Skip to content

Commit c8094ff

Browse files
committed
Add make package target to test packaged release
1 parent 0a3ac38 commit c8094ff

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ docs: build-docs
5151
linux-docs: build-docs
5252
readlink -f docs/_build/html/index.html
5353

54+
package: clean
55+
python setup.py sdist bdist_wheel
56+
python scripts/release/test_package.py
57+
5458
release: clean
5559
CURRENT_SIGN_SETTING=$(git config commit.gpgSign)
5660
git config commit.gpgSign true

scripts/release/test_package.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
from pathlib import Path
2+
import subprocess
3+
from tempfile import TemporaryDirectory
4+
import venv
5+
6+
7+
def create_venv(parent_path):
8+
venv_path = parent_path / 'package-smoke-test'
9+
venv.create(venv_path, with_pip=True)
10+
subprocess.run([venv_path / 'bin' / 'pip', 'install', '-U', 'pip', 'setuptools'], check=True)
11+
return venv_path
12+
13+
14+
def find_wheel(project_path):
15+
wheels = list(project_path.glob('dist/*.whl'))
16+
17+
if len(wheels) != 1:
18+
raise Exception(
19+
f"Expected one wheel. Instead found: {wheels} in project {project_path.absolute()}"
20+
)
21+
22+
return wheels[0]
23+
24+
25+
def install_wheel(venv_path, wheel_path, extras=tuple()):
26+
if extras:
27+
extra_suffix = f"[{','.join(extras)}]"
28+
else:
29+
extra_suffix = ""
30+
31+
subprocess.run(
32+
[
33+
venv_path / 'bin' / 'pip',
34+
'install',
35+
f"{wheel_path}{extra_suffix}"
36+
],
37+
check=True,
38+
)
39+
40+
41+
def test_install_local_wheel():
42+
temporary_dir = TemporaryDirectory()
43+
venv_path = create_venv(Path(temporary_dir.name))
44+
wheel_path = find_wheel(Path('.'))
45+
install_wheel(venv_path, wheel_path, extras=['p2p', 'trinity'])
46+
print("Installed", wheel_path.absolute(), "to", venv_path)
47+
print(f"Activate with `source {venv_path}/bin/activate`")
48+
input("Press enter when the test has completed. The directory will be deleted.")
49+
temporary_dir.cleanup()
50+
51+
52+
if __name__ == '__main__':
53+
test_install_local_wheel()

0 commit comments

Comments
 (0)