Skip to content

Commit

Permalink
Merge pull request #124 from cognitedata/fix-3285
Browse files Browse the repository at this point in the history
Fix #3285
  • Loading branch information
sdispater committed Jan 29, 2021
2 parents b5a1b1f + b2d24fd commit 8570e2e
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 1 deletion.
10 changes: 9 additions & 1 deletion poetry/core/masonry/builders/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,15 @@ def find_excluded_files(self): # type: () -> Set[str]
Path(excluded).relative_to(self._path).as_posix()
)

ignored = vcs_ignored_files | explicitely_excluded
explicitely_included = set()
for inc in self._package.include:
included_glob = inc["path"]
for included in self._path.glob(str(included_glob)):
explicitely_included.add(
Path(included).relative_to(self._path).as_posix()
)

ignored = (vcs_ignored_files | explicitely_excluded) - explicitely_included
result = set()
for file in ignored:
result.add(file)
Expand Down
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[tool.poetry]
name = "my_package"
version = "0.1.0"
description = ""
authors = ["Audun Skaugen <audun.skaugen@cognitedata.com>"]

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']

[tool.poetry.dependencies]
python = "^3.8"

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
14 changes: 14 additions & 0 deletions tests/masonry/builders/test_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,20 @@ def test_wheel_excluded_nested_data():
assert "my_package/public/item2/itemdata2.txt" not in z.namelist()


def test_include_excluded_code():
module_path = fixtures_dir / "include_excluded_code"
poetry = Factory().create_poetry(module_path)
wb = WheelBuilder(poetry)
wb.build()
whl = module_path / "dist" / wb.wheel_filename
assert whl.exists()

with zipfile.ZipFile(str(whl)) as z:
assert "my_package/__init__.py" in z.namelist()
assert "my_package/generated.py" in z.namelist()
assert "lib/my_package/generated.py" not in z.namelist()


def test_wheel_localversionlabel():
module_path = fixtures_dir / "localversionlabel"
project = Factory().create_poetry(module_path)
Expand Down

0 comments on commit 8570e2e

Please sign in to comment.