-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
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'}