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

Add tests/ directory to the source distribution #7352

Merged
Merged
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: 9 additions & 0 deletions backends/pep517.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,20 @@ def _inject_extra_sdist_files(tar_root):
for filename in glob.glob(pattern, recursive=True):
filename = os.path.relpath(filename, ROOT_DIR)
path_to_add = os.path.join(ROOT_DIR, filename)
if not _should_copy(path_to_add):
continue
target_path = os.path.join(tar_root, filename)
_create_dir_if_not_exists(os.path.dirname(target_path))
shutil.copy2(path_to_add, target_path)


def _should_copy(path):
if "__pycache__" in path or path.endswith(".pyc"):
return False
if os.path.isdir(path):
return False
return True

def read_sdist_extras():
with open(ROOT_DIR / "pyproject.toml", "r") as f:
data = f.read()
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ include = [
"backends/**/*.py",
"bin/*",
"CHANGELOG.rst",
"tests/**/*",
]
# end of cli sdist tool section

Expand Down
8 changes: 8 additions & 0 deletions tests/backends/test_pep517.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ def test_build_sdist(tmpdir, config_settings):
# Make sure the bin directory is included.
assert unpacked_sdist.join("bin", "aws").check()

# Make sure the tests directory is included.
assert unpacked_sdist.join("tests", "__init__.py").check()
assert unpacked_sdist.join("tests", "unit", "__init__.py").check()
assert unpacked_sdist.join(
"tests", "backends", "build_system", "unit", "__init__.py").check()
assert unpacked_sdist.join("tests", "__init__.py").check()

# We do not build the ac.index in building the sdist. So we want to make
# sure it is not being included.
assert not unpacked_sdist.join("awscli", "data", "ac.index").check()
Expand Down Expand Up @@ -245,6 +252,7 @@ def test_read_sdist_extras():
"backends/**/*.py",
"bin/*",
"CHANGELOG.rst",
"tests/**/*",
}
extras = set(backends.pep517.read_sdist_extras())

Expand Down