Skip to content

Commit

Permalink
default to sdist only
Browse files Browse the repository at this point in the history
  • Loading branch information
radoering committed Oct 13, 2024
1 parent 2449f56 commit 8cec614
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/poetry/core/masonry/builders/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ def _module(self) -> Module:

packages: list[dict[str, Any]] = []
includes: list[dict[str, Any]] = []
for source_list, target_list in [
(self._package.packages, packages),
(self._package.include, includes),
for source_list, target_list, default in [
(self._package.packages, packages, ["sdist", "wheel"]),
(self._package.include, includes, ["sdist"]),
]:
for item in source_list:
# Default to including in both sdist & wheel
# if the `format` key is not provided.
formats = item.get("format", ["sdist", "wheel"])
formats = item.get("format", default)
if not isinstance(formats, list):
formats = [formats]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ license = "MIT"
readme = "README.rst"

exclude = ["**/data/", "**/*/item*"]
include = ["my_package/data/data2.txt"]
include = [{path = "my_package/data/data2.txt", format = ["sdist", "wheel"]}]

homepage = "https://python-poetry.org/"
repository = "https://github.com/python-poetry/poetry"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ packages = [{include='my_package', from='lib'}]
# Simulate excluding due to .gitignore
exclude = ['lib/my_package/generated.py']
# Include again
include = ['lib/my_package/generated.py']
include = [{ path = 'lib/my_package/generated.py', format = ["sdist", "wheel"] }]

[tool.poetry.dependencies]
python = "^3.8"
Expand Down
4 changes: 2 additions & 2 deletions tests/masonry/builders/fixtures/with-include/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ packages = [
]

include = [
"extra_dir/vcs_excluded.py",
"notes.txt"
{ path = "extra_dir/vcs_excluded.py", format = ["sdist", "wheel"] },
"notes.txt", # default is sdist only
]


Expand Down
2 changes: 1 addition & 1 deletion tests/masonry/builders/test_complete.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def test_package_with_include(mocker: MockerFixture) -> None:
assert "extra_dir/sub_pkg/vcs_excluded.py" not in names
assert "for_wheel_only/__init__.py" in names
assert "my_module.py" in names
assert "notes.txt" in names
assert "notes.txt" not in names
assert "package_with_include/__init__.py" in names
assert "tests/__init__.py" not in names
assert "src_package/__init__.py" in names
Expand Down
6 changes: 3 additions & 3 deletions tests/masonry/builders/test_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,12 @@ def test_wheel_include_formats() -> None:
assert "pkg_both/__init__.py" in z.namelist()
assert "pkg_both/sub/__init__.py" in z.namelist()
# other includes
assert "default.txt" in z.namelist()
assert "default.txt" not in z.namelist()
assert "sdist_only.txt" not in z.namelist()
assert "wheel_only.txt" in z.namelist()
assert "both.txt" in z.namelist()
assert "default/file.txt" in z.namelist()
assert "default/sub/file.txt" in z.namelist()
assert "default/file.txt" not in z.namelist()
assert "default/sub/file.txt" not in z.namelist()
assert "sdist_only/file.txt" not in z.namelist()
assert "sdist_only/sub/file.txt" not in z.namelist()
assert "wheel_only/file.txt" in z.namelist()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def test_create_poetry_with_packages_and_includes() -> None:
]

assert package.include == [
{"path": "extra_dir/vcs_excluded.py"},
{"path": "extra_dir/vcs_excluded.py", "format": ["sdist", "wheel"]},
{"path": "notes.txt"},
]

Expand Down

0 comments on commit 8cec614

Please sign in to comment.