Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions eng/pipelines/templates/steps/run_apistub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
${{ parameters.AdditionalTestArgs }}
env:
TOX_PIP_IMPL: "uv"
VIRTUAL_ENV: ""
PYTHONHOME: ""
7 changes: 7 additions & 0 deletions eng/tools/azure-sdk-tools/azpysdk/Check.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 13 additions & 13 deletions eng/tools/azure-sdk-tools/azpysdk/apistub.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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,
Expand All @@ -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:
Expand All @@ -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)
Expand Down
Loading