question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot install Apache Airflow due to ambiguous constraint

See original GitHub issue
  • Poetry version: Poetry (version 1.2.2)
  • Python version: Python: 3.10.8
  • OS version and name: MacOS 13.0.1
  • pyproject.toml:
[tool.poetry.dependencies]
python = "^3.10"
apache-airflow-providers-google = { version = "==8.5.0rc1", allow-prereleases = true }
  • I am on the latest stable Poetry version, installed using a recommended method.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have consulted the FAQ and blog for any relevant entries or release notes.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

Issue

I am unable to run poetry lock with the above dependency.

Expected

Poetry locks correctly using apache-airflow-providers-common-sql==1.3.0rc1

Actual

Poetry returns the following error

poetry lock

Updating dependencies
Resolving dependencies... (1.5s)

Because apache-airflow-providers-google (8.5.0rc1) depends on apache-airflow-providers-common-sql (>=1.3.0) which doesn't match any versions, apache-airflow-providers-google is forbidden.
So, because poetry depends on apache-airflow-providers-google (==8.5.0rc1), version solving failed.

It looks like poetry has the following bug

Poetry is not supported to install airflow, and it has apparently a bug that it cannot properly handle the vaild >= .* requirement.

Note: the reproducibility of this example will stop once airflow publishes the final release of apache-airflow-providers-common-sql==1.3.0

Verifying that pypi has the expected requirement

API response

import json

import requests

package_name = 'apache-airflow-providers-google/8.5.0rc1'
url = 'https://pypi.python.org/pypi/' + str(package_name) + '/json'
data = requests.get(url).json()

print(data['info']['requires_dist'])

for apache-airflow-provider-common-sql returns the following

apache-airflow-providers-common-sql (>=1.3.0.*)

Further Notes

pipenv & pip run without issue

Pipenv

Pipfile

[packages]
apache-airflow-providers-google = { version = "==8.5.0rc1", pre="true" }

CLI

mkdir test-pipenv && cd test-pipenv
pip install pipenv
pipenv lock
nano pipfile

pipenv lock                                                                                                                                                                                                                   
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
✔ Success! 
Locking [dev-packages] dependencies...
Updated Pipfile.lock (43302be42e771518e472473549c7ab11902fd6f2e7eed04c64ffcd2d5f9be4e8)!

Locked Packages

...
        "apache-airflow-providers-common-sql": {
            "hashes": [
                "sha256:9308d3ac4d1f888f1a1f91c18cfa493291e333635cf0a0f93565581a83b1f097",
                "sha256:f5eb101f15a3535f879509873992d7194ef3e2a48316c984a0fc2a3a3af9001e"
            ],
            "markers": "python_version ~= '3.7'",
            "version": "==1.3.0rc1"
        },
        "apache-airflow-providers-google": {
            "hashes": [
                "sha256:a6d94a647c4dca9b2b75b4bf98c20c3809eb4ff8ccf4e7219f19df8fec3ea0de",
                "sha256:db9105714472b9cf344b55a72172dd87d85b7de5c8c5755bd86007c23d3ec3cf"
            ],
            "index": "pypi",
            "version": "==8.5.0rc1"
        },
...

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:37 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
potiukcommented, Nov 16, 2022

Fix for airflow provider packages in https://github.com/apache/airflow/pull/27727

2reactions
dimblebycommented, Nov 16, 2022

Just noting that indeed poetry does make a mess of prefix matching on == constraints: this code

#!/usr/bin/env python3

from poetry.core.constraints.version.version import Version
from poetry.core.constraints.version import parse_constraint

constraint = parse_constraint("==1.1.*")
version = Version.parse("1.1a1")
allowed = constraint.allows(version)
print(f"{allowed=}")

says allowed=False which certainly disagrees with one of the examples in PEP440.

So while - at least according to my reading - the problem in this particular issue is the airflow constraint rather than the poetry handling of it, we’re certainly very adjacent to a poetry bug

Read more comments on GitHub >

github_iconTop Results From Across the Web

Support for pip --constraint #3225 - python-poetry ... - GitHub
Although, doing pip install apache-airflow==1.10.12 -c constraints.txt , will not install ipython if it is not defined in the core metadata.
Read more >
Cannot install apache-airflow==2.0.0 because these package ...
I can't understand what's the issue becuase the pandas version in the --constraint file is pandas==1.2.2 . So it fullfill the needed dependency ......
Read more >
Installation — Airflow Documentation - Apache Airflow
This page describes installations using the apache-airflow package published in PyPI, but some information may be useful during installation with other ...
Read more >
Installation from PyPI - Apache Airflow
You should run provider's installation as a separate command after Airflow has been installed (usually with constraints). Constraints are only effective during ...
Read more >
Release Notes — Airflow Documentation
By default Airflow could not be embedded in an iframe. In Airflow 2.2.5 there was a bug introduced that made it impossible to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found