Skip to content
Merged
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
3 changes: 3 additions & 0 deletions eng/pipelines/templates/jobs/apireview-hub-job-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ jobs:
imageOverride: ${{ parameters.imageOverride }}
sourceRepositoryFullName: ${{ format('{0}/azure-sdk-for-python', parameters.repositoryOwner) }}
sourceCheckoutDir: $(Pipeline.Workspace)/apireview/source
variables:
- name: PIP_NO_INPUT
value: '1'
setupSteps:
- task: UsePythonVersion@0
displayName: 'Use Python ${{ parameters.pythonVersion }}'
Expand Down
10 changes: 7 additions & 3 deletions eng/tools/azure-sdk-tools/azpysdk/apistub.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
PYPI_INDEX_URL = "https://pypi.org/simple/"


def get_package_wheel_path(pkg_root: str) -> str:
def get_package_wheel_path(pkg_root: str, staging_dir: Optional[str] = None) -> str:
# parse setup.py to get package name and version
pkg_details = ParsedSetup.from_path(pkg_root)

Expand All @@ -34,7 +34,11 @@ def get_package_wheel_path(pkg_root: str) -> str:
)
)
return pkg_path
# Otherwise, use wheel created in staging directory, or fall back on source directory
if staging_dir:
found_whl = find_whl(staging_dir, pkg_details.name, pkg_details.version)
if found_whl:
return os.path.join(staging_dir, found_whl)
# Otherwise, use a wheel in the source directory, or fall back on the source directory
pkg_path = find_whl(pkg_root, pkg_details.name, pkg_details.version) or pkg_root
return pkg_path

Expand Down Expand Up @@ -197,7 +201,7 @@ def run(self, args: argparse.Namespace) -> int:
pre_download_disabled=False,
python_executable=executable,
)
pkg_path = get_package_wheel_path(package_dir)
pkg_path = get_package_wheel_path(package_dir, staging_directory)

if install_deps:
self.pip_freeze(executable)
Expand Down
13 changes: 13 additions & 0 deletions eng/tools/azure-sdk-tools/tests/test_apistub.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,19 @@ def test_no_prebuilt_dir_returns_found_whl(self, mock_find_whl, mock_parsed, mon
result = get_package_wheel_path("/my/pkg")
assert result == "azure_core-1.0.0-py3-none-any.whl"

@patch("azpysdk.apistub.ParsedSetup")
@patch("azpysdk.apistub.find_whl")
def test_no_prebuilt_dir_returns_staging_whl(self, mock_find_whl, mock_parsed, monkeypatch):
monkeypatch.delenv("PREBUILT_WHEEL_DIR", raising=False)
mock_parsed.from_path.return_value.name = "azure-core"
mock_parsed.from_path.return_value.version = "1.0.0"
mock_find_whl.return_value = "azure_core-1.0.0-py3-none-any.whl"

result = get_package_wheel_path("/my/pkg", "/staging")

assert result == os.path.join("/staging", "azure_core-1.0.0-py3-none-any.whl")
mock_find_whl.assert_called_once_with("/staging", "azure-core", "1.0.0")

@patch("azpysdk.apistub.ParsedSetup")
@patch("azpysdk.apistub.find_whl")
def test_no_prebuilt_dir_falls_back_to_pkg_root(self, mock_find_whl, mock_parsed, monkeypatch):
Expand Down
Loading