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

>= plus != generates invalid Requires-Dist #5470

Closed
3 tasks done
dargueta opened this issue Apr 20, 2022 · 1 comment · Fixed by python-poetry/poetry-core#343
Closed
3 tasks done

>= plus != generates invalid Requires-Dist #5470

dargueta opened this issue Apr 20, 2022 · 1 comment · Fixed by python-poetry/poetry-core#343
Labels
kind/bug Something isn't working as expected

Comments

@dargueta
Copy link

dargueta commented Apr 20, 2022

  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: Mac OS Big Sur 11.3.1
  • Poetry version: 1.1.13 (core 1.1.8), also tried 1.1.8 (core 1.0.4)
  • Link of a Gist with the contents of your pyproject.toml file: Files

Other versions:

pip: 22.0.4
setuptools: 62.1.0
wheel: 0.37.1

Issue

The following requirement:

google-api-python-client = ">=1.8,!=2.0.*"

generates this in the PKG-INFO source distribution:

Requires-Dist: google-api-python-client (>=1.8,<2.0.0 || >=2.1.0)

As you can see from the specification here, || is not included in the list of supported operators. When trying to install the package resulting from poetry build, pip (correctly) blows up with a syntax error while parsing PKG-INFO:

ERROR: Exception:
Traceback (most recent call last):
  File "/Users/dargueta/.pyenv/versions/3.7.8/envs/gds/lib/python3.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3021, in _dep_map
    return self.__dep_map
  File "/Users/dargueta/.pyenv/versions/3.7.8/envs/gds/lib/python3.7/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 "/Users/dargueta/.pyenv/versions/3.7.8/envs/gds/lib/python3.7/site-packages/pip/_vendor/packaging/requirements.py", line 102, in __init__
    req = REQUIREMENT.parseString(requirement_string)
  File "/Users/dargueta/.pyenv/versions/3.7.8/envs/gds/lib/python3.7/site-packages/pip/_vendor/pyparsing/core.py", line 1134, in parse_string
    raise exc.with_traceback(None)
pip._vendor.pyparsing.exceptions.ParseException: Expected string_end, found '('  (at char 25), (line:1, col:26)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/dargueta/.pyenv/versions/3.7.8/envs/gds/lib/python3.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3101, in __init__
    super(Requirement, self).__init__(requirement_string)
  File "/Users/dargueta/.pyenv/versions/3.7.8/envs/gds/lib/python3.7/site-packages/pip/_vendor/packaging/requirements.py", line 105, in __init__
    f'Parse error at "{ requirement_string[e.loc : e.loc + 8]!r}": {e.msg}'
pip._vendor.packaging.requirements.InvalidRequirement: Parse error at "'(>=1.8,<'": Expected string_end

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/dargueta/.pyenv/versions/3.7.8/envs/gds/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 167, in exc_logging_wrapper
    status = run_func(*args)
  File "/Users/dargueta/.pyenv/versions/3.7.8/envs/gds/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 205, in wrapper
    return func(self, options, args)
  File "/Users/dargueta/.pyenv/versions/3.7.8/envs/gds/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 340, in run
    reqs, check_supported_wheels=not options.target_dir
  File "/Users/dargueta/.pyenv/versions/3.7.8/envs/gds/lib/python3.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 181, in resolve
    discovered_reqs.extend(self._resolve_one(requirement_set, req))
  File "/Users/dargueta/.pyenv/versions/3.7.8/envs/gds/lib/python3.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 422, in _resolve_one
    set(req_to_install.extras) - set(dist.iter_provided_extras())
  File "/Users/dargueta/.pyenv/versions/3.7.8/envs/gds/lib/python3.7/site-packages/pip/_internal/metadata/pkg_resources.py", line 205, in iter_provided_extras
    return self._dist.extras
  File "/Users/dargueta/.pyenv/versions/3.7.8/envs/gds/lib/python3.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2978, in extras
    return [dep for dep in self._dep_map if dep]
  File "/Users/dargueta/.pyenv/versions/3.7.8/envs/gds/lib/python3.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3023, in _dep_map
    self.__dep_map = self._compute_dependencies()
  File "/Users/dargueta/.pyenv/versions/3.7.8/envs/gds/lib/python3.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3033, in _compute_dependencies
    reqs.extend(parse_requirements(req))
  File "/Users/dargueta/.pyenv/versions/3.7.8/envs/gds/lib/python3.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3094, in parse_requirements
    yield Requirement(line)
  File "/Users/dargueta/.pyenv/versions/3.7.8/envs/gds/lib/python3.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3103, in __init__
    raise RequirementParseError(str(e))
pip._vendor.pkg_resources.RequirementParseError: Parse error at "'(>=1.8,<'": Expected string_end

