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

Pipfile: dev-packages cause an error if main dependencies use a custom index repo #6237

Open
stokito opened this issue Sep 11, 2024 · 0 comments
Labels

Comments

@stokito
Copy link

stokito commented Sep 11, 2024

Issue description

I have a Pipfile with two sources: pypi and internal for a company. In packages declared dependencies from the internal index. Additionally there is the dev-packages that declares one dep:

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

[[source]]
name = "internal"
url = "https://artifactory.example.net/artifactory/api/pypi/internal/simple"
verify_ssl = true


[requires]
python_version = "3.11"

[packages]
internal-dependency = { version = "1.0.0", index = "internal" }

[dev-packages]
tox = "*"

Expected result

When making the pipenv lock it resolves deps and creates the Pipfile.lock.

Actual result

  File "~/project/venv/lib/python3.11/site-packages/pipenv/patched/pip/_vendor/packaging/requirements.py", line 113, in __init__
    raise InvalidRequirement(
pipenv.patched.pip._vendor.packaging.requirements.InvalidRequirement: Parse error at ""'1.0.0'"": Expected string_end

The exception thrown in the code:

        try:
            req = REQUIREMENT.parseString(requirement_string)
        except ParseException as e:
            raise InvalidRequirement(
                f'Parse error at "{ requirement_string[e.loc : e.loc + 8]!r}": {e.msg}'
            )

The requirement_string is internal-dependency=={'version': '1.0.0', 'index': 'internal'}.
It looks like the regexp REQUIREMENT doesn't expect the index at all:

NAMED_REQUIREMENT = NAME + Optional(EXTRAS) + (URL_AND_MARKER | VERSION_AND_MARKER) + Optional(INDEX_NAME)
REQUIREMENT = stringStart + NAMED_REQUIREMENT + stringEnd

But here it comes the most strange part: when I removed all deps from the dev-packages it started working well.

Anyway, let's add the requirement_string to the exception message because it's very complicated to figure out the problem because the temp file is removed and a user has nothing to see at all.


$ pipenv --support

Pipenv version: '2024.0.1'

OS Name: 'posix'

User pip version: '24.0'

user Python installations found:

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.11.10',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '6.8.0-41-generic',
 'platform_system': 'Linux',
 'platform_version': '#41-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug  2 20:41:06 UTC '
                     '2024',
 'python_full_version': '3.11.10',
 'python_version': '3.11',
 'sys_platform': 'linux'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants