Skip to content

Commit 096f6a8

Browse files
committed
Stable deps and eat-our-own dogfood
Signed-off-by: Bernát Gábor <[email protected]>
1 parent d7f5335 commit 096f6a8

File tree

8 files changed

+69
-51
lines changed

8 files changed

+69
-51
lines changed

.github/workflows/check.yml

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,20 @@ jobs:
2929
- 3.7
3030
- 3.6
3131
steps:
32-
- name: setup python for tox
32+
- name: Setup python for tox
3333
uses: actions/setup-python@v2
3434
with:
35-
python-version: 3.8
36-
- name: install tox
37-
run: python -m pip install tox
35+
python-version: 3.9
3836
- uses: actions/checkout@v2
3937
with:
4038
fetch-depth: 0
41-
- name: setup python for test ${{ matrix.py }}
39+
- name: Install self-tox
40+
run: python -m pip install .
41+
- name: Setup python for test ${{ matrix.py }}
4242
uses: actions/setup-python@v2
4343
with:
4444
python-version: ${{ matrix.py }}
45-
- name: pick environment to run
45+
- name: Pick environment to run
4646
run: |
4747
import json
4848
import os
@@ -51,21 +51,21 @@ jobs:
5151
with open(os.environ['GITHUB_ENV'], 'a') as file_handler:
5252
file_handler.write('TOXENV=' + ("py" if impl == "CPython" else "pypy") + ("{}{}".format(major, minor) if impl == "CPython" else "3") + "\n")
5353
shell: python
54-
- name: setup test suite
55-
run: tox -vv --notest
56-
- name: run test suite
57-
run: tox --skip-pkg-install
54+
- name: Setup test suite
55+
run: tox4 r -vv --notest
56+
- name: Run test suite
57+
run: tox4 r --skip-pkg-install
5858
env:
5959
PYTEST_ADDOPTS: "-vv --durations=20"
6060
CI_RUN: "yes"
6161
DIFF_AGAINST: HEAD
62-
- name: rename coverage report file
62+
- name: Rename coverage report file
6363
run: |
64-
import os; os.rename('.tox/coverage.{}.xml'.format(os.environ['TOXENV']), '.tox/coverage.xml')
64+
import os; os.rename('.tox4/coverage.{}.xml'.format(os.environ['TOXENV']), '.tox4/coverage.xml')
6565
shell: python
6666
- uses: codecov/codecov-action@v1
6767
with:
68-
file: ./.tox/coverage.xml
68+
file: ./.tox4/coverage.xml
6969
flags: tests
7070
name: ${{ matrix.py }} - ${{ matrix.os }}
7171

@@ -89,14 +89,14 @@ jobs:
8989
- uses: actions/checkout@v2
9090
with:
9191
fetch-depth: 0
92-
- name: setup Python 3.8
92+
- name: Setup Python 3.9
9393
uses: actions/setup-python@v2
9494
with:
95-
python-version: 3.8
96-
- name: install tox
97-
run: python -m pip install tox
98-
- name: run check for ${{ matrix.tox_env }}
99-
run: python -m tox -e ${{ matrix.tox_env }}
95+
python-version: 3.9
96+
- name: Install self-tox
97+
run: python -m pip install .
98+
- name: Run check for ${{ matrix.tox_env }}
99+
run: tox4 r -e ${{ matrix.tox_env }}
100100
env:
101101
UPGRADE_ADVISORY: "yes"
102102

@@ -105,18 +105,18 @@ jobs:
105105
needs: [ check, test, pre_commit ]
106106
runs-on: ubuntu-latest
107107
steps:
108-
- name: setup python to build package
108+
- name: Setup python to build package
109109
uses: actions/setup-python@v2
110110
with:
111-
python-version: 3.8
112-
- name: install pep517
113-
run: python -m pip install pep517
111+
python-version: 3.9
112+
- name: Install build
113+
run: python -m pip install build
114114
- uses: actions/checkout@v2
115115
with:
116116
fetch-depth: 0
117-
- name: build package
118-
run: python -m pep517.build -s -b . -o dist
119-
- name: publish to PyPi
117+
- name: Build package
118+
run: pyproject-build -s -w . -o dist
119+
- name: Publish to PyPi
120120
uses: pypa/gh-action-pypi-publish@master
121121
with:
122122
skip_existing: true

src/tox/execute/local_sub_process/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def __exit__(
228228
def get_stream_file_no(key: str) -> Generator[int, "Popen[bytes]", None]:
229229
process = yield PIPE
230230
stream = getattr(process, key)
231-
if sys.platform == "win32": # explicit check for mypy
231+
if sys.platform == "win32": # explicit check for mypy # pragma: win32 cover
232232
yield stream.handle
233233
else:
234234
yield stream.name

src/tox/session/cmd/run/common.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,18 @@ def env_run_create_flags(parser: ArgumentParser) -> None:
104104
help="for python discovery first try the python executables under these paths",
105105
default=[],
106106
)
107+
parser.add_argument(
108+
"--no-recreate-pkg",
109+
dest="no_recreate_pkg",
110+
help="if recreate is set do not recreate packaging tox environment(s)",
111+
action="store_true",
112+
)
113+
parser.add_argument(
114+
"--skip-pkg-install",
115+
dest="skip_pkg_install",
116+
help="skip package installation for this run",
117+
action="store_true",
118+
)
107119

108120

109121
def run_and_report(state: State, result: List[ToxEnvRunResult]) -> int:

