Closed
Description
Issue
Python constraints issues happens when installing aiopika with weird python specifications - poetry add aiopika
Stack trace:
3 ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/core/semver/helpers.py:137 in parse_single_constraint
135│
136│ try:
→ 137│ version = Version.parse(version)
138│ except ValueError:
139│ raise ValueError(
2 ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/core/version/pep440/version.py:134 in parse
132│ from poetry.core.version.pep440.parser import parse_pep440
133│
→ 134│ return parse_pep440(value, cls)
135│
136│ def is_prerelease(self) -> bool:
1 ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/core/version/pep440/parser.py:88 in parse_pep440
86│ value: str, version_class: Optional[Type["PEP440Version"]] = None
87│ ) -> "PEP440Version":
→ 88│ return PEP440Parser.parse(value, version_class)
89│
InvalidVersion
Invalid PEP 440 version: '3.5.'
at ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/core/version/pep440/parser.py:67 in parse
63│ @classmethod
64│ def parse(cls, value: str, version_class: Optional[Type["PEP440Version"]] = None):
65│ match = cls._regex.search(value) if value else None
66│ if not match:
→ 67│ raise InvalidVersion(f"Invalid PEP 440 version: '{value}'")
68│
69│ if version_class is None:
70│ from poetry.core.version.pep440.version import PEP440Version
71│
The following error occurred when trying to handle this error:
Stack trace:
21 ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/cleo/application.py:314 in run
312│
313│ try:
→ 314│ exit_code = self._run(io)
315│ except Exception as e:
316│ if not self._catch_exceptions:
20 ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/console/application.py:167 in _run
165│ self._load_plugins(io)
166│
→ 167│ return super()._run(io)
168│
169│ def _configure_io(self, io: IO) -> None:
19 ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/cleo/application.py:409 in _run
407│ io.set_input(ArgvInput(argv))
408│
→ 409│ exit_code = self._run_command(command, io)
410│ self._running_command = None
411│
18 ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/cleo/application.py:451 in _run_command
449│
450│ if error is not None:
→ 451│ raise error
452│
453│ return event.exit_code
17 ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/cleo/application.py:435 in _run_command
433│
434│ if event.command_should_run():
→ 435│ exit_code = command.run(io)
436│ else:
437│ exit_code = ConsoleCommandEvent.RETURN_CODE_DISABLED
16 ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/cleo/commands/base_command.py:118 in run
116│ io.input.validate()
117│
→ 118│ status_code = self.execute(io)
119│
120│ if status_code is None:
15 ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/cleo/commands/command.py:85 in execute
83│
84│ try:
→ 85│ return self.handle()
86│ except KeyboardInterrupt:
87│ return 1
14 ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/console/commands/add.py:189 in handle
187│ self._installer.whitelist([r["name"] for r in requirements])
188│
→ 189│ status = self._installer.run()
190│ except BaseException:
191│ # Using BaseException here as some exceptions, eg: KeyboardInterrupt, do not inherit from Exception
13 ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/installation/installer.py:112 in run
110│ local_repo = Repository()
111│
→ 112│ return self._do_install(local_repo)
113│
114│ def dry_run(self, dry_run: bool = True) -> "Installer":
12 ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/installation/installer.py:252 in _do_install
250│ )
251│
→ 252│ ops = solver.solve(use_latest=self._whitelist)
253│ else:
254│ self._io.write_line("Installing dependencies from lock file")
11 ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/puzzle/solver.py:99 in solve
97│ with self._provider.progress():
98│ start = time.time()
→ 99│ packages, depths = self._solve(use_latest=use_latest)
100│ end = time.time()
101│
10 ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/puzzle/solver.py:270 in _solve
268│
269│ try:
→ 270│ result = resolve_version(
271│ self._package, self._provider, locked=locked, use_latest=use_latest
272│ )
9 ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/mixology/__init__.py:24 in resolve_version
22│ solver = VersionSolver(root, provider, locked=locked, use_latest=use_latest)
23│
→ 24│ return solver.solve()
25│
8 ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/mixology/version_solver.py:82 in solve
80│ while next is not None:
81│ self._propagate(next)
→ 82│ next = self._choose_package_version()
83│
84│ return self._result()
7 ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/mixology/version_solver.py:394 in _choose_package_version
392│ version = locked
393│
→ 394│ version = self._provider.complete_package(version)
395│
396│ conflict = False
6 ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/puzzle/provider.py:445 in complete_package
443│ package = DependencyPackage(
444│ package.dependency,
→ 445│ self._pool.package(
446│ package.name,
447│ package.version.text,
5 ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/repositories/pool.py:143 in package
141│ for idx, repo in enumerate(self._repositories):
142│ try:
→ 143│ package = repo.package(name, version, extras=extras)
144│ except PackageNotFound:
145│ continue
4 ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/repositories/pypi_repository.py:165 in package
163│ extras: (Union[list, None]) = None,
164│ ) -> Package:
→ 165│ return self.get_release_info(name, version).to_package(name=name, extras=extras)
166│
167│ def search(self, query: str) -> List[Package]:
3 ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/inspection/info.py:151 in to_package
149│ package.description = self.summary
150│ package.root_dir = root_dir
→ 151│ package.python_versions = self.requires_python or "*"
152│ package.files = self.files
153│
2 ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/core/packages/package.py:233 in python_versions
231│ def python_versions(self, value: str) -> None:
232│ self._python_versions = value
→ 233│ self._python_constraint = parse_constraint(value)
234│ self._python_marker = parse_marker(
235│ create_nested_marker("python_version", self._python_constraint)
1 ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/core/semver/helpers.py:33 in parse_constraint
31│ if len(and_constraints) > 1:
32│ for constraint in and_constraints:
→ 33│ constraint_objects.append(parse_single_constraint(constraint))
34│ else:
35│ constraint_objects.append(parse_single_constraint(and_constraints[0]))
ValueError
Could not parse version constraint: >3.5.*
at ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/core/semver/helpers.py:139 in parse_single_constraint
135│
136│ try:
137│ version = Version.parse(version)
138│ except ValueError:
→ 139│ raise ValueError(
140│ "Could not parse version constraint: {}".format(constraint)
141│ )
142│
143│ if op == "<":
Metadata
Metadata
Assignees
Labels
No labels
Activity
albireox commentedon May 30, 2021
I'm seeing the same issue with
1.2.0a1
. Bothaio_pika
andaiormq
fail because of this error.abn commentedon May 30, 2021
Is
>3.5.*
a valid PEP 345 specification?Seems PEP 345 Requires-Python section indicates that the value must be a valid Version Specifiers. This inturn expects this to be PEP 440. Which this is not afaict.
EIther poetry needs to relax the checks (which might cause unintended side-effects) or the project should use
>3.5,<4
.albireox commentedon May 30, 2021
I'm not very familiar with the version PEPs, but it seems excluding versions is very frequent, for example
so one would expect other inequalities would also be allowed. I can open an issue for the
aio-pika
people, but ifpoetry
starts enforcing this version parsing,1.2.x
will become unusable for many of us.abn commentedon May 31, 2021
I don't think the
!=
operator is in question here, the issue is with>
. Using a wild card does not make sense there and it is not, as per spec iiuc. I'll check the aio-pika package see how the pypi metadata is being generated.finswimmer commentedon Jun 4, 2021
Closing this, because it's not poetry issue.
(Hopefully they will fix it upstream, because I'm using this packages as well)
aviramha commentedon Jun 4, 2021
@finswimmer can we consider maybe adding an ignore flag ? or being less strict with a warning period? This change is ofc good but it causes real issues that restricts many developers from updating to the new poetry version.
ITProKyle commentedon Jun 10, 2021
@finswimmer - seconding the above comment. While being more strict with versioning is great for the entirety of the python community, it is going to make the new release of poetry unusable in many circumstances as some python packages will become unusable.
I ran into this issue with
yamllint
defining their python version requirement as>=3.5.*
.Poetry should try to make an assumption in cases like this but log a waning about potential issues. Ideally, it would also provide a link to get more info about what is incorrect, why its incorrect, and how to fix it so that poetry users can submit PRs to slowly resolve these issue across the board.
Something that I would like to see in the next prerelease of poetry (if it has not been done already) is a better error when this issue is encountered. Right now, if I start using poetry 1.2.0a1 after using 1.1.6, it will result in the
ValueError
and show what version specification is incorrect but it does not show what package it belongs to. I just had to go through andpoetry add <package>
each of my project's dependencies to be able to find which one needed to be fixed.python_requires
does not comply with PEP 345/440 adrienverge/yamllint#387setup: update python_requires to comply with PEP 345/440
12 remaining items