-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1545 from kclowes/add-release-test
Add script to test packaging
- Loading branch information
Showing
10 changed files
with
154 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add script to test release install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
from pathlib import ( | ||
Path, | ||
) | ||
import subprocess | ||
from tempfile import ( | ||
TemporaryDirectory, | ||
) | ||
from typing import ( | ||
Tuple, | ||
) | ||
import venv | ||
|
||
|
||
def create_venv(parent_path: Path) -> Path: | ||
venv_path = parent_path / 'package-smoke-test' | ||
venv.create(venv_path, with_pip=True) | ||
subprocess.run([venv_path / 'bin' / 'pip', 'install', '-U', 'pip', 'setuptools'], check=True) | ||
return venv_path | ||
|
||
|
||
def find_wheel(project_path: Path) -> Path: | ||
wheels = list(project_path.glob('dist/*.whl')) | ||
|
||
if len(wheels) != 1: | ||
raise Exception( | ||
f"Expected one wheel. Instead found: {wheels} in project {project_path.absolute()}" | ||
) | ||
|
||
return wheels[0] | ||
|
||
|
||
def install_wheel( | ||
venv_path: Path, wheel_path: Path, extras: Tuple[str, ...] = () | ||
) -> None: | ||
if extras: | ||
extra_suffix = f"[{','.join(extras)}]" | ||
else: | ||
extra_suffix = "" | ||
|
||
subprocess.run( | ||
[ | ||
venv_path / 'bin' / 'pip', | ||
'install', | ||
f"{wheel_path}{extra_suffix}" | ||
], | ||
check=True, | ||
) | ||
|
||
|
||
def test_install_local_wheel() -> None: | ||
with TemporaryDirectory() as tmpdir: | ||
venv_path = create_venv(Path(tmpdir)) | ||
wheel_path = find_wheel(Path('.')) | ||
install_wheel(venv_path, wheel_path) | ||
print("Installed", wheel_path.absolute(), "to", venv_path) | ||
print(f"Activate with `source {venv_path}/bin/activate`") | ||
input("Press enter when the test has completed. The directory will be deleted.") | ||
|
||
|
||
if __name__ == '__main__': | ||
test_install_local_wheel() |