Skip to content
3 changes: 2 additions & 1 deletion eng/apiview_reqs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ tomli==2.2.1
tomlkit==0.13.2
typing_extensions==4.15.0
wrapt==1.17.2
apiview-stub-generator==0.3.25
apiview-stub-generator==0.3.25
pip
5 changes: 2 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,13 @@ 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 }}
23 changes: 11 additions & 12 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 @@ -117,9 +110,15 @@ 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)
pkg_path = os.path.abspath(pkg_path)

out_token_path = os.path.abspath(staging_directory)
cross_language_mapping_path = get_cross_language_mapping_path(package_dir)

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 +129,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