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

Make poetry compatible with poetry-core#777 #9762

Closed
wants to merge 1 commit into from
Closed
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: 4 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Changelog = "https://python-poetry.org/history/"
[tool.poetry.dependencies]
python = "^3.8"

poetry-core = { git = "https://github.com/python-poetry/poetry-core.git", branch = "main" }
poetry-core = { git = "https://github.com/Secrus/poetry-core.git", branch = "homepage-url" }
build = "^1.2.1"
cachecontrol = { version = "^0.14.0", extras = ["filecache"] }
cleo = "^2.1.0"
Expand Down
2 changes: 2 additions & 0 deletions tests/masonry/builders/test_editable_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ def test_builder_installs_proper_files_for_standard_packages(
Classifier: Topic :: Software Development :: Build Tools
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Project-URL: Documentation, https://python-poetry.org/docs
Project-URL: Homepage, https://python-poetry.org
Project-URL: Repository, https://github.com/python-poetry/poetry
Description-Content-Type: text/x-rst

Expand Down Expand Up @@ -349,6 +350,7 @@ def test_builder_generates_proper_metadata_when_multiple_readme_files(
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Project-URL: Homepage, https://python-poetry.org
Description-Content-Type: text/x-rst

Single Python
Expand Down
27 changes: 25 additions & 2 deletions tests/repositories/fixtures/pypi.org/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import tarfile
import zipfile

from copy import copy
from functools import cached_property
from gzip import GzipFile
from pathlib import Path
Expand All @@ -51,7 +52,7 @@
from typing import Iterator

from packaging.metadata import parse_email
from poetry.core.masonry.builders.sdist import SdistBuilder
from poetry.core.masonry.utils.helpers import normalize_file_permissions
from poetry.core.packages.package import Package

from poetry.repositories.pypi_repository import PyPiRepository
Expand All @@ -64,6 +65,8 @@


if TYPE_CHECKING:
from tarfile import TarInfo

import requests

from poetry.core.packages.utils.link import Link
Expand Down Expand Up @@ -357,7 +360,7 @@ def process_tarfile(self, link: Link) -> ReleaseFileMetadata:
) as dst_tf, tarfile.open(src, "r") as src_tf:
for member in src_tf.getmembers():
member.mtime = 0
member = SdistBuilder.clean_tarinfo(member)
member = self.clean_tarinfo(member)

if member.isfile() and not is_protected(Path(member.name).name):
logger.debug("Stubbing file %s(%s)", link.filename, member.name)
Expand All @@ -372,6 +375,26 @@ def process_tarfile(self, link: Link) -> ReleaseFileMetadata:

return ReleaseFileMetadata(dst)

def clean_tarinfo(self, tar_info: TarInfo) -> TarInfo:
"""
Clean metadata from a TarInfo object to make it more reproducible.

- Set uid & gid to 0
- Set uname and gname to ""
- Normalise permissions to 644 or 755
- Set mtime if not None
"""

ti = copy(tar_info)
ti.uid = 0
ti.gid = 0
ti.uname = ""
ti.gname = ""
ti.mtime = 0
ti.mode = normalize_file_permissions(ti.mode)

return ti


class Project:
def __init__(self, name: str, releases: list[Release]):
Expand Down
Loading