rules_pycross icon indicating copy to clipboard operation
rules_pycross copied to clipboard

How to use poetry with url without version?

Open chulkilee opened this issue 1 year ago • 3 comments

boto3 = {url = "https://github.com/boto/boto3/archive/31a8a3d7bcd021aadceba63d6f207a3a61c58aac.zip"}

poetry lock is successful

# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand.

[[package]]
name = "boto3"
version = "1.35.13"
description = "The AWS SDK for Python"
optional = false
python-versions = ">= 3.8"
files = [
    {file = "31a8a3d7bcd021aadceba63d6f207a3a61c58aac.zip", hash = "sha256:166f093e1d7905b6e116f413f22780151c010f916092772ee1c19e2def949517"},
]

[package.dependencies]
botocore = ">=1.35.13,<1.36.0"
jmespath = ">=0.7.1,<2.0.0"
s3transfer = ">=0.10.0,<0.11.0"

[package.extras]
crt = ["botocore[crt] (>=1.21.0,<2.0a0)"]

[package.source]
type = "url"
url = "https://github.com/boto/boto3/archive/31a8a3d7bcd021aadceba63d6f207a3a61c58aac.zip"

[[package]]
name = "botocore"
version = "1.35.13"
description = "Low-level, data-driven core of boto 3."
optional = false
python-versions = ">=3.8"
files = [
    {file = "botocore-1.35.13-py3-none-any.whl", hash = "sha256:dd8a8bb1946187c8eb902a3b856d3b24df63917e4f2c61a6bce7f3ea9f112761"},
    {file = "botocore-1.35.13.tar.gz", hash = "sha256:f7ae62eab44d731a5ad8917788378316c79c7bceb530a8307ed0f3bca7037341"},
]

[package.dependencies]
jmespath = ">=0.7.1,<2.0.0"
python-dateutil = ">=2.1,<3.0.0"
urllib3 = {version = ">=1.25.4,<2.2.0 || >2.2.0,<3", markers = "python_version >= \"3.10\""}

[package.extras]
crt = ["awscrt (==0.21.2)"]

[[package]]
name = "jmespath"
version = "1.0.1"
description = "JSON Matching Expressions"
optional = false
python-versions = ">=3.7"
files = [
    {file = "jmespath-1.0.1-py3-none-any.whl", hash = "sha256:02e2e4cc71b5bcab88332eebf907519190dd9e6e82107fa7f83b1003a6252980"},
    {file = "jmespath-1.0.1.tar.gz", hash = "sha256:90261b206d6defd58fdd5e85f478bf633a2901798906be2ad389150c5c60edbe"},
]

[[package]]
name = "python-dateutil"
version = "2.9.0.post0"
description = "Extensions to the standard Python datetime module"
optional = false
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7"
files = [
    {file = "python-dateutil-2.9.0.post0.tar.gz", hash = "sha256:37dd54208da7e1cd875388217d5e00ebd4179249f90fb72437e91a35459a0ad3"},
    {file = "python_dateutil-2.9.0.post0-py2.py3-none-any.whl", hash = "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427"},
]

[package.dependencies]
six = ">=1.5"

[[package]]
name = "s3transfer"
version = "0.10.2"
description = "An Amazon S3 Transfer Manager"
optional = false
python-versions = ">=3.8"
files = [
    {file = "s3transfer-0.10.2-py3-none-any.whl", hash = "sha256:eca1c20de70a39daee580aef4986996620f365c4e0fda6a86100231d62f1bf69"},
    {file = "s3transfer-0.10.2.tar.gz", hash = "sha256:0711534e9356d3cc692fdde846b4a1e4b0cb6519971860796e6bc4c7aea00ef6"},
]

[package.dependencies]
botocore = ">=1.33.2,<2.0a.0"

[package.extras]
crt = ["botocore[crt] (>=1.33.2,<2.0a.0)"]

[[package]]
name = "six"
version = "1.16.0"
description = "Python 2 and 3 compatibility utilities"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*"
files = [
    {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"},
    {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"},
]

[[package]]
name = "urllib3"
version = "2.2.2"
description = "HTTP library with thread-safe connection pooling, file post, and more."
optional = false
python-versions = ">=3.8"
files = [
    {file = "urllib3-2.2.2-py3-none-any.whl", hash = "sha256:a448b2f64d686155468037e1ace9f2d2199776e17f0a46610480d311f73e3472"},
    {file = "urllib3-2.2.2.tar.gz", hash = "sha256:dd505485549a7a552833da5e6063639d0d177c04f23bc3864e41e5dc5f612168"},
]

[package.extras]
brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)"]
h2 = ["h2 (>=4,<5)"]
socks = ["pysocks (>=1.5.6,!=1.5.7,<2.0)"]
zstd = ["zstandard (>=0.18.0)"]

[metadata]
lock-version = "2.0"
python-versions = "3.11.9 || 3.12.4"
content-hash = "936bf419505533623b19f273b900d813fd26820d7c1dd5c876d497ea858f71b7"

However lock generation failed

Traceback (most recent call last):
  File "/private/.../bin/external/rules_pycross~/pycross/private/tools/poetry_translator.runfiles/_main/../rules_pycross~/pycross/private/tools/poetry_translator.py", line 281, in <module>
    main(parse_flags())
  File "/private/.../bin/external/rules_pycross~/pycross/private/tools/poetry_translator.runfiles/_main/../rules_pycross~/pycross/private/tools/poetry_translator.py", line 243, in main
    lock_set = translate(args.project_file, args.lock_file)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/private/.../bin/external/rules_pycross~/pycross/private/tools/poetry_translator.runfiles/_main/../rules_pycross~/pycross/private/tools/poetry_translator.py", line 125, in translate
    pinned_package_specs[pin] = parse_constraint(pin_info["version"])
                                                 ~~~~~~~~^^^^^^^^^^^
KeyError: 'version'

chulkilee avatar Sep 06 '24 07:09 chulkilee

I guess this format isn't currently supported. Is there a way to include a version parameter along with the URL to satisfy it?

The translator looks at pyproject.toml to get the set of pinned dependencies - i.e., the roots used in a later step that computes a transitive closure. The actual lock file can contain multiple versions of a single package in some uncommon scenarios, so the translator doesn't look there for the version. But we could make a change to have it defer to the version in the lock file if pyproject.toml doesn't provide one and poetry.lock only has a single version, which I think would handle most scenarios.

jvolkman avatar Sep 06 '24 18:09 jvolkman

Created https://github.com/jvolkman/rules_pycross/pull/118!

chulkilee avatar Sep 06 '24 23:09 chulkilee

I also just ran into this, except that we have some entries that looks like this:

random-project = { git = "https://github.com/owner/repo.git", rev = "random-git-hash"}