-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Default to CFS for uv and azpysdk #46281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
897a44a
253e23d
0987188
871de8d
df5f8a9
908e6ba
a1c0457
720cf00
b74ae0c
8d8b816
571e779
db37b8e
a66d4d9
012a599
7153c62
419fc32
5407e5f
cf34d73
9ca4540
7715247
5a719d4
28bf1c8
50b8d4b
429a9df
fb334ca
705d916
8a2bbc8
ea4e9c4
1d23eda
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| name: 'Configure Package Indexes' | ||
| description: 'Configure pip/uv package indexes to use Azure SDK CFS feed' | ||
|
|
||
| runs: | ||
| using: 'composite' | ||
| steps: | ||
| - name: Configure package indexes | ||
| run: | | ||
| echo "PIP_INDEX_URL=https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/" >> "$GITHUB_ENV" | ||
| echo "UV_DEFAULT_INDEX=https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/" >> "$GITHUB_ENV" | ||
| shell: bash |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,12 +41,13 @@ | |
| from .devtest import devtest | ||
| from .optional import optional | ||
| from .update_snippet import update_snippet | ||
|
|
||
| from ci_tools.logging import configure_logging, logger | ||
|
|
||
| __all__ = ["main", "build_parser"] | ||
| __version__ = "0.0.0" | ||
|
|
||
| CFS_INDEX_URL = "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/" | ||
|
|
||
|
|
||
| def build_parser() -> argparse.ArgumentParser: | ||
| """Create and return the top-level ArgumentParser for the CLI.""" | ||
|
|
@@ -56,6 +57,12 @@ def build_parser() -> argparse.ArgumentParser: | |
| parser.add_argument( | ||
| "--isolate", action="store_true", default=False, help="If set, run in an isolated virtual environment." | ||
| ) | ||
| parser.add_argument( | ||
| "--pypi", | ||
| action="store_true", | ||
| default=False, | ||
| help="Use PyPI directly instead of the CFS (Central Feed Services) feed.", | ||
| ) | ||
|
Comment on lines
+60
to
+65
|
||
| parser.add_argument( | ||
| "--python", | ||
| default=None, | ||
|
|
@@ -155,6 +162,9 @@ def main(argv: Optional[Sequence[str]] = None) -> int: | |
| Exit code to return to the OS. | ||
| """ | ||
| original_cwd = os.getcwd() | ||
| # Save original env vars so we can restore them when azpysdk finishes | ||
| original_pip_index = os.environ.get("PIP_INDEX_URL") | ||
| original_uv_index = os.environ.get("UV_DEFAULT_INDEX") | ||
|
|
||
| parser = build_parser() | ||
| args = parser.parse_args(argv) | ||
|
|
@@ -171,6 +181,23 @@ def main(argv: Optional[Sequence[str]] = None) -> int: | |
| if uv_path: | ||
| os.environ["TOX_PIP_IMPL"] = "uv" | ||
|
|
||
| # default to CFS feed unless --pypi is specified, but allow explicit env var override (e.g. for CI) | ||
| if args.pypi: | ||
| # Explicitly set PyPI URLs to override uv.toml CFS default | ||
| os.environ["PIP_INDEX_URL"] = "https://pypi.org/simple/" | ||
| os.environ["UV_DEFAULT_INDEX"] = "https://pypi.org/simple/" | ||
| logger.info("Installing from PyPI (--pypi flag set)") | ||
| else: | ||
| using_cfs = False | ||
| if not os.environ.get("PIP_INDEX_URL"): | ||
| os.environ["PIP_INDEX_URL"] = CFS_INDEX_URL | ||
| using_cfs = True | ||
| if not os.environ.get("UV_DEFAULT_INDEX"): | ||
| os.environ["UV_DEFAULT_INDEX"] = CFS_INDEX_URL | ||
| using_cfs = True | ||
|
|
||
| if using_cfs: | ||
| logger.info("Installing from CFS feed: %s", CFS_INDEX_URL) | ||
| # --python requires both --isolate and uv | ||
| python_version = getattr(args, "python_version", None) | ||
| if python_version: | ||
|
|
@@ -196,6 +223,15 @@ def main(argv: Optional[Sequence[str]] = None) -> int: | |
| return 2 | ||
| finally: | ||
| os.chdir(original_cwd) | ||
| # Restore original env vars (or remove them if they weren't set before) | ||
| if original_pip_index is None: | ||
| os.environ.pop("PIP_INDEX_URL", None) | ||
| else: | ||
| os.environ["PIP_INDEX_URL"] = original_pip_index | ||
| if original_uv_index is None: | ||
| os.environ.pop("UV_DEFAULT_INDEX", None) | ||
| else: | ||
| os.environ["UV_DEFAULT_INDEX"] = original_uv_index | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| [[index]] | ||
| name = "azure-sdk" | ||
| url = "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/" | ||
| default = true |
Uh oh!
There was an error while loading. Please reload this page.