-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Previously: when running tox, it created wheels directly from the source tree and installed Now: When running tox, always run against a wheel which is created from sdist created from the source tree (using python -m build). This way (1) also the sdist is tested and (2) the same exact wheel files which are uploaded to PyPI will be tested in the unit tests. In addition, start using the .pkg_external tox environment for building the wheel -- with a small adjustment: Always only build the wheel once (makes the tests run faster).
- Loading branch information
Showing
11 changed files
with
144 additions
and
16 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
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 |
---|---|---|
@@ -1,12 +1,19 @@ | ||
# requirements for running unit tests | ||
tox==4.6.0 | ||
pytest==8.1.1; python_version>='3.8' | ||
|
||
# Python 3.7 support dropped in tox 4.9.0 | ||
tox==4.14.2; python_version>='3.8' | ||
tox==4.8.0; python_version<'3.8' | ||
|
||
# Python 3.7 support dropped in pytest 8.0.0 | ||
pytest==8.1.1; python_version>='3.8' | ||
pytest==7.4.4; python_version=='3.7' | ||
|
||
pytest-cov==4.1.0 | ||
coverage-conditional-plugin==0.9.0 | ||
time-machine==2.14.0; python_version>='3.8' | ||
|
||
# Python 3.7 support dropped in time-machine 2.11.0 | ||
time-machine==2.14.0; python_version>='3.8' | ||
time-machine==2.10.0; python_version=='3.7' | ||
|
||
# Jeepney is used in the integration tests for creating a D-Bus server | ||
jeepney==0.8.0;sys_platform=='linux' |
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,38 @@ | ||
"""This module is used solely by tox and is meant for the .pkg_external | ||
environment. See tox.ini for more details. | ||
""" | ||
|
||
import shutil | ||
import subprocess | ||
from pathlib import Path | ||
|
||
dist_dir = Path(__file__).resolve().parent.parent / "dist" | ||
tox_asks_rebuild = dist_dir / ".TOX-ASKS-REBUILD" | ||
|
||
|
||
def build(): | ||
print(f"Checking {tox_asks_rebuild}") | ||
if not tox_asks_rebuild.exists(): | ||
print("Build already done. skipping.") | ||
return | ||
|
||
print(f"Removing {dist_dir} and building sdist and wheel into {dist_dir}") | ||
# Cleanup. Remove all older builds; the /dist folder and its contents. | ||
# Note that tox would crash if there were two files with .whl extension. | ||
# This also resets the TOX-ASKS-REBUILD so we build only once. | ||
shutil.rmtree(dist_dir, ignore_errors=True) | ||
|
||
# This creates first sdist from the source tree and then wheel from the | ||
# sdist. By running tests agains the wheel we test all, the source tree, | ||
# the sdist and the wheel. | ||
out = subprocess.run( | ||
f"python -m build -o {dist_dir}", capture_output=True, shell=True | ||
) | ||
if out.stderr: | ||
raise RuntimeError(out.stderr.decode("utf-8")) | ||
print(out.stdout.decode("utf-8")) | ||
|
||
|
||
if __name__ == "__main__": | ||
|
||
build() |
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,44 @@ | ||
from __future__ import annotations | ||
|
||
import typing | ||
from pathlib import Path | ||
from typing import Any | ||
|
||
from tox.plugin import impl | ||
|
||
if typing.TYPE_CHECKING: | ||
from tox.tox_env.api import ToxEnv | ||
|
||
|
||
dist_dir = Path(__file__).resolve().parent / "dist" | ||
tox_asks_rebuild = dist_dir / ".TOX-ASKS-REBUILD" | ||
|
||
|
||
@impl | ||
def tox_on_install(tox_env: ToxEnv, arguments: Any, section: str, of_type: str): | ||
"""The tox_on_install is once of the available tox hooks[1]. What we are | ||
here after is the tox_on_intall hook call of the ".pkg_external" | ||
environment, which is called max once per tox invocation, before any | ||
commands of other environments are executed. The reason why this is used | ||
is to make it possible to build wheel just once and use it in multiple tox | ||
environments. See tox #2729[2] | ||
[1]: https://tox.wiki/en/4.14.2/plugins.html | ||
[2]: https://github.com/tox-dev/tox/issues/2729 | ||
""" | ||
|
||
# (1) The tox_env of .pkg_external is passed here only if the package needs | ||
# to be built; only if tox is run with at least one environment with | ||
# skip_install not set to True. This requires the "package = external" | ||
# setting in the [testenv] of tox.ini. | ||
# (2) There are two matches for `of_type`: 'requires' and 'deps'. We want | ||
# to only match once. (but it does not matter which one of them) | ||
print(f"Called tox_on_intall hook ({tox_env.name}, {of_type})") | ||
if (tox_env.name != ".pkg_external") or (of_type != "requires"): | ||
return | ||
|
||
print(f"Creating {tox_asks_rebuild}") | ||
# Create a dummy file which tells to the build script that the package | ||
# should be built. | ||
tox_asks_rebuild.parent.mkdir(parents=True, exist_ok=True) | ||
tox_asks_rebuild.touch() |
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