pipenv icon indicating copy to clipboard operation
pipenv copied to clipboard

`PIP_INDEX_URL` does not work when `pipenv install` directly against `Pipfile`

Open huxuan opened this issue 4 years ago • 3 comments

Be sure to check the existing issues (both open and closed!), and make sure you are running the latest version of Pipenv.

Check the diagnose documentation for common issues before posting! We may close your issue if it is very similar to one of them. Please be considerate, or be on your way.

Make sure to mention your debugging experience if the documented solution failed.

Issue description

When running pipenv install -v (with Pipfile exists in the same directory and no specific packages), seems PIP_INDEX_URL and PIP_EXTRA_INDEX_URL will not take effects, but pipenv install -v [specific-package] seems to work.

P.S. Setting PIPENV_PYPI_MIRROR overrides the behavior but might not be a fix to this bug I think.

Expected result

$ ['/root/.local/share/virtualenvs/-x-v5uFv0/bin/pip', 'install', '--verbose', '--upgrade', '--exists-action=i', '-r', '/tmp/pipenv-y1y1ullx-requirements/pipenv-xwj6d0w7-requirement.txt', '-i', '<customized_pypi_mirror>', '--extra-index-url', 'https://pypi.org/simple']

Actual result

$ ['/root/.local/share/virtualenvs/-x-v5uFv0/bin/pip', 'install', '--verbose', '--upgrade', '--require-hashes', '--no-deps', '--exists-action=i', '-r', '/tmp/pipenv-xgumh48f-requirements/pipenv-n4appqla-requirement.txt', '-i', 'https://pypi.org/simple']

Steps to replicate

Provide the steps to replicate (which usually at least includes the commands and the Pipfile).

The Pipfile

[dev-packages]

[packages]
requests = "*"

[requires]
python_version = "3.9"

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

Run in python docker container for example

docker pull python:3.9
docker run --rm -it --entrypoint bash -v <path/to/Pipfile>:/Pipfile python:3.9

Commands inside the container

export PIP_INDEX_URL=<customized_pypi_mirror>
pip install pipenv # Install pipenv from <customized_pypi_mirror>
pipenv install -v # This only installs from pypi.org
pipenv --rm # Clean
pipenv install -v requests # This installs from the specified <customized_pypi_mirror>

$ pipenv --support

Pipenv version: '2021.5.29'

Pipenv location: '/usr/local/lib/python3.9/site-packages/pipenv'

Python location: '/usr/local/bin/python'

Python installations found:

  • 3.9.7: /usr/local/bin/python3.9
  • 3.9.7: /usr/local/bin/python3
  • 3.9.2: /usr/bin/python3.9
  • 3.9.2: /usr/bin/python3

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.9.7',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '5.10.47-linuxkit',
 'platform_system': 'Linux',
 'platform_version': '#1 SMP Sat Jul 3 21:51:47 UTC 2021',
 'python_full_version': '3.9.7',
 'python_version': '3.9',
 'sys_platform': 'linux'}

System environment variables:

  • HOSTNAME
  • PYTHON_VERSION
  • PWD
  • PYTHON_SETUPTOOLS_VERSION
  • HOME
  • LANG
  • PIP_EXTRA_INDEX_URL
  • GPG_KEY
  • TERM
  • SHLVL
  • PYTHON_PIP_VERSION
  • PYTHON_GET_PIP_SHA256
  • PYTHON_GET_PIP_URL
  • PATH
  • _
  • PIP_DISABLE_PIP_VERSION_CHECK
  • PYTHONDONTWRITEBYTECODE
  • PIP_SHIMS_BASE_MODULE
  • PIP_PYTHON_PATH
  • PYTHONFINDER_IGNORE_UNSUPPORTED

Pipenv–specific environment variables:

Debug–specific environment variables:

  • PATH: /usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  • LANG: C.UTF-8
  • PWD: /

Contents of Pipfile ('/Pipfile'):

[dev-packages]

[packages]
requests = "*"

[requires]
python_version = "3.9"

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

Contents of Pipfile.lock ('/Pipfile.lock'):

{
    "_meta": {
        "hash": {
            "sha256": "b8c2e1580c53e383cfe4254c1f16560b855d984fde8b2beb3bf6ee8fc2fe5a22"
        },
        "pipfile-spec": 6,
        "requires": {
            "python_version": "3.9"
        },
        "sources": [
            {
                "name": "pypi",
                "url": "https://pypi.org/simple",
                "verify_ssl": true
            }
        ]
    },
    "default": {
        "certifi": {
            "hashes": [
                "sha256:78884e7c1d4b00ce3cea67b44566851c4343c120abd683433ce934a68ea58872",
                "sha256:d62a0163eb4c2344ac042ab2bdf75399a71a2d8c7d47eac2e2ee91b9d6339569"
            ],
            "version": "==2021.10.8"
        },
        "charset-normalizer": {
            "hashes": [
                "sha256:e019de665e2bcf9c2b64e2e5aa025fa991da8720daa3c1138cadd2fd1856aed0",
                "sha256:f7af805c321bfa1ce6714c51f254e0d5bb5e5834039bc17db7ebe3a4cec9492b"
            ],
            "markers": "python_version >= '3'",
            "version": "==2.0.7"
        },
        "idna": {
            "hashes": [
                "sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff",
                "sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d"
            ],
            "markers": "python_version >= '3'",
            "version": "==3.3"
        },
        "requests": {
            "hashes": [
                "sha256:6c1246513ecd5ecd4528a0906f910e8f0f9c6b8ec72030dc9fd154dc1a6efd24",
                "sha256:b8aa58f8cf793ffd8782d3d8cb19e66ef36f7aba4353eec859e74678b01b07a7"
            ],
            "index": "pypi",
            "version": "==2.26.0"
        },
        "urllib3": {
            "hashes": [
                "sha256:4987c65554f7a2dbf30c18fd48778ef124af6fab771a377103da0585e2336ece",
                "sha256:c4fdf4019605b6e5423637e01bc9fe4daef873709a7973e195ceba0a62bbc844"
            ],
            "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'",
            "version": "==1.26.7"
        }
    },
    "develop": {}
}

huxuan avatar Oct 17 '21 08:10 huxuan

@huxuan This feels like a duplicate request of https://github.com/pypa/pipenv/issues/3920 Edit: Ok well similar but different, since that request wants to support a variable that defaults to something within the Pipfile and this is concerned with just the variable PIP_INDEX_URL

There is also another issue where @frostming talks about the difficulty in supporting the PIP_ environment variables: https://github.com/pypa/pipenv/issues/4453#issuecomment-724586448

matteius avatar Dec 24 '21 03:12 matteius

@huxuan I believe with the completion of Index Restricted Packages that this ticket should be resolved. Please see the updated documentation around specifying package indexes: https://pipenv.pypa.io/en/latest/advanced/#specifying-package-indexes

Feel free to comment back with any question or clarifying request.

matteius avatar Apr 21 '22 01:04 matteius

I perhaps misunderstood this issue prior, or well it at least relates to a PR I started working on: https://github.com/pypa/pipenv/pull/5297

matteius avatar Sep 03 '22 11:09 matteius

pipenv==2023.2.18 has been released with support for reading index information from pip.conf or pip.ini

matteius avatar Feb 18 '23 22:02 matteius