I've also tried it a few other ways, and poetry generated an invalid constraint both times:

  • ^1.8 || ^2.1 became >=1.8,<2.0 || >=2.1,<3.0
  • >=1.8,<3.0.0,!=2.0.* became >=1.8,<3.0,<2.0.0 || >=2.1.0. This is actually wrong because <3.0 should be on the right-hand side.
  • Changing the order to >=1.8,!=2.0.*,<3 became >=1.8,<2.0.0 || >=2.1.0,<3. Note the 3.0 constraint is now on the correct side.

The expected behavior would be:

  • >=1.8,!=2.0.* remains the same
  • >=1.8,<3.0.0,!=2.0.* also is unchanged
  • ^1.8 || ^2.1 becomes something like >=1.8,<3.0.0,!=2.0.*
@dargueta dargueta added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Apr 20, 2022
abn added a commit to abn/poetry-core that referenced this issue May 2, 2022
Prior to this change, when exporting PEP 508 strings for dependencies,
wildcard exclusion constraints like `!=2.0.*` were incorrectly
serialised as invalid PEP 508 due to how version unions were serialsed.

This change allows for determining if a version union is a single
wildcard range exclusion, and if so serialise it appropriately.

Resolves: python-poetry/poetry#5470
abn added a commit to abn/poetry-core that referenced this issue May 5, 2022
Prior to this change, when exporting PEP 508 strings for dependencies,
wildcard exclusion constraints like `!=2.0.*` were incorrectly
serialised as invalid PEP 508 due to how version unions were serialsed.

This change allows for determining if a version union is a single
wildcard range exclusion, and if so serialise it appropriately.

Resolves: python-poetry/poetry#5470
abn added a commit to abn/poetry-core that referenced this issue May 5, 2022
Prior to this change, when exporting PEP 508 strings for dependencies,
wildcard exclusion constraints like `!=2.0.*` were incorrectly
serialised as invalid PEP 508 due to how version unions were serialsed.

This change allows for determining if a version union is a single
wildcard range exclusion, and if so serialise it appropriately.

Resolves: python-poetry/poetry#5470
abn added a commit to abn/poetry-core that referenced this issue May 5, 2022
Prior to this change, when exporting PEP 508 strings for dependencies,
wildcard exclusion constraints like `!=2.0.*` were incorrectly
serialised as invalid PEP 508 due to how version unions were serialsed.

This change allows for determining if a version union is a single
wildcard range exclusion, and if so serialise it appropriately.

Resolves: python-poetry/poetry#5470
abn added a commit to abn/poetry-core that referenced this issue May 6, 2022
Prior to this change, when exporting PEP 508 strings for dependencies,
wildcard exclusion constraints like `!=2.0.*` were incorrectly
serialised as invalid PEP 508 due to how version unions were serialsed.

This change allows for determining if a version union is a single
wildcard range exclusion, and if so serialise it appropriately.

Resolves: python-poetry/poetry#5470
abn added a commit to abn/poetry-core that referenced this issue May 6, 2022
Prior to this change, when exporting PEP 508 strings for dependencies,
wildcard exclusion constraints like `!=2.0.*` were incorrectly
serialised as invalid PEP 508 due to how version unions were serialsed.

This change allows for determining if a version union is a single
wildcard range exclusion, and if so serialise it appropriately.

Resolves: python-poetry/poetry#5470
abn added a commit to abn/poetry-core that referenced this issue May 6, 2022
Prior to this change, when exporting PEP 508 strings for dependencies,
wildcard exclusion constraints like `!=2.0.*` were incorrectly
serialised as invalid PEP 508 due to how version unions were serialsed.

This change allows for determining if a version union is a single
wildcard range exclusion, and if so serialise it appropriately.

Resolves: python-poetry/poetry#5470
radoering pushed a commit to python-poetry/poetry-core that referenced this issue May 6, 2022
Prior to this change, when exporting PEP 508 strings for dependencies,
wildcard exclusion constraints like `!=2.0.*` were incorrectly
serialised as invalid PEP 508 due to how version unions were serialised.

This change allows for determining if a version union is a single
wildcard range exclusion, and if so serialise it appropriately.

Resolves: python-poetry/poetry#5470
@mkniewallner mkniewallner removed the status/triage This issue needs to be triaged label Jun 11, 2022
bostonrwalker pushed a commit to bostonrwalker/poetry-core that referenced this issue Aug 29, 2022
Prior to this change, when exporting PEP 508 strings for dependencies,
wildcard exclusion constraints like `!=2.0.*` were incorrectly
serialised as invalid PEP 508 due to how version unions were serialised.

This change allows for determining if a version union is a single
wildcard range exclusion, and if so serialise it appropriately.

Resolves: python-poetry/poetry#5470
DavidVujic pushed a commit to DavidVujic/poetry-core that referenced this issue Aug 31, 2022
Prior to this change, when exporting PEP 508 strings for dependencies,
wildcard exclusion constraints like `!=2.0.*` were incorrectly
serialised as invalid PEP 508 due to how version unions were serialised.

This change allows for determining if a version union is a single
wildcard range exclusion, and if so serialise it appropriately.

Resolves: python-poetry/poetry#5470
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
kind/bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants