Skip to content

Commit 59239c7

Browse files
committed
modernize test setup with tox
1 parent 01260b3 commit 59239c7

File tree

7 files changed

+76
-86
lines changed

7 files changed

+76
-86
lines changed

.github/workflows/tests.yaml

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,42 +8,44 @@ on:
88
- "opened"
99
workflow_call:
1010
workflow_dispatch:
11+
1112
jobs:
1213
lint:
1314
runs-on: ubuntu-latest
1415
steps:
1516
- uses: actions/checkout@v4
16-
- uses: actions/setup-python@v5
17-
with:
18-
python-version: "3.12"
19-
- uses: pre-commit/action@v3.0.1
20-
build:
17+
- name: Install uv
18+
uses: astral-sh/setup-uv@v5
19+
- name: Run lint with tox
20+
run: uvx --with tox-uv tox -e lint
21+
22+
test:
2123
strategy:
2224
matrix:
23-
python-version:
24-
- "3.8"
25-
- "3.9"
26-
- "3.10"
27-
- "3.11"
28-
- "3.12"
2925
os:
3026
- ubuntu-latest
3127
- windows-latest
3228
- macos-latest
29+
python-config:
30+
- version: "3.8"
31+
tox-env: "py38"
32+
- version: "3.9"
33+
tox-env: "py39"
34+
- version: "3.10"
35+
tox-env: "py310"
36+
- version: "3.11"
37+
tox-env: "py311"
38+
- version: "3.12"
39+
tox-env: "py312"
3340
runs-on: ${{ matrix.os }}
3441

3542
steps:
3643
- uses: actions/checkout@v4
37-
- name: Set up Python ${{ matrix.python-version }}
38-
uses: actions/setup-python@v5
39-
with:
40-
python-version: ${{ matrix.python-version }}
41-
cache: "pip"
42-
- name: "Install Python dependencies (pip)"
43-
uses: "py-actions/py-dependency-install@v4"
44-
with:
45-
path: "requirements.txt"
46-
- name: Run Tests
47-
run: |
48-
git config --global protocol.file.allow always
49-
pytest .
44+
- name: Install uv
45+
uses: astral-sh/setup-uv@v5
46+
- name: Set up Python ${{ matrix.python-config.version }}
47+
run: uv python install ${{ matrix.python-config.version }}
48+
- name: Configure git for tests
49+
run: git config --global protocol.file.allow always
50+
- name: Run tests with tox
51+
run: uvx --with tox-uv tox -e ${{ matrix.python-config.tox-env }}

CHANGES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
## Changes
22

3+
## 4.1.1 (unreleased)
4+
5+
- nothing yet
6+
7+
38
## 4.1.0 (2025-06-03)
49

510
- Support environment variable `GIT_CLONE_DEPTH` for setting a default git depth for all checkouts. Useful for CI.

MANIFEST.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
include *.rst
22
include *.md
3-
exclude requirements.txt
4-
exclude tox.ini
53
exclude .*.yaml
64
recursive-include example *.ini
75
recursive-include example *.txt

Makefile

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,14 @@ EXTRA_PATH?=
4444

4545
# Primary Python interpreter to use. It is used to create the
4646
# virtual environment if `VENV_ENABLED` and `VENV_CREATE` are set to `true`.
47+
# If global `uv` is used, this value is passed as `--python VALUE` to the venv creation.
48+
# uv then downloads the Python interpreter if it is not available.
49+
# for more on this feature read the [uv python documentation](https://docs.astral.sh/uv/concepts/python-versions/)
4750
# Default: python3
48-
PRIMARY_PYTHON?=python3
51+
PRIMARY_PYTHON?=3.14
4952

5053
# Minimum required Python version.
51-
# Default: 3.7
54+
# Default: 3.9
5255
PYTHON_MIN_VERSION?=3.7
5356

5457
# Install packages using the given package installer method.
@@ -63,7 +66,7 @@ PYTHON_PACKAGE_INSTALLER?=uv
6366
# Flag whether to use a global installed 'uv' or install
6467
# it in the virtual environment.
6568
# Default: false
66-
MXENV_UV_GLOBAL?=false
69+
MXENV_UV_GLOBAL?=true
6770

6871
# Flag whether to use virtual environment. If `false`, the
6972
# interpreter according to `PRIMARY_PYTHON` found in `PATH` is used.
@@ -191,34 +194,15 @@ MXMAKE_FOLDER?=.mxmake
191194
# Sentinel files
192195
SENTINEL_FOLDER?=$(MXMAKE_FOLDER)/sentinels
193196
SENTINEL?=$(SENTINEL_FOLDER)/about.txt
194-
$(SENTINEL): Makefile
197+
$(SENTINEL): $(firstword $(MAKEFILE_LIST))
195198
@mkdir -p $(SENTINEL_FOLDER)
196199
@echo "Sentinels for the Makefile process." > $(SENTINEL)
197200

198201
##############################################################################
199202
# mxenv
200203
##############################################################################
201204

