From f98a98f865a226999e1c1e1ce1a73a36e19fedf5 Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Mon, 3 Jul 2023 20:36:15 +0200 Subject: [PATCH] Use pip config list to detect index url --- python/packaging/frontend_sdist/setup.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/python/packaging/frontend_sdist/setup.py b/python/packaging/frontend_sdist/setup.py index 96e4aeb9b..2d980f87f 100644 --- a/python/packaging/frontend_sdist/setup.py +++ b/python/packaging/frontend_sdist/setup.py @@ -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() @@ -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: