Skip to content
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

Pipenv code bug for explicit version in Pipfile: Invalid version: '=4.9.4' (2024.4.0) #6320

Open
ekimbernow opened this issue Dec 2, 2024 · 0 comments

Comments

@ekimbernow
Copy link

Issue description

Given a Pipfile with this entry:

lxml = "==4.9.4"

If I remove the Pipfile.lock and then run pipenv update --clear --verbose the processing fails:

Writing supplied requirement line to temporary file: 'lxml====4.9.4'
Install Phase: Editable Requirements
Preparing Installation of 'lxml====4.9.4'
$ /Users/eliot.kimber/.local/share/virtualenvs/apps-sources-_QT3Gbly/bin/python /Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/__pip-runner__.py 
install -i https://pypi.org/simple --no-input --upgrade --no-deps -r /var/folders/0p/v1g5ck5d2r9bdp48cjzjg25h0000gn/T/pipenv-fzo3qtq2-requirements/pipenv-gaknwoim-reqs.txt
Using source directory: '/Users/eliot.kimber/.local/share/virtualenvs/apps-sources-_QT3Gbly/src'
ERROR: Exception:
Traceback (most recent call last):
  File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_internal/cli/base_command.py", line 105, in _run_wrapper
    status = _inner_run()
  File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_internal/cli/base_command.py", line 96, in _inner_run
    return self.run(options, args)
  File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_internal/cli/req_command.py", line 67, in wrapper
    return func(self, options, args)
  File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_internal/commands/install.py", line 379, in run
    requirement_set = resolver.resolve(
  File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_internal/resolution/resolvelib/resolver.py", line 95, in resolve
    result = self._result = resolver.resolve(
  File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_vendor/resolvelib/resolvers.py", line 546, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_vendor/resolvelib/resolvers.py", line 397, in resolve
    self._add_to_criteria(self.state.criteria, r, parent=None)
  File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_vendor/resolvelib/resolvers.py", line 173, in _add_to_criteria
    if not criterion.candidates:
  File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_vendor/resolvelib/structs.py", line 156, in __bool__
    return bool(self._sequence)
  File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_internal/resolution/resolvelib/found_candidates.py", line 174, in __bool__
    return any(self)
  File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_internal/resolution/resolvelib/found_candidates.py", line 162, in <genexpr>
    return (c for c in iterator if id(c) not in self._incompatible_ids)
  File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_internal/resolution/resolvelib/found_candidates.py", line 49, in _iter_built
    for version, func in infos:
  File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_internal/resolution/resolvelib/factory.py", line 307, in iter_index_candidate_infos
    result = self._finder.find_best_candidate(
  File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_internal/index/package_finder.py", line 902, in find_best_candidate
    return candidate_evaluator.compute_best_candidate(candidates)
  File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_internal/index/package_finder.py", line 579, in compute_best_candidate
    applicable_candidates = self.get_applicable_candidates(candidates)
  File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_internal/index/package_finder.py", line 469, in get_applicable_candidates
    specifier.filter(
  File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_vendor/packaging/specifiers.py", line 977, in filter
    prereleases = self.prereleases
  File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_vendor/packaging/specifiers.py", line 739, in prereleases
    return any(s.prereleases for s in self._specs)
  File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_vendor/packaging/specifiers.py", line 739, in <genexpr>
    return any(s.prereleases for s in self._specs)
  File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_vendor/packaging/specifiers.py", line 267, in prereleases
    if Version(version).is_prerelease:
  File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_vendor/packaging/version.py", line 202, in __init__
    raise InvalidVersion(f"Invalid version: '{version}'")
pipenv.patched.pip._vendor.packaging.version.InvalidVersion: Invalid version: '=4.9.4'
: ERROR: Exception:
: Traceback (most recent call last):
:   File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_internal/cli/base_command.py", line 105, in _run_wrapper
:     status = _inner_run()
:   File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_internal/cli/base_command.py", line 96, in _inner_run
:     return self.run(options, args)
:   File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_internal/cli/req_command.py", line 67, in wrapper
:     return func(self, options, args)
:   File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_internal/commands/install.py", line 379, in run
:     requirement_set = resolver.resolve(
:   File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_internal/resolution/resolvelib/resolver.py", line 95, in resolve
:     result = self._result = resolver.resolve(
:   File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_vendor/resolvelib/resolvers.py", line 546, in resolve
:     state = resolution.resolve(requirements, max_rounds=max_rounds)
:   File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_vendor/resolvelib/resolvers.py", line 397, in resolve
:     self._add_to_criteria(self.state.criteria, r, parent=None)
:   File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_vendor/resolvelib/resolvers.py", line 173, in _add_to_criteria
:     if not criterion.candidates:
:   File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_vendor/resolvelib/structs.py", line 156, in __bool__
:     return bool(self._sequence)
:   File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_internal/resolution/resolvelib/found_candidates.py", line 174, in __bool__
:     return any(self)
:   File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_internal/resolution/resolvelib/found_candidates.py", line 162, in <genexpr>
:     return (c for c in iterator if id(c) not in self._incompatible_ids)
:   File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_internal/resolution/resolvelib/found_candidates.py", line 49, in _iter_built
:     for version, func in infos:
:   File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_internal/resolution/resolvelib/factory.py", line 307, in iter_index_candidate_infos
:     result = self._finder.find_best_candidate(
:   File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_internal/index/package_finder.py", line 902, in find_best_candidate
:     return candidate_evaluator.compute_best_candidate(candidates)
:   File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_internal/index/package_finder.py", line 579, in compute_best_candidate
:     applicable_candidates = self.get_applicable_candidates(candidates)
:   File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_internal/index/package_finder.py", line 469, in get_applicable_candidates
:     specifier.filter(
:   File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_vendor/packaging/specifiers.py", line 977, in filter
:     prereleases = self.prereleases
:   File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_vendor/packaging/specifiers.py", line 739, in prereleases
:     return any(s.prereleases for s in self._specs)
:   File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_vendor/packaging/specifiers.py", line 739, in <genexpr>
:     return any(s.prereleases for s in self._specs)
:   File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_vendor/packaging/specifiers.py", line 267, in prereleases
:     if Version(version).is_prerelease:
:   File "/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv/patched/pip/_vendor/packaging/version.py", line 202, in __init__
:     raise InvalidVersion(f"Invalid version: '{version}'")
: pipenv.patched.pip._vendor.packaging.version.InvalidVersion: Invalid version: '=4.9.4'
ERROR: Couldn't install package: [1m{}[0m
 [33mPackage installation failed...[0m

With the same Pipfile, I have also gotten a "str does not have method 'get'" on this line in update.py:

if pipfile_entry["version"] != locked_entry.get("version", ""):

Doing a bit of debugging, it looked like the locked_packages dictionary had simple string values rather than the objects the code expects:

*** DEBUG: locked_packages:
{'aenum': '*', 'anytree': '*', 'babel': '*', 'bs4': '*', 'certifi': '*', 'darkdetect': '*', 'furo': '*', 'load_dotenv': '*', 'lxml': '*', 'nltk': '*', 'openpyxl': '*', 'pillow': '*', 'progressbar2': '*', 'pyinstaller': '*', 'pyinstaller-hooks-contrib': '*', 'pylightxl': '*', 'pytest': '*', 'python-dotenv': '*', 'pyyaml': '*', 'requests': '*', 'sphinx': '*', 'tkcalendar': '*', 'tkscrolledframe': '*', 'urllib3': '*', 'xlsxwriter': '*'}
*** DEBUG: locked_entry is str: True

Expected result

Update succeeds.

If I install 2024.3.1, update succeeds.

macOS, Python 3.10.4 (installed via homebrew)

Actual result

pipenv-2024-04-01.txt

Steps to replicate

  1. Remove Pipfile.lock
  2. Run pipenv update --clear

Full Pipfile is:

# Normal use Pipfile. This Pipfile uses nowutils and ditalib from GitHub.
#
# To use the nowutils and ditalib modules from their locally-cloned source 
# locations (i.e., to do development on those modules but test it in the context
# of an apps-sources Python app), use the Pipfile-dev Pipfile, which you can do
# by setting the PIPENV_PIPFILE environment variable. You can do that directly
# on the command line:
#
#   PIPENV_PIPFILE=path/to/pipfile pipenv=Pipfile-dev pipenv shell
#
#    or
#
#   PIPENV_PIPFILE=path/to/pipfile pipenv=Pipfile-dev pipenv run myscript.py
#
#==================================================================================

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

[packages]
aenum = "*"
tkcalendar = "*"
urllib3 = "*"
anytree = "*"
xlsxwriter = "*"
requests = "*"
certifi = "*"
nltk = "*"
pytest = "*"
pillow = "*"
openpyxl = "*"
pyyaml = "*"
progressbar2 = "*"
sphinx = "*"
furo = "*"
pyinstaller = "*"
pyinstaller-hooks-contrib = "*"
babel = "*"
darkdetect = "*"
pylightxl = "*"
bs4 = "*"
tkscrolledframe = "*"
load_dotenv = "*"
python-dotenv = "*"
lxml = "==4.9.4"
# lxml = "*"

[dev-packages]
pytest = "*"
pylint = "*"

[requires]
python_version = "3.10"

$ pipenv --support

Pipenv version: '2024.4.0'

Pipenv location: '/Users/eliot.kimber/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pipenv'

Python location: '/Users/eliot.kimber/.pyenv/versions/3.10.4/bin/python3.10'

OS Name: 'posix'

User pip version: '24.3.1'

user Python installations found:

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.10.4',
 'os_name': 'posix',
 'platform_machine': 'arm64',
 'platform_python_implementation': 'CPython',
 'platform_release': '23.6.0',
 'platform_system': 'Darwin',
 'platform_version': 'Darwin Kernel Version 23.6.0: Thu Sep 12 23:35:10 PDT '
                     '2024; root:xnu-10063.141.1.701.1~1/RELEASE_ARM64_T6030',
 'python_full_version': '3.10.4',
 'python_version': '3.10',
 'sys_platform': 'darwin'}

System environment variables:

  • SHELL
  • PYENV_HOOK_PATH
  • PYENV_SHELL
  • XPC_FLAGS
  • TERM_PROGRAM_VERSION
  • JAVA_HOME
  • OXYGEN_HOME
  • __CFBundleIdentifier
  • SSH_AUTH_SOCK
  • TERM_SESSION_ID
  • ANT_HOME
  • HOMEBREW_PREFIX
  • PYENV_VERSION
  • PWD
  • LOGNAME
  • LaunchInstanceID
  • GIT_EXECUTABLE
  • HOME
  • LANG
  • BASEX_HOME
  • SECURITYSESSIONID
  • TMPDIR
  • BASEX_REPORT_DIR
  • PYENV_DIR
  • INFOPATH
  • TERM
  • USER
  • HOMEBREW_CELLAR
  • SHLVL
  • HOMEBREW_REPOSITORY
  • XPC_SERVICE_NAME
  • BASEX_GIT
  • NOW_DITA_AUTHOR_TOOLS_DEBUG
  • PYENV_ROOT
  • NOW_DITA_AUTHOR_TOOLS_DEV
  • PATH
  • HISTFILESIZE
  • OLDPWD
  • TERM_PROGRAM
  • __CF_USER_TEXT_ENCODING
  • PIP_DISABLE_PIP_VERSION_CHECK
  • PYTHONDONTWRITEBYTECODE
  • SEMAPHORE_API_KEY
  • SEMAPHORE_ACCESS_TOKEN
  • PYTHONFINDER_IGNORE_UNSUPPORTED

Pipenv–specific environment variables:

Debug–specific environment variables:

  • PATH: /Users/eliot.kimber/.pyenv/versions/3.10.4/bin:/Users/eliot.kimber/.pyenv/versions/3.10.5/bin:/Users/eliot.kimber/.pyenv/versions/3.10.4/bin:/opt/homebrew/Cellar/pyenv/2.4.19/libexec:/opt/homebrew/Cellar/pyenv/2.4.19/plugins/python-build/bin:/opt/homebrew/opt/openjdk/bin:/usr/local/opt/openjdk@17/bin:/Users/eliot.kimber/.pyenv/shims:/opt/homebrew/bin:/opt/homebrew/sbin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/eliot.kimber/.local/bin:/Users/eliot.kimber/apps/basex_10_7/bin:/Users/eliot.kimber/git/dita-build-tools/apps
  • SHELL: /bin/zsh
  • LANG: en_US.UTF-8
  • PWD: /Users/eliot.kimber/git/dita-build-tools/apps-sources

Contents of Pipfile ('/Users/eliot.kimber/git/dita-build-tools/apps-sources/Pipfile'):

# Normal use Pipfile. This Pipfile uses nowutils and ditalib from GitHub.
#
# To use the nowutils and ditalib modules from their locally-cloned source 
# locations (i.e., to do development on those modules but test it in the context
# of an apps-sources Python app), use the Pipfile-dev Pipfile, which you can do
# by setting the PIPENV_PIPFILE environment variable. You can do that directly
# on the command line:
#
#   PIPENV_PIPFILE=path/to/pipfile pipenv=Pipfile-dev pipenv shell
#
#    or
#
#   PIPENV_PIPFILE=path/to/pipfile pipenv=Pipfile-dev pipenv run myscript.py
#
#==================================================================================

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

[packages]
aenum = "*"
tkcalendar = "*"
urllib3 = "*"
anytree = "*"
xlsxwriter = "*"
requests = "*"
certifi = "*"
nltk = "*"
pytest = "*"
pillow = "*"
openpyxl = "*"
pyyaml = "*"
progressbar2 = "*"
sphinx = "*"
furo = "*"
pyinstaller = "*"
pyinstaller-hooks-contrib = "*"
babel = "*"
darkdetect = "*"
pylightxl = "*"
bs4 = "*"
tkscrolledframe = "*"
load_dotenv = "*"
python-dotenv = "*"
lxml = "==4.9.4"
# lxml = "*"

[dev-packages]
pytest = "*"
pylint = "*"

[requires]
python_version = "3.10"

Contents of Pipfile.lock ('/Users/eliot.kimber/git/dita-build-tools/apps-sources/Pipfile.lock'):

{
    "_meta": {
        "hash": {
            "sha256": "e4b748238135bf90723f43150ce865e6aeda2e188ae85ae32c1ff55992e33f87"
        },
        "pipfile-spec": 6,
        "requires": {
            "python_version": "3.10"
        },
        "sources": [
            {
                "name": "pypi",
                "url": "https://pypi.org/simple",
                "verify_ssl": true
            }
        ]
    },
    "default": {
        "aenum": "*",
        "anytree": "*",
        "babel": "*",
        "bs4": "*",
        "certifi": "*",
        "darkdetect": "*",
        "furo": "*",
        "load_dotenv": "*",
        "lxml": "==4.9.4",
        "nltk": "*",
        "openpyxl": "*",
        "pillow": "*",
        "progressbar2": "*",
        "pyinstaller": "*",


        "pyinstaller-hooks-contrib": "*",
        "pylightxl": "*",
        "pytest": "*",
        "python-dotenv": "*",
        "pyyaml": "*",
        "requests": "*",
        "sphinx": "*",
        "tkcalendar": "*",
        "tkscrolledframe": "*",
        "urllib3": "*",
        "xlsxwriter": "*"
    },
    "develop": {
        "pylint": "*",
        "pytest": "*"
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant