Skip to content

Commit

Permalink
fix(build): include py.typed in dists
Browse files Browse the repository at this point in the history
  • Loading branch information
nejch authored and JohnVillalovos committed Nov 3, 2023
1 parent 9270e10 commit b928639
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
@@ -1,4 +1,4 @@
include COPYING AUTHORS CHANGELOG.md requirements*.txt
include tox.ini
include tox.ini gitlab/py.typed
recursive-include tests *
recursive-include docs *j2 *.js *.md *.py *.rst api/*.rst Makefile make.bat
10 changes: 9 additions & 1 deletion tests/smoke/test_dists.py
Expand Up @@ -12,6 +12,7 @@
TEST_DIR = "tests"
SDIST_FILE = f"{__title__}-{__version__}.tar.gz"
WHEEL_FILE = f"{__title__.replace('-', '_')}-{__version__}-py{sys.version_info.major}-none-any.whl"
PY_TYPED = "gitlab/py.typed"


@pytest.fixture(scope="session")
Expand All @@ -21,19 +22,26 @@ def build(tmp_path_factory: pytest.TempPathFactory):
return temp_dir


def test_sdist_includes_docs_and_tests(build: Path) -> None:
def test_sdist_includes_correct_files(build: Path) -> None:
sdist = tarfile.open(build / SDIST_FILE, "r:gz")
sdist_dir = f"{__title__}-{__version__}"

docs_dir = sdist.getmember(f"{sdist_dir}/{DOCS_DIR}")
test_dir = sdist.getmember(f"{sdist_dir}/{TEST_DIR}")
readme = sdist.getmember(f"{sdist_dir}/README.rst")
py_typed = sdist.getmember(f"{sdist_dir}/{PY_TYPED}")

assert docs_dir.isdir()
assert test_dir.isdir()
assert py_typed.isfile()
assert readme.isfile()


def test_wheel_includes_correct_files(build: Path) -> None:
wheel = zipfile.ZipFile(build / WHEEL_FILE)
assert PY_TYPED in wheel.namelist()


def test_wheel_excludes_docs_and_tests(build: Path) -> None:
wheel = zipfile.ZipFile(build / WHEEL_FILE)
assert not any(file.startswith((DOCS_DIR, TEST_DIR)) for file in wheel.namelist())

0 comments on commit b928639

Please sign in to comment.