202-
# Check if given Python is installed
203-
ifeq (,$(shell which $(PRIMARY_PYTHON)))
204-
$(error "PYTHON=$(PRIMARY_PYTHON) not found in $(PATH)")
205-
endif
206-
207-
# Check if given Python version is ok
208-
PYTHON_VERSION_OK=$(shell $(PRIMARY_PYTHON) -c "import sys; print((int(sys.version_info[0]), int(sys.version_info[1])) >= tuple(map(int, '$(PYTHON_MIN_VERSION)'.split('.'))))")
209-
ifeq ($(PYTHON_VERSION_OK),0)
210-
$(error "Need Python >= $(PYTHON_MIN_VERSION)")
211-
endif
212-
213-
# Check if venv folder is configured if venv is enabled
214-
ifeq ($(shell [[ "$(VENV_ENABLED)" == "true" && "$(VENV_FOLDER)" == "" ]] && echo "true"),"true")
215-
$(error "VENV_FOLDER must be configured if VENV_ENABLED is true")
216-
endif
217-
218-
# Check if global python is used with uv (this is not supported by uv)
219-
ifeq ("$(VENV_ENABLED)$(PYTHON_PACKAGE_INSTALLER)","falseuv")
220-
$(error "Package installer uv does not work with a global Python interpreter.")
221-
endif
205+
OS?=
222206

223207
# Determine the executable path
224208
ifeq ("$(VENV_ENABLED)", "true")
@@ -243,6 +227,16 @@ endif
243227

244228
MXENV_TARGET:=$(SENTINEL_FOLDER)/mxenv.sentinel
245229
$(MXENV_TARGET): $(SENTINEL)
230+
ifneq ("$(PYTHON_PACKAGE_INSTALLER)$(MXENV_UV_GLOBAL)","uvfalse")
231+
@$(PRIMARY_PYTHON) -c "import sys; vi = sys.version_info; sys.exit(1 if (int(vi[0]), int(vi[1])) >= tuple(map(int, '$(PYTHON_MIN_VERSION)'.split('.'))) else 0)" \
232+
&& echo "Need Python >= $(PYTHON_MIN_VERSION)" && exit 1 || :
233+
else
234+
@echo "Use Python $(PYTHON_MIN_VERSION) over uv"
235+
endif
236+
@[[ "$(VENV_ENABLED)" == "true" && "$(VENV_FOLDER)" == "" ]] \
237+
&& echo "VENV_FOLDER must be configured if VENV_ENABLED is true" && exit 1 || :
238+
@[[ "$(VENV_ENABLED)$(PYTHON_PACKAGE_INSTALLER)" == "falseuv" ]] \
239+
&& echo "Package installer uv does not work with a global Python interpreter." && exit 1 || :
246240
ifeq ("$(VENV_ENABLED)", "true")
247241
ifeq ("$(VENV_CREATE)", "true")
248242
ifeq ("$(PYTHON_PACKAGE_INSTALLER)$(MXENV_UV_GLOBAL)","uvtrue")
@@ -556,6 +550,10 @@ INSTALL_TARGETS+=$(ZEST_RELEASER_TARGET)
556550
DIRTY_TARGETS+=zest-releaser-dirty
557551
CLEAN_TARGETS+=zest-releaser-clean
558552

553+
##############################################################################
554+
# Custom includes
555+
##############################################################################
556+
559557
-include $(INCLUDE_MAKEFILE)
560558

561559
##############################################################################

pyproject.toml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "mxdev"
33
description = "Enable to work with Python projects containing lots of packages, of which you only want to develop some."
4-
version = "4.1.0"
4+
version = "4.1.1.dev0"
55
keywords = ["pip", "vcs", "git", "development"]
66
authors = [
77
{name = "MX Stack Developers", email = "dev@bluedynamics.com" }
@@ -96,3 +96,25 @@ ignore = [
9696
"Makefile",
9797
"mx.ini"
9898
]
99+
100+
[tool.tox]
101+
requires = ["tox>=4", "tox-uv>=1"]
102+
env_list = ["lint", "py38", "py39", "py310", "py311", "py312", "py313", "py314"]
103+
104+
[tool.tox.env_run_base]
105+
description = "Run tests with pytest and coverage"
106+
runner = "uv-venv-runner"
107+
uv_resolution = "highest"
108+
pass_env = ["LC_ALL", "LANG", "HOME"]
109+
commands = [
110+
["uv", "pip", "install", "-e", ".[test]"],
111+
["pytest", "--cov", "--cov-report=term", "--cov-branch", "{posargs:src}"]
112+
]
113+
114+
[tool.tox.env.lint]
115+
description = "Run pre-commit hooks for linting"
116+
runner = "uv-venv-runner"
117+
commands = [
118+
["python", "-m", "pre_commit", "run", "{posargs:--all}"]
119+
]
120+
deps = ["pre-commit>=1.20.0"]

requirements.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

tox.ini

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)