Skip to content

Commit

Permalink
Use pip config list to detect index url
Browse files Browse the repository at this point in the history
Signed-off-by: ddelange <14880945+ddelange@users.noreply.github.com>
  • Loading branch information
ddelange committed Jul 3, 2023
1 parent 6fd6064 commit fc53814
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions python/packaging/frontend_sdist/setup.py
Expand Up @@ -46,6 +46,17 @@ def run(self):
super().run()


def pip_config_list():
"""Get the current pip config (env vars, config file, etc)."""
return subprocess.check_output(
[
"{}/bin/pip".format(sys.exec_prefix),
"config",
"list",
]
).decode()


def parent_command_line():
"""Get the command line of the parent PID."""
pid = os.getppid()
Expand All @@ -68,10 +79,7 @@ def parent_command_line():


# use pip-inside-pip hack only if the nvidia index is not set in the environment
if (
"pypi.nvidia.com" in os.environ.get("PIP_EXTRA_INDEX_URL", "")
or "pypi.nvidia.com" in parent_command_line()
):
if "pypi.nvidia.com" in pip_config_list() or "pypi.nvidia.com" in parent_command_line():
install_requires = tensorrt_submodules
cmdclass = {}
else:
Expand Down

0 comments on commit fc53814

Please sign in to comment.