diff --git a/eng/pipelines/templates/steps/run_apistub.yml b/eng/pipelines/templates/steps/run_apistub.yml index ea84514f3ba0..cf738f19a922 100644 --- a/eng/pipelines/templates/steps/run_apistub.yml +++ b/eng/pipelines/templates/steps/run_apistub.yml @@ -31,14 +31,18 @@ steps: condition: and(succeededOrFailed(), ne(variables['Skip.ApiStubGen'],'true')) displayName: 'Generate API stub files' inputs: - scriptPath: 'scripts/devops_tasks/dispatch_tox.py' + scriptPath: 'eng/scripts/dispatch_checks.py' arguments: >- "$(TargetingString)" ${{ parameters.AdditionalTestArgs }} -d "$(Build.ArtifactStagingDirectory)" --mark_arg="${{ parameters.TestMarkArgument }}" --service="${{ parameters.ServiceDirectory }}" - --toxenv="apistub" + --checks="apistub" --disablecov --filter-type="Omit_management" - ${{ parameters.AdditionalTestArgs }} \ No newline at end of file + ${{ parameters.AdditionalTestArgs }} + env: + TOX_PIP_IMPL: "uv" + VIRTUAL_ENV: "" + PYTHONHOME: "" \ No newline at end of file diff --git a/eng/tools/azure-sdk-tools/azpysdk/Check.py b/eng/tools/azure-sdk-tools/azpysdk/Check.py index 212e089b82d0..697a32ce4525 100644 --- a/eng/tools/azure-sdk-tools/azpysdk/Check.py +++ b/eng/tools/azure-sdk-tools/azpysdk/Check.py @@ -71,6 +71,13 @@ def create_venv(self, isolate: bool, venv_location: str) -> str: subprocess.check_call(venv_cmd + [venv_location]) + # ensure uv venv has pip for tools that require pip + if venv_cmd[0] == "uv": + try: + subprocess.check_call(["uv", "pip", "install", "--python", venv_python, "pip"]) + except subprocess.CalledProcessError as e: + logger.error(f"Failed to ensure pip in uv venv: {e}") + if in_ci(): # first attempt to retrieve azure-sdk-tools from the prebuilt wheel directory # if present, install from there instead of constantly rebuilding azure-sdk-tools in a possible diff --git a/eng/tools/azure-sdk-tools/azpysdk/apistub.py b/eng/tools/azure-sdk-tools/azpysdk/apistub.py index 183f76aee7ae..d97d68edc4bb 100644 --- a/eng/tools/azure-sdk-tools/azpysdk/apistub.py +++ b/eng/tools/azure-sdk-tools/azpysdk/apistub.py @@ -16,13 +16,12 @@ MAX_PYTHON_VERSION = (3, 11) -def get_package_wheel_path(pkg_root: str, out_path: Optional[str]) -> tuple[str, Optional[str]]: +def get_package_wheel_path(pkg_root: str) -> str: # parse setup.py to get package name and version pkg_details = ParsedSetup.from_path(pkg_root) # Check if wheel is already built and available for current package prebuilt_dir = os.getenv("PREBUILT_WHEEL_DIR") - out_token_path = None if prebuilt_dir: found_whl = find_whl(prebuilt_dir, pkg_details.name, pkg_details.version) pkg_path = os.path.join(prebuilt_dir, found_whl) if found_whl else None @@ -32,16 +31,10 @@ def get_package_wheel_path(pkg_root: str, out_path: Optional[str]) -> tuple[str, pkg_details.name, pkg_details.version, prebuilt_dir ) ) - # If the package is a wheel and out_path is given, the token file output path should be the parent directory of the wheel - if out_path: - out_token_path = os.path.join(out_path, os.path.basename(os.path.dirname(pkg_path))) - return pkg_path, out_token_path - + return pkg_path # Otherwise, use wheel created in staging directory, or fall back on source directory pkg_path = find_whl(pkg_root, pkg_details.name, pkg_details.version) or pkg_root - out_token_path = out_path - - return pkg_path, out_token_path + return pkg_path def get_cross_language_mapping_path(pkg_root): @@ -106,7 +99,7 @@ def run(self, args: argparse.Namespace) -> int: create_package_and_install( distribution_directory=staging_directory, target_setup=package_dir, - skip_install=True, + skip_install=False, cache_dir=None, work_dir=staging_directory, force_create=False, @@ -117,9 +110,16 @@ def run(self, args: argparse.Namespace) -> int: self.pip_freeze(executable) - pkg_path, out_token_path = get_package_wheel_path(package_dir, staging_directory) + pkg_path = get_package_wheel_path(package_dir) + out_token_path = staging_directory cross_language_mapping_path = get_cross_language_mapping_path(package_dir) + pkg_path = os.path.abspath(pkg_path) + if out_token_path: + out_token_path = os.path.abspath(out_token_path) + if cross_language_mapping_path: + cross_language_mapping_path = os.path.abspath(cross_language_mapping_path) + cmds = ["-m", "apistub", "--pkg-path", pkg_path] if out_token_path: @@ -130,7 +130,7 @@ def run(self, args: argparse.Namespace) -> int: logger.info("Running apistub {}.".format(cmds)) try: - self.run_venv_command(executable, cmds, cwd=package_dir, check=True, immediately_dump=True) + self.run_venv_command(executable, cmds, cwd=staging_directory, check=True, immediately_dump=True) except CalledProcessError as e: logger.error(f"{package_name} exited with error {e.returncode}") results.append(e.returncode)