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

Failed parsing requirement error for local dependency #5307

Closed
mstdokumaci opened this issue Aug 29, 2022 · 10 comments · Fixed by #5308 or #5320
Closed

Failed parsing requirement error for local dependency #5307

mstdokumaci opened this issue Aug 29, 2022 · 10 comments · Fixed by #5308 or #5320

Comments

@mstdokumaci
Copy link

mstdokumaci commented Aug 29, 2022

Release https://github.com/pypa/pipenv/releases/tag/v2022.8.24 introduces a bug about resolving local dependencies with a relative path.

Our setup has a local dependency described as {path = "./shared", extras = ["models", "auth0"]} in Pipfile.

pipenv install throws error: pipenv.vendor.requirementslib.exceptions.RequirementError: Failed parsing requirement from './shared#egg='

reverting to the previous release https://github.com/pypa/pipenv/releases/tag/v2022.8.19 fixes the issue for us.

@matteius
Copy link
Member

matteius commented Aug 29, 2022

@mstdokumaci I see what you mean about this example, it may be a new requirementslib issue--however, if you add editable = "true", to your local dependency it appears to work. Here was the stack trace I got without having editable = "true",

$ pipenv lock
Locking [packages] dependencies...
           Building requirements...
Traceback (most recent call last):
  File "C:\Users\matte\AppData\Roaming\Python\Python310\site-packages\pkg_resources\_vendor\packaging\requirements.py", line 102, in __init__
    req = REQUIREMENT.parseString(requirement_string)
  File "C:\Users\matte\AppData\Roaming\Python\Python310\site-packages\pkg_resources\_vendor\pyparsing\core.py", line 1141, in parse_string
    raise exc.with_traceback(None)
