Skip to content

Add support for global index-urls #170

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

Closed
Closed
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
13 changes: 11 additions & 2 deletions src/python_inspector/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import os
from netrc import netrc
from pip._internal.configuration import Configuration
from typing import Dict
from typing import List
from typing import NamedTuple
Expand Down Expand Up @@ -101,7 +102,7 @@ def resolve_dependencies(
linux OS.

Download from the provided PyPI simple index_urls INDEX(s) URLs defaulting
to PyPI.org
to PyPI.org if not global index-url is configured, overriding PyPI.org
"""

if not operating_system:
Expand Down Expand Up @@ -146,7 +147,15 @@ def resolve_dependencies(

files = []

if PYPI_SIMPLE_URL not in index_urls:
# We need respect system and user configuration
# before explicitly assign PYPI
config = Configuration(True)
config.load()

global_index: str | None = config.get_value('global.index-url')
if global_index and global_index not in index_urls:
index_urls = tuple([global_index]) + tuple(index_urls)
elif PYPI_SIMPLE_URL not in index_urls:
index_urls = tuple([PYPI_SIMPLE_URL]) + tuple(index_urls)

# requirements
Expand Down