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

install_with_constraints fails with the new poetry 1.1.0 #162

Closed
villekr opened this issue Oct 1, 2020 · 5 comments
Closed

install_with_constraints fails with the new poetry 1.1.0 #162

villekr opened this issue Oct 1, 2020 · 5 comments

Comments

@villekr
Copy link

villekr commented Oct 1, 2020

First of all big thanks for an excellent example for Python project tooling!

Have you also noticed this problem with latest poetry update?
poetry 1.1.0
nox 2020.8.22

❯ nox -rs black
nox > Running session black
nox > Re-using existing virtual environment at .nox/black.
nox > poetry export --dev --format=requirements.txt --output=/var/folders/qj/sjb9y3s56sj1s60cwhmhln3cy765d7/T/tmp57tr87b4

  IndexError

  list index out of range

  at ~/.pyenv/versions/3.8.1/lib/python3.8/site-packages/poetry/utils/exporter.py:76 in _export_requirements_txt
       72│             if not dev
       73│             else self._poetry.package.all_requires,
       74│             with_nested=True,
       75│         ):
    →  76│             package = repository.find_packages(dependency=dependency)[0]
       77│
       78│             # If a package is optional and we haven't opted in to it, continue
       79│             if package.optional and package.name not in extra_package_names:
       80│                 continue
nox > Command poetry export --dev --format=requirements.txt --output=/var/folders/qj/sjb9y3s56sj1s60cwhmhln3cy765d7/T/tmp57tr87b4 failed with exit code 1
nox > Session black failed.

It works fine if downgrading poetry to 1.0.5.
Strangely running below command directly i.e. not in nox session works with poetry 1.1.0.

❯ poetry export --dev --format=requirements.txt --output=/var/folders/qj/sjb9y3s56sj1s60cwhmhln3cy765d7/T/tmp57tr87b4
@cjolowicz
Copy link
Owner

Thank you for reporting this, interesting. Can you provide more detail on how to reproduce this?

I tried to reproduce this with the Dockerfile below, but hit a different error.

ARG PYTHON_VERSION=3.8.6
FROM python:$PYTHON_VERSION
ARG POETRY_VERSION=1.1.0
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
ENV PATH $PATH:/root/.poetry/bin
ARG NOX_VERSION=2020.8.22
RUN pip install nox==$NOX_VERSION
RUN git clone https://github.com/cjolowicz/hypermodern-python
WORKDIR /hypermodern-python
RUN nox --stop-on-first-error
#9 9.886 ERROR: In --require-hashes mode, all requirements must have their versions pinned with ==. These do not:
#9 9.886     bandit from https://files.pythonhosted.org/packages/5a/50/ff2f2c8f1f0ca1569f678eeb608c0f973b835985410985594fbee96be820/bandit-1.6.2-py2.py3-none-any.whl#sha256=336620e220cf2d3115877685e264477ff9d9abaeb0afe3dc7264f55fa17a3952 (from flake8-bandit==2.1.2->-c /tmp/tmpw8avibm7 (line 63))
#9 9.886     flake8-polyfill from https://files.pythonhosted.org/packages/86/b5/a43fed6fd0193585d17d6faa7b85317d4461f694aaed546098c69f856579/flake8_polyfill-1.0.2-py2.py3-none-any.whl#sha256=12be6a34ee3ab795b19ca73505e7b55826d5f6ad7230d31b18e106400169b9e9 (from flake8-bandit==2.1.2->-c /tmp/tmpw8avibm7 (line 63))
#9 9.886     pycodestyle from https://files.pythonhosted.org/packages/10/5b/88879fb861ab79aef45c7e199cae3ef7af487b5603dcb363517a50602dd7/pycodestyle-2.6.0-py2.py3-none-any.whl#sha256=2295e7b2f6b5bd100585ebcb1f616591b652db8a741695b3d8f5d28bdc934367 (from flake8-bandit==2.1.2->-c /tmp/tmpw8avibm7 (line 63))
#9 9.886     pydocstyle>=2.1 from https://files.pythonhosted.org/packages/3b/32/59d44a2ff98e87a35c33b99dc1b4f0bacdd968a8f37080eccd840f2f8e89/pydocstyle-5.1.1-py3-none-any.whl#sha256=aca749e190a01726a4fb472dd4ef23b5c9da7b9205c0a7857c06533de13fd678 (from flake8-docstrings==1.5.0->-c /tmp/tmpw8avibm7 (line 70))
#9 9.886     pyflakes<2.2.0,>=2.1.0 from https://files.pythonhosted.org/packages/84/f2/ed0ffb887f8138a8fe5a621b8c0bb9598bfb3989e029f6c6a85ee66628ee/pyflakes-2.1.1-py2.py3-none-any.whl#sha256=17dbeb2e3f4d772725c777fabc446d5634d1038f234e77343108ce445ea69ce0 (from flake8==3.7.9->-c /tmp/tmpw8avibm7 (line 76))
#9 9.886     mccabe<0.7.0,>=0.6.0 from https://files.pythonhosted.org/packages/87/89/479dc97e18549e21354893e4ee4ef36db1d237534982482c3681ee6e7b57/mccabe-0.6.1-py2.py3-none-any.whl#sha256=ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42 (from flake8==3.7.9->-c /tmp/tmpw8avibm7 (line 76))
#9 9.886     entrypoints<0.4.0,>=0.3.0 from https://files.pythonhosted.org/packages/ac/c6/44694103f8c221443ee6b0041f69e2740d89a25641e62fb4f2ee568f2f9c/entrypoints-0.3-py2.py3-none-any.whl#sha256=589f874b313739ad35be6e0cd7efde2a4e9b6fea91edcc34e58ecbb8dbe56d19 (from flake8==3.7.9->-c /tmp/tmpw8avibm7 (line 76))
#9 9.886     appdirs from https://files.pythonhosted.org/packages/3b/00/2344469e2084fb287c2e0b57b72910309874c3245463acd6cf5e3db69324/appdirs-1.4.4-py2.py3-none-any.whl#sha256=a841dacd6b99318a741b166adb07e19ee71a274450e68237b4650ca1055ab128 (from black==19.10b0->-c /tmp/tmpw8avibm7 (line 4))
#9 9.886     pathspec<1,>=0.6 from https://files.pythonhosted.org/packages/5d/d0/887c58853bd4b6ffc7aa9cdba4fc57d7b979b45888a6bd47e4568e1cf868/pathspec-0.8.0-py2.py3-none-any.whl#sha256=7d91249d21749788d07a2d0f94147accd8f845507400749ea19c1ec9054a12b0 (from black==19.10b0->-c /tmp/tmpw8avibm7 (line 4))
#9 9.886     regex from https://files.pythonhosted.org/packages/2d/f7/7853ca43f65c6dfb7706b11c960718b90527a2419686b5a2686da904fc3e/regex-2020.9.27-cp38-cp38-manylinux2010_x86_64.whl#sha256=8d69cef61fa50c8133382e61fd97439de1ae623fe943578e477e76a9d9471637 (from black==19.10b0->-c /tmp/tmpw8avibm7 (line 4))
#9 9.886     toml>=0.9.4 from https://files.pythonhosted.org/packages/9f/e1/1b40b80f2e1663a6b9f497123c11d7d988c0919abbf3c3f2688e448c5363/toml-0.10.1-py2.py3-none-any.whl#sha256=bda89d5935c2eac546d648028b9901107a595863cb36bae0c73ac804a9b4ce88 (from black==19.10b0->-c /tmp/tmpw8avibm7 (line 4))
#9 9.886     typed-ast>=1.4.0 from https://files.pythonhosted.org/packages/77/49/51308e8c529e14bb2399ff6d22998583aa9ae189ec191e6f7cbb4679f7d5/typed_ast-1.4.1-cp38-cp38-manylinux1_x86_64.whl#sha256=498b0f36cc7054c1fead3d7fc59d2150f4d5c6c56ba7fb150c013fbc683a8d2d (from black==19.10b0->-c /tmp/tmpw8avibm7 (line 4))

In fact, bandit is missing from the exported requirements.txt, even though it's present in poetry.lock.

I would advise you to raise your issue upstream. Bugs were still present in the export command as of 1.1.0rc1, so I guess there may be more rough edges left.

@villekr
Copy link
Author

villekr commented Oct 3, 2020

python-poetry/poetry#3063. Not an issue with this repository code. Just to be aware of this if following atm.

@cjolowicz
Copy link
Owner

The upstream issue was fixed in Poetry 1.1.1 via python-poetry/poetry#3024 and python-poetry/poetry#3038.

@andreas-vester
Copy link

I just hit this error again:

nox > Running session lint
nox > Creating virtual environment (virtualenv) using python3.10 in .nox/lint
nox > poetry export --dev --format=requirements.txt --output=/tmp/tmp4o9k0qa8
nox > python -m pip install --constraint=/tmp/tmp4o9k0qa8 flake8 flake8-bandit flake8-black flake8-bugbear flake8-isort
nox > Command python -m pip install --constraint=/tmp/tmp4o9k0qa8 flake8 flake8-bandit flake8-black flake8-bugbear flake8-isort failed with exit code 1:
Collecting flake8
ERROR: In --require-hashes mode, all requirements must have their versions pinned with ==. These do not:
    flake8 from https://files.pythonhosted.org/packages/cf/a0/b881b63a17a59d9d07f5c0cc91a29182c8e8a9aa2bde5b3b2b16519c02f4/flake8-5.0.4-py2.py3-none-any.whl
nox > Session lint failed.

I am using poetry v1.1.15 and pip v22.2.2.

@darth-veitcher
Copy link

I think this is still a problem. See python-poetry/poetry-plugin-export#126

When you have dependencies such as pylama[lint] or coverage[toml] it will fail with the following error message:

DEPRECATION: Constraints are only allowed to take the form of a package name and a version specifier. Other forms were originally permitted as an accident of the implementation, but were undocumented. The new implementation of the resolver no longer supports these forms. A possible replacement is replacing the constraint with a requirement. Discussion can be found at pypa/pip#8210
ERROR: Constraints cannot have extras

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants