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..7ff3c6900849 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( @@ -87,22 +82,31 @@ 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}") + + # check generated files and update package["version"] + if package_name.startswith("azure-mgmt-"): + 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)] + 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}", } - for artifact in package["artifacts"]: - if ".whl" in artifact: - package["language"] = "Python" - break + package["result"] = "succeeded" package["packageFolder"] = package["path"][0] result["packages"].append(package) - # check generated files - if package_name.startswith("azure-mgmt-"): - check_file(package) - with open(generate_output, "w") as writer: json.dump(result, writer)