From a82c1cdf1cd2e907494ede62af9256a344e94f62 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Tue, 1 Apr 2025 10:24:59 +0800 Subject: [PATCH 1/2] fix version --- .../packaging_tools/package_utils.py | 14 +++++-------- .../packaging_tools/sdk_package.py | 20 +++++++++++-------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tools/azure-sdk-tools/packaging_tools/package_utils.py b/tools/azure-sdk-tools/packaging_tools/package_utils.py index 77d55d023900..421f756f28bf 100644 --- a/tools/azure-sdk-tools/packaging_tools/package_utils.py +++ b/tools/azure-sdk-tools/packaging_tools/package_utils.py @@ -170,13 +170,6 @@ def next_version(self) -> str: self._next_version = self.calculate_next_version() return self._next_version - def get_private_package(self) -> List[str]: - return self.package_info["artifacts"] - - @property - def get_whl_package(self) -> str: - return [package for package in self.get_private_package() if package.endswith(".whl")][0] - # Use the template to update readme and setup by packaging_tools @return_origin_path def check_file_with_packaging_tool(self): @@ -369,5 +362,8 @@ def run(self): self.check_pyproject_toml() -def check_file(package_info: Dict[str, Any]): - CheckFile(package_info).run() +def check_file(package: Dict[str, Any]): + client = CheckFile(package) + client.run() + if not client.has_invalid_next_version: + package["version"] = client.next_version diff --git a/tools/azure-sdk-tools/packaging_tools/sdk_package.py b/tools/azure-sdk-tools/packaging_tools/sdk_package.py index 8a554779bd51..64f9cb269c3c 100644 --- a/tools/azure-sdk-tools/packaging_tools/sdk_package.py +++ b/tools/azure-sdk-tools/packaging_tools/sdk_package.py @@ -59,13 +59,8 @@ def main(generate_input, generate_output): package["version"] = last_version _LOGGER.info(f"[PACKAGE]({package_name})[CHANGELOG]:{md_output}") - # Built package - create_package(prefolder, package_name) - folder_name = package["path"][0] - dist_path = Path(sdk_folder, folder_name, package_name, "dist") - package["artifacts"] = [str(dist_path / package_file) for package_file in os.listdir(dist_path)] - package["result"] = "succeeded" # Generate api stub File + folder_name = package["path"][0] try: package_path = Path(sdk_folder, folder_name, package_name) check_call( @@ -99,9 +94,18 @@ def main(generate_input, generate_output): package["packageFolder"] = package["path"][0] result["packages"].append(package) - # check generated files + # check generated files and update package["version"] if package_name.startswith("azure-mgmt-"): - check_file(package) + try: + check_file(package) + except Exception as e: + _LOGGER.error(f"Fail to check generated files for {package_name}: {e}") + + # Built package + create_package(prefolder, package_name) + dist_path = Path(sdk_folder, folder_name, package_name, "dist") + package["artifacts"] = [str(dist_path / package_file) for package_file in os.listdir(dist_path)] + package["result"] = "succeeded" with open(generate_output, "w") as writer: json.dump(result, writer) From 1f81be72c9fb6cde96f7d95dd52e96c7d39373d7 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Tue, 1 Apr 2025 10:34:17 +0800 Subject: [PATCH 2/2] fix --- .../packaging_tools/sdk_package.py | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/azure-sdk-tools/packaging_tools/sdk_package.py b/tools/azure-sdk-tools/packaging_tools/sdk_package.py index 64f9cb269c3c..7ff3c6900849 100644 --- a/tools/azure-sdk-tools/packaging_tools/sdk_package.py +++ b/tools/azure-sdk-tools/packaging_tools/sdk_package.py @@ -82,17 +82,6 @@ def main(generate_input, generate_output): package["apiViewArtifact"] = str(Path(package_path, file)) except Exception as e: _LOGGER.debug(f"Fail to generate ApiView token file for {package_name}: {e}") - # Installation package - package["installInstructions"] = { - "full": "You can install the use using pip install of the artifacts.", - "lite": f"pip install {package_name}", - } - for artifact in package["artifacts"]: - if ".whl" in artifact: - package["language"] = "Python" - break - package["packageFolder"] = package["path"][0] - result["packages"].append(package) # check generated files and update package["version"] if package_name.startswith("azure-mgmt-"): @@ -105,7 +94,18 @@ def main(generate_input, generate_output): create_package(prefolder, package_name) dist_path = Path(sdk_folder, folder_name, package_name, "dist") package["artifacts"] = [str(dist_path / package_file) for package_file in os.listdir(dist_path)] + for artifact in package["artifacts"]: + if ".whl" in artifact: + package["language"] = "Python" + break + # Installation package + package["installInstructions"] = { + "full": "You can install the use using pip install of the artifacts.", + "lite": f"pip install {package_name}", + } package["result"] = "succeeded" + package["packageFolder"] = package["path"][0] + result["packages"].append(package) with open(generate_output, "w") as writer: json.dump(result, writer)