src/tox/tox_env/package.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22
A tox environment that can build packages.
33
"""
44
from abc import ABC, abstractmethod
5-
from argparse import ArgumentParser
65
from pathlib import Path
76
from typing import TYPE_CHECKING, List, Set
87

98
from packaging.requirements import Requirement
109

1110
from tox.config.sets import ConfigSet
1211
from tox.journal import EnvJournal
13-
from tox.plugin.impl import impl
1412
from tox.report import ToxHandler
1513
from tox.util.threading import AtomicCounter
1614

@@ -39,13 +37,3 @@ def perform_packaging(self) -> List[Path]:
3937
def clean(self, force: bool = False) -> None:
4038
if force or self.recreate_package: # only recreate if user did not opt out
4139
super().clean(force)
42-
43-
44-
@impl
45-
def tox_add_option(parser: ArgumentParser) -> None:
46-
parser.add_argument(
47-
"--no-recreate-pkg",
48-
dest="no_recreate_pkg",
49-
help="if recreate is set do not recreate packaging tox environment(s)",
50-
action="store_true",
51-
)

src/tox/tox_env/python/runner.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,26 @@ def setup(self) -> None:
4242
"""setup the tox environment"""
4343
super().setup()
4444
self.install_deps()
45-
if self.package_env is not None:
46-
# 1. install pkg dependencies
47-
with self.package_env.display_context(suspend=self.has_display_suspended):
48-
package_deps = self.package_env.get_package_dependencies(self.conf["extras"])
49-
self.cached_install([PythonDep(p) for p in package_deps], PythonRun.__name__, "package_deps")
5045

51-
# 2. install the package
52-
with self.package_env.display_context(suspend=self.has_display_suspended):
53-
self._packages = [PythonDep(p) for p in self.package_env.perform_packaging()]
54-
self.install_python_packages(
55-
self._packages, "package", **self.install_package_args() # type: ignore[no-untyped-call]
56-
)
57-
self.handle_journal_package(self.journal, self._packages)
46+
if self.package_env is None:
47+
return
48+
skip_pkg_install: bool = getattr(self.options, "skip_pkg_install", False)
49+
if skip_pkg_install is True:
50+
logging.warning("skip building and installing the package")
51+
return
52+
53+
# 1. install pkg dependencies
54+
with self.package_env.display_context(suspend=self.has_display_suspended):
55+
package_deps = self.package_env.get_package_dependencies(self.conf["extras"])
56+
self.cached_install([PythonDep(p) for p in package_deps], PythonRun.__name__, "package_deps")
57+
58+
# 2. install the package
59+
with self.package_env.display_context(suspend=self.has_display_suspended):
60+
self._packages = [PythonDep(p) for p in self.package_env.perform_packaging()]
61+
self.install_python_packages(
62+
self._packages, "package", **self.install_package_args() # type: ignore[no-untyped-call]
63+
)
64+
self.handle_journal_package(self.journal, self._packages)
5865

5966
def install_deps(self) -> None:
6067
requirements_file: RequirementsFile = self.conf["deps"]

tests/config/cli/test_cli_env_var.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def test_verbose_no_test(monkeypatch: MonkeyPatch) -> None:
4242
"devenv_path": None,
4343
"env": CliEnv(),
4444
"skip_missing_interpreters": "config",
45+
"skip_pkg_install": False,
4546
"recreate": False,
4647
"no_test": True,
4748
"package_only": False,
@@ -101,6 +102,7 @@ def test_env_var_exhaustive_parallel_values(
101102
"show_config": False,
102103
"sitepackages": False,
103104
"skip_missing_interpreters": "config",
105+
"skip_pkg_install": False,
104106
"verbose": 5,
105107
"work_dir": None,
106108
"root_dir": None,

tests/config/cli/test_cli_ini.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ def default_options(tmp_path: Path) -> Dict[str, Any]:
8888
"recreate": False,
8989
"result_json": None,
9090
"skip_missing_interpreters": "config",
91+
"skip_pkg_install": False,
9192
"verbose": 2,
9293
"no_recreate_pkg": False,
9394
"work_dir": None,
@@ -118,6 +119,7 @@ def test_ini_exhaustive_parallel_values(exhaustive_ini: Path, core_handlers: Dic
118119
"recreate": True,
119120
"result_json": None,
120121
"skip_missing_interpreters": "config",
122+
"skip_pkg_install": False,
121123
"verbose": 5,
122124
"work_dir": None,
123125
"root_dir": None,

tests/session/cmd/test_sequential.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,3 +363,10 @@ def test_pkg_env_dep_remove_recreate(tox_project: ToxProjectCreator, demo_pkg_in
363363
assert ".package-py: recreate env because dependencies removed: setuptools" in result_second.out, result_second.out
364364
run_ids = [i[0][2].run_id for i in execute_calls.call_args_list]
365365
assert run_ids == ["get_requires_for_build_wheel", "build_wheel", "install_package", "_exit"]
366+
367+
368+
def test_skip_pkg_install(tox_project: ToxProjectCreator, demo_pkg_inline: Path) -> None:
369+
proj = tox_project({"tox.ini": "[testenv]\npackage=wheel\n"})
370+
result_first = proj.run("--root", str(demo_pkg_inline), "--skip-pkg-install")
371+
result_first.assert_success()
372+
assert result_first.out.startswith("py: skip building and installing the package"), result_first.out

0 commit comments

Comments
 (0)