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

Could not parse version constraint: ~3.6.* #2645

Closed
3 tasks done
abersheeran opened this issue Jul 8, 2020 · 9 comments · Fixed by python-poetry/poetry-core#56
Closed
3 tasks done

Could not parse version constraint: ~3.6.* #2645

abersheeran opened this issue Jul 8, 2020 · 9 comments · Fixed by python-poetry/poetry-core#56
Labels
kind/bug Something isn't working as expected

Comments

@abersheeran
Copy link

abersheeran commented Jul 8, 2020

  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I am on the latest Poetry version.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: Windows10
  • Poetry version: 1.0.9

Issue

I initialized a project and tried to install index.py using poetry add git+https://github.com/abersheeran/index.py@setup.py.

➜ poetry add git+https://github.com/abersheeran/index.py@setup.py -vvv
Using virtualenv: C:\Users\AberS\Documents\**********************\.venv

[ValueError]
Could not parse version constraint: ~3.6.*

Traceback (most recent call last):
  File "c:\users\abers\.local\pipx\venvs\poetry\lib\site-packages\clikit\console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "c:\users\abers\.local\pipx\venvs\poetry\lib\site-packages\clikit\api\command\command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "c:\users\abers\.local\pipx\venvs\poetry\lib\site-packages\clikit\api\command\command.py", line 171, in _do_handle
    return getattr(handler, handler_method)(args, io, self)
  File "c:\users\abers\.local\pipx\venvs\poetry\lib\site-packages\cleo\commands\command.py", line 92, in wrap_handle
    return self.handle()
  File "c:\users\abers\.local\pipx\venvs\poetry\lib\site-packages\poetry\console\commands\add.py", line 89, in handle
    packages, allow_prereleases=self.option('allow-prereleases')
  File "c:\users\abers\.local\pipx\venvs\poetry\lib\site-packages\poetry\console\commands\init.py", line 293, in _determine_requirements
    requires = self._parse_requirements(requires)
  File "c:\users\abers\.local\pipx\venvs\poetry\lib\site-packages\poetry\console\commands\init.py", line 381, in _parse_requirements
    "git", url.url, reference=pair.get("rev")
  File "c:\users\abers\.local\pipx\venvs\poetry\lib\site-packages\poetry\puzzle\provider.py", line 213, in get_package_from_vcs
    package = cls.get_package_from_directory(tmp_dir, name=name)
  File "c:\users\abers\.local\pipx\venvs\poetry\lib\site-packages\poetry\puzzle\provider.py", line 441, in get_package_from_directory
    dep = dependency_from_pep_508(req)
  File "c:\users\abers\.local\pipx\venvs\poetry\lib\site-packages\poetry\packages\__init__.py", line 158, in dependency_from_pep_508
    dep.python_versions = ' || '.join(ors)
  File "c:\users\abers\.local\pipx\venvs\poetry\lib\site-packages\poetry\packages\dependency.py", line 99, in python_versions
    self._python_constraint = parse_constraint(value)
  File "c:\users\abers\.local\pipx\venvs\poetry\lib\site-packages\poetry\semver\__init__.py", line 31, in parse_constraint
    constraint_objects.append(parse_single_constraint(and_constraints[0]))
  File "c:\users\abers\.local\pipx\venvs\poetry\lib\site-packages\poetry\semver\__init__.py", line 162, in parse_single_constraint
    raise ValueError('Could not parse version constraint: {}'.format(constraint))

On https://github.com/abersheeran/index.py/tree/setup.py, you can see that setup.py is automatically generated using dephell, and I have read that ~3.6.* does not appear, I don’t know the cause of this error.

Hope someone can help me. 😭

@abersheeran abersheeran added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Jul 8, 2020
@atollk
Copy link

atollk commented Jul 22, 2020

Which version constraint to you want to express? It looks like you are trying to mix tilde requirements and wildcard requirements which seems to not be supported.

@abersheeran
Copy link
Author

This is the problem, I did not find any string similar to ~3.6.* in setup.py. @atollk

@atollk
Copy link

atollk commented Jul 23, 2020

Which version constraint to you want to express?

@abersheeran
Copy link
Author

Which version constraint to you want to express?

~3.6

@atollk
Copy link

atollk commented Jul 23, 2020

And what does your pyproject.toml look like?

@abersheeran
Copy link
Author

There is no pyproject.toml, only a setup.py file.

# -*- coding: utf-8 -*-

# DO NOT EDIT THIS FILE!
# This file has been autogenerated by dephell <3
# https://github.com/dephell/dephell

try:
    from setuptools import setup
except ImportError:
    from distutils.core import setup

import os.path

readme = ''
here = os.path.abspath(os.path.dirname(__file__))
readme_path = os.path.join(here, 'README.rst')
if os.path.exists(readme_path):
    with open(readme_path, 'rb') as stream:
        readme = stream.read().decode('utf8')

setup(
    long_description=readme,
    name='index.py',
    version='0.11.1',
    description='An easy-to-use asynchronous web framework based on ASGI.',
    python_requires='==3.*,>=3.6.0',
    project_urls={
        "documentation": "https://index-py.abersheeran.com/",
        "homepage": "https://github.com/abersheeran/index.py",
        "repository": "https://github.com/abersheeran/index.py"
    },
    author='abersheeran',
    author_email='me@abersheeran.com',
    license='Apache-2.0',
    classifiers=[
        'License :: OSI Approved :: Apache Software License',
        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: Implementation :: CPython'
    ],
    entry_points={"console_scripts": ["index-cli = indexpy.cli:main"]},
    packages=[
        'indexpy', 'indexpy.http', 'indexpy.openapi', 'indexpy.websocket'
    ],
    package_dir={"": "."},
    package_data={
        "indexpy": ["*.typed"],
        "indexpy.openapi": ["*.html"]
    },
    install_requires=[
        'a2wsgi==0.*,>=0.3.6', 'aiofiles==0.*,>=0.5.0',
        'contextvars==2.*,>=2.4.0; python_version == "3.6.*" and python_version >= "3.6.0"',
        'jinja2==2.*,>=2.10.3', 'pydantic==1.*,>=1.6.0',
        'python-multipart==0.*,>=0.0.5', 'pyyaml==5.*,>=5.3.0',
        'starlette==0.*,>=0.13.1',
        'typing-extensions==3.*,>=3.7.4; python_version < "3.8"',
        'uvicorn==0.*,>=0.11.3'
    ],
    extras_require={
        "dev": [
            "black", "django==3.*,>=3.0.2", "flake8", "mkdocs",
            "mkdocs-material", "mypy", "pytest-asyncio==0.*,>=0.12.0",
            "pytest-cov==2.*,>=2.8.1"
        ],
        "gunicorn": ["gunicorn==20.*,>=20.0.4"],
        "pytest": ["pytest==5.*,>=5.4.2"],
        "requests": ["requests==2.*,>=2.23.0"],
        "test": ["pytest==5.*,>=5.4.2", "requests==2.*,>=2.23.0"]
    },
)

@atollk
Copy link

atollk commented Jul 23, 2020

I see. I guess it refers to this then: python_requires='==3.*,>=3.6.0'.

The usual way to express this constraint would be >=3.6,<4. Would you still receive the same error with this constraint?

@abersheeran
Copy link
Author

The problem lies in the python version constraints of contextvars. python_version == "3.6.*" and python_version >= "3.6.0" is incorrectly parsed as "~3.6.*"

Copy link

github-actions bot commented Mar 3, 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 3, 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.

3 participants