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

poetry: support for poetry metadata format 2.0 #353

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
44 changes: 29 additions & 15 deletions poetry/flatpak-poetry-generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,23 @@ def get_module_sources(parsed_lockfile: dict, include_devel: bool = True) -> lis
for section, packages in parsed_lockfile.items():
if section == "package":
for package in packages:
if (
package["category"] == "dev"
and include_devel
and not package["optional"]
or package["category"] == "main"
and not package["optional"]
if "category" not in package or (
(
package.get("category") == "dev"
and include_devel
and not package.get("optional")
)
or (
package.get("category") == "main"
and not package.get("optional")
)
):
hashes = []
# Check for old metadata format (poetry version < 1.0.0b2)
if "hashes" in parsed_lockfile["metadata"]:
hashes = parsed_lockfile["metadata"]["hashes"][package["name"]]
# Else new metadata format
else:
hashes = []
# metadata format 1.1
elif "files" in parsed_lockfile["metadata"]:
for package_name in parsed_lockfile["metadata"]["files"]:
if package_name == package["name"]:
package_files = parsed_lockfile["metadata"]["files"][
Expand All @@ -86,6 +90,12 @@ def get_module_sources(parsed_lockfile: dict, include_devel: bool = True) -> lis
match = hash_re.search(package_files[num]["hash"])
if match:
hashes.append(match.group(2))
# metadata format 2.0
else:
for file in package["files"]:
match = hash_re.search(file["hash"])
if match:
hashes.append(match.group(2))
url, hash = get_pypi_source(
package["name"], package["version"], hashes
)
Expand All @@ -108,12 +118,16 @@ def get_dep_names(parsed_lockfile: dict, include_devel: bool = True) -> list:
for section, packages in parsed_lockfile.items():
if section == "package":
for package in packages:
if (
package["category"] == "dev"
and include_devel
and not package["optional"]
or package["category"] == "main"
and not package["optional"]
if "category" not in package or (
(
package.get("category") == "dev"
and include_devel
and not package.get("optional")
)
or (
package.get("category") == "main"
and not package.get("optional")
)
):
dep_names.append(package["name"])
return dep_names
Expand Down