Skip to content
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
59 changes: 59 additions & 0 deletions scripts/ci/smoke_test_built_wheel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
from __future__ import annotations

import shutil
import subprocess
import sys
import tempfile
from pathlib import Path


PROJECT_ROOT = Path(__file__).resolve().parents[2]
BUILD_DIR = PROJECT_ROOT / "build"
DIST_DIR = PROJECT_ROOT / "dist"
WHEEL_PATTERN = "faster_hexbytes-*.whl"
PACKAGE_IMPORT = "faster_hexbytes"


def run_python(*args: str, cwd: Path = PROJECT_ROOT) -> None:
subprocess.run((sys.executable, *args), cwd=cwd, check=True)


def clean_build_artifacts() -> None:
for path in (BUILD_DIR, DIST_DIR):
if path.exists():
shutil.rmtree(path)


def find_built_wheel() -> Path:
wheels = sorted(DIST_DIR.glob(WHEEL_PATTERN))
if len(wheels) == 1:
return wheels[0]

found = ", ".join(wheel.name for wheel in wheels) or "none"
raise SystemExit(
f"Expected exactly one {WHEEL_PATTERN} in {DIST_DIR}, found {found}."
)


def main() -> None:
clean_build_artifacts()
run_python("-m", "build")

wheel = find_built_wheel()
print(f"Installing wheel: {wheel.name}")
run_python(
"-m",
"pip",
"install",
"--upgrade",
str(wheel),
"--progress-bar",
"off",
)

with tempfile.TemporaryDirectory() as tmpdir:
run_python("-c", f"import {PACKAGE_IMPORT}", cwd=Path(tmpdir))


if __name__ == "__main__":
main()
25 changes: 1 addition & 24 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ envlist=
py{310,311,312,313,313t,314,314t}-core
py{310,311,312,313,313t,314,314t}-lint
py{310,311,312,313,313t,314,314t}-wheel
windows-wheel
docs

[flake8]
Expand All @@ -22,7 +21,6 @@ commands=
docs: make check-docs-ci
basepython=
docs: python
windows-wheel: python
extras=
test
docs
Expand All @@ -39,28 +37,7 @@ commands=
deps=
wheel
build[virtualenv]
allowlist_externals=
/bin/rm
/bin/bash
commands=
python -m pip install --upgrade pip
/bin/rm -rf build dist
python -m build
/bin/bash -c 'python -m pip install --upgrade "$(ls dist/faster_hexbytes-*-py3-none-any.whl)" --progress-bar off'
python -c "import faster_hexbytes"
skip_install=true

[testenv:windows-wheel]
deps=
wheel
build[virtualenv]
allowlist_externals=
bash.exe
commands=
python --version
python -m pip install --upgrade pip
bash.exe -c "rm -rf build dist"
python -m build
bash.exe -c 'python -m pip install --upgrade "$(ls dist/faster_hexbytes-*-py3-none-any.whl)" --progress-bar off'
python -c "import faster_hexbytes"
python scripts/ci/smoke_test_built_wheel.py
skip_install=true
Loading