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

Support for Poetry lock format 2.0 #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion rules_poetry/poetry.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,14 @@ def _impl(repository_ctx):

lockfile = json.decode(result.stdout)
metadata = lockfile["metadata"]
if "files" in metadata: # Poetry 1.x format
package_files = [{"name": package["name"], "files": package["files"]} for package in lockfile["package"] if package.get("files")]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would go for explicit version checking:

if metadata["lock-version"] in ["2.0"]:

etc. as far back as they had the lock-version item in metadata


if any(package_files): # Poetry >=1.3 format
hashes = {}

for files in package_files:
hashes[files["name"]] = [x["hash"] for x in files["files"]]
elif "files" in metadata: # Poetry 1.x to 1.3 format
files = metadata["files"]

# only the hashes are needed to build a requirements.txt
Expand Down
Loading