pkg_resources._vendor.pyparsing.exceptions.ParseException: Expected W:(0-9A-Za-z), found '.'  (at char 0), (line:1, col:1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\matte\Projects\pipenv\pipenv\vendor\requirementslib\models\requirements.py", line 966, in _parse_name_from_line
    self._requirement = init_requirement(self.line)
  File "C:\Users\matte\Projects\pipenv\pipenv\vendor\requirementslib\models\utils.py", line 194, in init_requirement
    req = Requirement.parse(name)
  File "C:\Users\matte\AppData\Roaming\Python\Python310\site-packages\pkg_resources\__init__.py", line 3147, in parse
    req, = parse_requirements(s)
  File "C:\Users\matte\AppData\Roaming\Python\Python310\site-packages\pkg_resources\__init__.py", line 3102, in __init__
    super(Requirement, self).__init__(requirement_string)
  File "C:\Users\matte\AppData\Roaming\Python\Python310\site-packages\pkg_resources\_vendor\packaging\requirements.py", line 104, in __init__
    raise InvalidRequirement(
pkg_resources.extern.packaging.requirements.InvalidRequirement: Parse error at "'./shared'": Expected W:(0-9A-Za-z)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\matte\AppData\Roaming\Python\Python310\Scripts\pipenv.exe\__main__.py", line 7, in <module>
  File "C:\Users\matte\Projects\pipenv\pipenv\vendor\click\core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\matte\Projects\pipenv\pipenv\cli\options.py", line 56, in main
    return super().main(*args, **kwargs, windows_expand_args=False)
  File "C:\Users\matte\Projects\pipenv\pipenv\vendor\click\core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "C:\Users\matte\Projects\pipenv\pipenv\vendor\click\core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\matte\Projects\pipenv\pipenv\vendor\click\core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\matte\Projects\pipenv\pipenv\vendor\click\core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\matte\Projects\pipenv\pipenv\vendor\click\decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "C:\Users\matte\Projects\pipenv\pipenv\vendor\click\core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\matte\Projects\pipenv\pipenv\vendor\click\decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "C:\Users\matte\Projects\pipenv\pipenv\cli\command.py", line 333, in lock
    do_lock(
  File "C:\Users\matte\Projects\pipenv\pipenv\core.py", line 1122, in do_lock
    venv_resolve_deps(
  File "C:\Users\matte\Projects\pipenv\pipenv\utils\resolver.py", line 1030, in venv_resolve_deps
    deps = convert_deps_to_pip(deps, project, include_index=True)
  File "C:\Users\matte\Projects\pipenv\pipenv\utils\dependencies.py", line 262, in convert_deps_to_pip
    req = new_dep.as_line(
  File "C:\Users\matte\Projects\pipenv\pipenv\vendor\requirementslib\models\requirements.py", line 2796, in as_line
    assert self.line_instance is not None
  File "C:\Users\matte\Projects\pipenv\pipenv\vendor\requirementslib\models\requirements.py", line 2554, in line_instance
    self.line_instance = self.get_line_instance()
  File "C:\Users\matte\Projects\pipenv\pipenv\vendor\requirementslib\models\requirements.py", line 2548, in get_line_instance
    return Line(line)
  File "C:\Users\matte\Projects\pipenv\pipenv\vendor\requirementslib\models\requirements.py", line 173, in __init__
    self.parse()
  File "C:\Users\matte\Projects\pipenv\pipenv\vendor\requirementslib\models\requirements.py", line 1304, in parse
    self.parse_name()
  File "C:\Users\matte\Projects\pipenv\pipenv\vendor\requirementslib\models\requirements.py", line 1027, in parse_name
    name = self._parse_name_from_line()
  File "C:\Users\matte\Projects\pipenv\pipenv\vendor\requirementslib\models\requirements.py", line 968, in _parse_name_from_line
    raise RequirementError(
pipenv.vendor.requirementslib.exceptions.RequirementError: Failed parsing requirement from './shared#egg='

@matteius
Copy link
Member

I may have found where I caused the bug in requirementslib but I need to let the whole test suite run to see if I wasn't trying to fix a different issue.

@matteius
Copy link
Member

There is an issue with one of the test cases if I simply revert my change, but I've added a check if the uri.startswith("file://") that appears to workaround not specifying the editable flag. sarugaku/requirementslib#342

@matteius
Copy link
Member

pipenv, version 2022.8.30 has been released.

@mstdokumaci
Copy link
Author

@matteius
Copy link
Member

matteius commented Sep 1, 2022

@mstdokumaci Can you clarify, was it working in 2022.8.30 and then 2022.8.31 broke? What broke exactly? Only thing I can think related would be we fixed a different issue in requirementslib that is related code path: https://github.com/sarugaku/requirementslib/pull/342/files

@matteius matteius reopened this Sep 1, 2022
@mstdokumaci
Copy link
Author

mstdokumaci commented Sep 1, 2022

@matteius this time the error is:

[pipenv.exceptions.InstallError]: Processing ./shared
[pipenv.exceptions.InstallError]: ERROR: Can't verify hashes for these file:// requirements because they point to directories:

on local dependencies.

2022.8.30 works fine.

@matteius
Copy link
Member

matteius commented Sep 1, 2022

@mstdokumaci Can you share what the Pipfile and Pipfile.lcok looks for for the requirement that is failing to install? Does it have hashes in the lock file or no? I wonder if there is an edge case on this optimization where your editable install is getting included with the standard install dependencies phase. Is it not marked editable = "true"? https://github.com/pypa/pipenv/pull/5301/files#diff-ef852c4ac364f946819f765a6bc26f04f1b0968f31fc512949a60fa2ab0685e8R1583

Would love to sort this out, but I am lacking just the right details to know how to fix it.

@matteius
Copy link
Member

matteius commented Sep 1, 2022

@mstdokumaci I think this change will solve the issue you are seeing -- are you able to check your issue against this branch? #5320

@mstdokumaci
Copy link
Author

I have already fixed the version to 2022.8.30 in all dockerfiles where we install pipenv. By the looks, #5320 seems to fix it. But it will be much easier for me to validate by the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants