Skip to content

Commit

Permalink
fix: correctly parse source distribution names with hyphens (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdwint authored Jan 14, 2024
1 parent bb611d1 commit 93bf92a
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 32 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [PEP 440](https://www.python.org/dev/peps/pep-0440/).


## 2.0.1 - 2024-01-14

### Fixed

- Correctly parse source distribution names with hyphens, since setuptools does not
produce normalised names. See
[pypa/setuptools#3593](https://github.com/pypa/setuptools/issues/3593).


## 2.0.0 - 2024-01-06

### Added
Expand Down
57 changes: 29 additions & 28 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "s3pypi"
version = "2.0.0"
version = "2.0.1"
description = "CLI for creating a Python Package Repository in an S3 bucket"
authors = [
"Matteo De Wint <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion s3pypi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__prog__ = "s3pypi"
__version__ = "2.0.0"
__version__ = "2.0.1"
9 changes: 8 additions & 1 deletion s3pypi/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,14 @@ def parse_distribution_id(filename: str) -> DistributionId:
if not ext:
raise S3PyPiError(f"Unknown file type: {filename}")

name, version = filename[: -len(ext)].split("-", 2)[:2]
stem = filename[: -len(ext)]

if ext == ".whl":
name, version = stem.split("-", 2)[:2]
else:
name, version = stem.rsplit("-", 1)
name = name.replace("-", "_")

return DistributionId(name, version)


Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 2.0.0
current_version = 2.0.1
commit = True
message = chore: bump version to {new_version}

Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def test_normalize_package_name(name, normalized):
@pytest.mark.parametrize(
"filename, dist",
[
("hello-world-0.1.0.tar.gz", core.DistributionId("hello_world", "0.1.0")),
("hello_world-0.1.0.tar.gz", core.DistributionId("hello_world", "0.1.0")),
("foo_bar-1.2.3-py3-none-any.whl", core.DistributionId("foo_bar", "1.2.3")),
],
Expand Down

0 comments on commit 93bf92a

Please sign in to comment.