Repository: pypa/pipenv

Issue:
Failed parsing requirement error for local dependency
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.


Discussion:
@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='
```
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.  
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.  https://github.com/sarugaku/requirementslib/pull/342
pipenv, version 2022.8.30 has been released.
https://github.com/pypa/pipenv/releases/tag/v2022.8.31 has broken it again.
@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 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.
@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.

Resolving patch:
diff --git a/pipenv/core.py b/pipenv/core.py
--- a/pipenv/core.py
+++ b/pipenv/core.py
@@ -1592,7 +1592,12 @@ def pip_install_deps(
     )
     for requirement in deps:
         ignore_hash = ignore_hashes
-        vcs_or_editable = requirement.is_vcs or requirement.vcs or requirement.editable
+        vcs_or_editable = (
+            requirement.is_vcs
+            or requirement.vcs
+            or requirement.editable
+            or requirement.is_file_or_url
+        )
         if vcs_or_editable:
             ignore_hash = True
         if requirement and vcs_or_editable:


Test patch: