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

poetry-core generates invalid PEP 508 requirements when extras are used #6900

Closed
4 tasks done
luca-medeiros opened this issue Oct 27, 2022 · 12 comments · Fixed by python-poetry/poetry-core#510
Closed
4 tasks done
Labels
area/build-system Related to PEP 517 packaging (see poetry-core) area/core Related to the poetry-core library kind/bug Something isn't working as expected version/1.2.2

Comments

@luca-medeiros
Copy link

luca-medeiros commented Oct 27, 2022

  • I am on the latest stable Poetry version, installed using a recommended method.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have consulted the FAQ and blog for any relevant entries or release notes.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

Issue

Installing the repository by poetry install works fine, but when running pip install . the following error message shows up:

Output message
Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com
Processing /home/luca/reposNuvi/test_monorepo/lib
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
ERROR: Exception:
Traceback (most recent call last):
  File "/home/luca/anaconda3/envs/split_na2/lib/python3.8/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3021, in _dep_map
    return self.__dep_map
  File "/home/luca/anaconda3/envs/split_na2/lib/python3.8/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2815, in __getattr__
    raise AttributeError(attr)
AttributeError: _DistInfoDistribution__dep_map

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/luca/anaconda3/envs/split_na2/lib/python3.8/site-packages/pip/_vendor/packaging/requirements.py", line 102, in __init__
    req = REQUIREMENT.parseString(requirement_string)
  File "/home/luca/anaconda3/envs/split_na2/lib/python3.8/site-packages/pip/_vendor/pyparsing/core.py", line 1141, in parse_string
    raise exc.with_traceback(None)
pip._vendor.pyparsing.exceptions.ParseException: Expected string_end, found 'extra'  (at char 11), (line:1, col:12)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/luca/anaconda3/envs/split_na2/lib/python3.8/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3101, in __init__
    super(Requirement, self).__init__(requirement_string)
  File "/home/luca/anaconda3/envs/split_na2/lib/python3.8/site-packages/pip/_vendor/packaging/requirements.py", line 104, in __init__
    raise InvalidRequirement(
pip._vendor.packaging.requirements.InvalidRequirement: Parse error at "'extra =='": Expected string_end

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/luca/anaconda3/envs/split_na2/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 167, in exc_logging_wrapper
    status = run_func(*args)
  File "/home/luca/anaconda3/envs/split_na2/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 247, in wrapper
    return func(self, options, args)
  File "/home/luca/anaconda3/envs/split_na2/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 369, in run
    requirement_set = resolver.resolve(
  File "/home/luca/anaconda3/envs/split_na2/lib/python3.8/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 92, in resolve
    result = self._result = resolver.resolve(
  File "/home/luca/anaconda3/envs/split_na2/lib/python3.8/site-packages/pip/_vendor/resolvelib/resolvers.py", line 481, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "/home/luca/anaconda3/envs/split_na2/lib/python3.8/site-packages/pip/_vendor/resolvelib/resolvers.py", line 373, in resolve
    failure_causes = self._attempt_to_pin_criterion(name)
  File "/home/luca/anaconda3/envs/split_na2/lib/python3.8/site-packages/pip/_vendor/resolvelib/resolvers.py", line 213, in _attempt_to_pin_criterion
    criteria = self._get_updated_criteria(candidate)
  File "/home/luca/anaconda3/envs/split_na2/lib/python3.8/site-packages/pip/_vendor/resolvelib/resolvers.py", line 203, in _get_updated_criteria
    for requirement in self._p.get_dependencies(candidate=candidate):
  File "/home/luca/anaconda3/envs/split_na2/lib/python3.8/site-packages/pip/_internal/resolution/resolvelib/provider.py", line 237, in get_dependencies
    return [r for r in candidate.iter_dependencies(with_requires) if r is not None]
  File "/home/luca/anaconda3/envs/split_na2/lib/python3.8/site-packages/pip/_internal/resolution/resolvelib/provider.py", line 237, in <listcomp>
    return [r for r in candidate.iter_dependencies(with_requires) if r is not None]
  File "/home/luca/anaconda3/envs/split_na2/lib/python3.8/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 495, in iter_dependencies
    valid_extras = self.extras.intersection(self.base.dist.iter_provided_extras())
  File "/home/luca/anaconda3/envs/split_na2/lib/python3.8/site-packages/pip/_internal/metadata/pkg_resources.py", line 202, in iter_provided_extras
    return self._dist.extras
  File "/home/luca/anaconda3/envs/split_na2/lib/python3.8/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2978, in extras
    return [dep for dep in self._dep_map if dep]
  File "/home/luca/anaconda3/envs/split_na2/lib/python3.8/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3023, in _dep_map
    self.__dep_map = self._compute_dependencies()
  File "/home/luca/anaconda3/envs/split_na2/lib/python3.8/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3033, in _compute_dependencies
    reqs.extend(parse_requirements(req))
  File "/home/luca/anaconda3/envs/split_na2/lib/python3.8/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3094, in parse_requirements
    yield Requirement(line)
  File "/home/luca/anaconda3/envs/split_na2/lib/python3.8/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3103, in __init__
    raise RequirementParseError(str(e))
pip._vendor.pkg_resources.RequirementParseError: Parse error at "'extra =='": Expected string_end

@luca-medeiros luca-medeiros added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Oct 27, 2022
@dimbleby
Copy link
Contributor

probably just a missing space before the semicolons, here

pull request welcome, though note that fixing this alone is insufficient, you'll still have to get past #5273

@neersighted neersighted changed the title Error installing extra dependency with PIP poetry-core generates invalid PEP 508 requirements when extras are used Oct 27, 2022
@neersighted neersighted added area/build-system Related to PEP 517 packaging (see poetry-core) area/core Related to the poetry-core library version/1.2.2 and removed status/triage This issue needs to be triaged labels Oct 27, 2022
@radoering
Copy link
Member

I don't think a whitespace is required according to PEP 508. Further, pip does not require whitespace in a requirements.txt.

@radoering radoering added the status/triage This issue needs to be triaged label Oct 28, 2022
@dimbleby
Copy link
Contributor

dimbleby commented Oct 28, 2022

I think you are mistaken and without whitespace the semicolon is mistaken for being part of the url

there's code a few lines up that tries to add a space for direct dependencies but (surely accidentally?) omits directory dependencies. Simplest is likely to include the space unconditionally, it should be benign always if only required sometimes

@radoering
Copy link
Member

You're right. I missed that part. Whitespace is required in some cases (e.g. with urls). I agree we should simply add it in any case.

@luca-medeiros
Copy link
Author

Strangely, I'm still getting the same error message about extras on the repo that I've linked.

@neersighted
Copy link
Member

The change is not yet in a released version of Poetry. Merged does not mean it has shown up on your machine yet.

@luca-medeiros
Copy link
Author

I supposed installing from the source on the main branch would do the trick.

@radoering
Copy link
Member

Only if the fix is in poetry itself. This fix is in poetry-core. When installing poetry from source you still get a released version of poetry-core. Replacing poetry-core with the version from its main branch should do the trick.

@neersighted
Copy link
Member

That won't work either as this is poetry-core as the build-system. You'll need to update your build-system requirement to use a Git reference.

@luca-medeiros
Copy link
Author

luca-medeiros commented Nov 7, 2022

Thanks for the build-system trick! Seems to be working now.

@neersighted
Copy link
Member

Just note that by using a non-SHA git reference there is inherent instability; please do not release versions with such a build dependency (see #6741 for an example of why this is bad).

Copy link

github-actions bot commented Mar 1, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/build-system Related to PEP 517 packaging (see poetry-core) area/core Related to the poetry-core library kind/bug Something isn't working as expected version/1.2.2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants