Repository navigation
'EmptyConstraint' object has no attribute 'allows' #4402
Copy link
Copy link
Closed
python-poetry/poetry-core
#188Labels
kind/bugSomething isn't working as expectedSomething isn't working as expected
Description
Everything was working fine until yesterday, I cleaned up my docker ending up removing all the images, etc. The project was building fine before clean up. Post clean up when I rebuilt the docker image, I started receiving the error:
Writing lock file
#11 68.00
#11 68.00 [AttributeError]
#11 68.00 'EmptyConstraint' object has no attribute 'allows'
#11 68.00
#11 68.05 Traceback (most recent call last):
#11 68.05 File "/usr/local/lib/python3.8/site-packages/clikit/console_application.py", line 131, in run
#11 68.05 status_code = command.handle(parsed_args, io)
#11 68.05 File "/usr/local/lib/python3.8/site-packages/clikit/api/command/command.py", line 120, in handle
#11 68.05 status_code = self._do_handle(args, io)
#11 68.05 File "/usr/local/lib/python3.8/site-packages/clikit/api/command/command.py", line 171, in _do_handle
#11 68.05 return getattr(handler, handler_method)(args, io, self)
#11 68.05 File "/usr/local/lib/python3.8/site-packages/cleo/commands/command.py", line 92, in wrap_handle
#11 68.05 return self.handle()
#11 68.05 File "/usr/local/lib/python3.8/site-packages/poetry/console/commands/update.py", line 49, in handle
#11 68.05 return installer.run()
#11 68.05 File "/usr/local/lib/python3.8/site-packages/poetry/installation/installer.py", line 74, in run
#11 68.05 self._do_install(local_repo)
#11 68.05 File "/usr/local/lib/python3.8/site-packages/poetry/installation/installer.py", line 230, in _do_install
#11 68.05 self._filter_operations(ops, local_repo)
#11 68.05 File "/usr/local/lib/python3.8/site-packages/poetry/installation/installer.py", line 447, in _filter_operations
#11 68.05 ) or not self._env.is_valid_for_marker(package.marker):
#11 68.05 File "/usr/local/lib/python3.8/site-packages/poetry/utils/env.py", line 808, in is_valid_for_marker
#11 68.05 return marker.validate(self.marker_env)
#11 68.05 File "/usr/local/lib/python3.8/site-packages/poetry/version/markers.py", line 601, in validate
#11 68.05 if m.validate(environment):
#11 68.05 File "/usr/local/lib/python3.8/site-packages/poetry/version/markers.py", line 470, in validate
#11 68.05 if not m.validate(environment):
#11 68.05 File "/usr/local/lib/python3.8/site-packages/poetry/version/markers.py", line 361, in validate
#11 68.05 return self._constraint.allows(self._parser(environment[self._name]))
#11 68.05
Here's my .toml file:
[tool.poetry]
name = "myproject"
version = "0.1.0"
description = ""
authors = ["abc <abc@mail.in>"]
[tool.poetry.dependencies]
python = "^3.8"
python-dotenv = "^0.17.0"
numpy = ">=1.19.2"
pandas = "^1.2.4"
Flask = "^1.1.2"
Flask-SQLAlchemy = "^2.5.1"
Flask-Migrate = "^2.7.0"
newrelic = "^6.2.0"
python-jose = "^3.2.0"
Flask-JWT = "^0.3.2"
PyMySQL = "^1.0.2"
psycopg2 = "^2.8.6"
toolz = "^0.11.1"
sortedcontainers = "^2.3.0"
sqlalchemy-redshift = "^0.8.2"
boto3 = "^1.17.57"
joblib = "^1.0.1"
xgboost = "^1.4.2"
scikit-learn = "^0.24.2"
redis = "^3.5.3"
celery = {extras = ["redis"], version = "^5.1.0"}
[tool.poetry.dev-dependencies]
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
And here's my dockerfile:
FROM tiangolo/uwsgi-nginx-flask:python3.8
LABEL MAINTAINER="test@mail.in>"
ARG APP_DIR=/zest-srv
ARG SERVICE_NAME=service
ARG LOG_DIR_PATH=/var/log/uwsgi
WORKDIR $APP_DIR
RUN apt-get update \
&& apt-get install -y ca-certificates
ARG POETRY_VERSION=1.0.0
## Use this instead
# curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
RUN pip install poetry==$POETRY_VERSION
RUN poetry --version
COPY poetry.lock pyproject.toml ${APP_DIR}/
RUN poetry update -vvv
# RUN mkdir ${APP_DIR}/lib
# COPY lib/transportstore-0.1.0-py3-none-any.whl ${APP_DIR}/lib/
RUN poetry config virtualenvs.create false \
&& poetry install --no-interaction --no-ansi
Here the debug logs: https://pastebin.com/sbiiDf8Z
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
kind/bugSomething isn't working as expectedSomething isn't working as expected
Activity
s3rius commentedon Aug 19, 2021
I faced the same issue. My problem was that I was using SQLAlchemy with version "^1.4".
But yesterday SQLAlchemy released "1.4.23" with
platform_machineconstraint.Here's the link: https://github.com/sqlalchemy/sqlalchemy/blob/4331c1902ae341158b597769f4e4991c0a7d5485/setup.cfg#L43.
My solution was to change SQLAlchemy dependency to:
asifali22 commentedon Aug 19, 2021
Thanks this helped a lot.
The above changes solved the issue for me. (Added SQLAlchemy)
sdispater commentedon Aug 19, 2021
Reopening since it should not crash like this when evaluating environment markers.
pierresouchay commentedon Aug 19, 2021
same issue here
alonme commentedon Aug 19, 2021
I think adding the offending package name to the error is crucial
josef-polak-heu commentedon Aug 19, 2021
Hi, i hot fixed this by adding method allows to EmptyConstraint class:
to ./poetry/core/packages/constraints/empty_constraint.py
trallnag commentedon Aug 19, 2021
Pinning the version of sqlalchemy fixed it for me. Thanks @s3rius
ftheo commentedon Aug 19, 2021
Same issue as well. Agree there should be more information on the error/offending package as it required digging into each dependency to identify the package causing the issue
monkey0head commentedon Aug 19, 2021
Thanks @josef-polak-heu! Perfectly solved the problem for me.
lgeo3 commentedon Aug 19, 2021
In the sqlalchemy repo, one developer is saying that it could be due to poetry-core not able to parse correctly constraint like:
see comment here:
sqlalchemy/sqlalchemy#6136 (comment)
if we look at parse_single_constraint (in poetry-core/core/package/constraints/init.py it seems that such kind of constraint is not handled by poetry and thus end as an EmptyConstraint
running an interactive debugging session we can see:
So my question is for such kind of constraint string, the correct constraint type should be AnyConstraint isn't it ?
On an other aspect Iam not sure that EmptyConstraint should provide a allows() that return True (maybee - see: it seems that someone already propose to add #4398 (comment)), but in my understanding, doing that will just hide the real problem here, that the constraint is not parsed correctly).
I am maybee completly wrong, so don't hesitate to tell me.
kupuguy commentedon Aug 19, 2021
I created an issue on sqlalchemy as I don't particularly care who is at fault, just want someone to fix it.
sqlalchemy/sqlalchemy#6903
12 remaining items
Fix an additional case for python-poetry/poetry#4402
setup: Update SQLAlchemy in sqlalchemy example
dwyatte commentedon Aug 24, 2021
Given #4429 and the fact that this error is in poetry-core, can one of the maintainers comment whether upgrading poetry-core>=1.0.4 is the better fix?
limit upper SQLalchemy version due to python-poetry/poetry#4402 (comm…
Pin SQLAlchemy under 1.4.23 until poetry-core 1.0.4 is in Fedora
Pin SQLAlchemy under 1.4.23 until poetry-core 1.0.4 is in Fedora
pyproject.toml: limit SQLAlchemy to < 1.4.23
limit upper SQLalchemy version due to python-poetry/poetry#4402 (comm…
Updated dependencies
Updated dependencies (attempt 2)
Updated dependencies (attempt 3)
github-actions commentedon Mar 2, 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.