Skip to content

Commit 3300025

Browse files
committed
Merge branch 'main' into feature/ty-domain
2 parents a2fce81 + db23ed7 commit 3300025

27 files changed

+327
-25
lines changed

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010

1111
steps:
12-
- uses: actions/checkout@v5
12+
- uses: actions/checkout@v6
1313

1414
- name: Set up uv
1515
uses: astral-sh/setup-uv@v7

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111

1212
steps:
13-
- uses: actions/checkout@v5
13+
- uses: actions/checkout@v6
1414

1515
- name: Set up uv
1616
uses: astral-sh/setup-uv@v7

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
id-token: write
3535

3636
steps:
37-
- uses: actions/checkout@v5
37+
- uses: actions/checkout@v6
3838
with:
3939
fetch-depth: 0
4040
persist-credentials: false

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- windows-latest
2323
runs-on: ${{ matrix.os }}
2424
steps:
25-
- uses: actions/checkout@v5
25+
- uses: actions/checkout@v6
2626
- name: Set up uv
2727
uses: astral-sh/setup-uv@v7
2828
with:

.github/workflows/typecheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111

1212
steps:
13-
- uses: actions/checkout@v5
13+
- uses: actions/checkout@v6
1414

1515
- name: Set up uv
1616
uses: astral-sh/setup-uv@v7

.github/workflows/variants.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- windows-latest
2121
runs-on: ${{ matrix.os }}
2222
steps:
23-
- uses: actions/checkout@v5
23+
- uses: actions/checkout@v6
2424
- name: Set up Python ${{ matrix.python-version }}
2525
uses: actions/setup-python@v6
2626
with:
@@ -86,7 +86,7 @@ jobs:
8686
apt-get update
8787
apt-get install -y make curl ca-certificates git
8888
89-
- uses: actions/checkout@v5
89+
- uses: actions/checkout@v6
9090

9191
- name: Install UV globally
9292
run: |

CHANGES.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
# Changelog
22

3-
## 2.0.2
3+
## 2.2.0
44

55
- Feature: Add `qa.ty` domain for Astral's ty type checker.
66
ty is an extremely fast Python type checker (10-100x faster than mypy).
77
Registers with both CHECK_TARGETS and TYPECHECK_TARGETS for fast feedback.
88
[jensens]
99

10-
## 2.0.1
10+
## 2.1.0
1111

1212
- Enhancement: Use tables in the generated sphinx code for topic/domains.
1313
[jensens, 02-11-2025]
14-
14+
- Feature: Add monorepo support with `PROJECT_PATH_PYTHON` setting.
15+
Python projects can now be located in subdirectories while keeping the Makefile at the repository root. Includes auto-detection of `pyproject.toml` in subdirectories on init, `--project-path-python` CLI flag and preseed file support.
16+
Useful for monorepos with multiple applications (e.g., frontend + backend).
17+
See the "Monorepo Support" section in getting-started.md for details.
1518
- Feature: Add `--version` (`-v`) command line flag to display mxmake version.
1619
[jensens, 02-11-2025]
1720

21+
- Fix: All QA tool domains (ruff, isort, mypy, black, zpretty, pyupgrade, pyrefly) now respect the `PROJECT_PATH_PYTHON` setting when using default source paths.
22+
When `PROJECT_PATH_PYTHON` is set (e.g., to `backend`), the tools automatically look for source code in the correct subdirectory (e.g., `backend/src`) instead of just `src`.
23+
[jensens, 03-11-2025]
24+
1825
## 2.0.0 (2025-10-24)
1926

2027
- **Breaking**: Drop Python 3.9 support. Minimum Python version is now 3.10.

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# License
22

3-
Copyright (c) 2022-2024, mxstack Contributors
3+
Copyright (c) 2022-2025, mxstack Contributors
44

55
All rights reserved.
66

Makefile

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ INCLUDE_MAKEFILE?=include.mk
4242
# No default value.
4343
EXTRA_PATH?=
4444

45+
# Path to Python project relative to Makefile (repository root).
46+
# Leave empty if Python project is in the same directory as Makefile.
47+
# For monorepo setups, set to subdirectory name (e.g., `backend`).
48+
# Future-proofed for multi-language monorepos (e.g., PROJECT_PATH_NODEJS).
49+
# No default value.
50+
PROJECT_PATH_PYTHON?=
51+
4552
## core.mxenv
4653

4754
# Primary Python interpreter to use. It is used to create the
@@ -53,8 +60,8 @@ EXTRA_PATH?=
5360
PRIMARY_PYTHON?=3.14
5461

5562
# Minimum required Python version.
56-
# Default: 3.9
57-
PYTHON_MIN_VERSION?=3.9
63+
# Default: 3.10
64+
PYTHON_MIN_VERSION?=3.10
5865

5966
# Install packages using the given package installer method.
6067
# Supported are `pip` and `uv`. When `uv` is selected, a global installation
@@ -194,6 +201,9 @@ FORMAT_TARGETS?=
194201

195202
export PATH:=$(if $(EXTRA_PATH),$(EXTRA_PATH):,)$(PATH)
196203

204+
# Helper variable: adds trailing slash to PROJECT_PATH_PYTHON only if non-empty
205+
PYTHON_PROJECT_PREFIX=$(if $(PROJECT_PATH_PYTHON),$(PROJECT_PATH_PYTHON)/,)
206+
197207
# Defensive settings for make: https://tech.davis-hansson.com/p/make/
198208
SHELL:=bash
199209
.ONESHELL:
@@ -337,6 +347,11 @@ CLEAN_TARGETS+=mxenv-clean
337347
# ruff
338348
##############################################################################
339349

350+
# Adjust RUFF_SRC to respect PROJECT_PATH_PYTHON if still at default
351+
ifeq ($(RUFF_SRC),src)
352+
RUFF_SRC:=$(PYTHON_PROJECT_PREFIX)src
353+
endif
354+
340355
RUFF_TARGET:=$(SENTINEL_FOLDER)/ruff.sentinel
341356
$(RUFF_TARGET): $(MXENV_TARGET)
342357
@echo "Install Ruff"
@@ -372,6 +387,11 @@ CLEAN_TARGETS+=ruff-clean
372387
# isort
373388
##############################################################################
374389

390+
# Adjust ISORT_SRC to respect PROJECT_PATH_PYTHON if still at default
391+
ifeq ($(ISORT_SRC),src)
392+
ISORT_SRC:=$(PYTHON_PROJECT_PREFIX)src
393+
endif
394+
375395
ISORT_TARGET:=$(SENTINEL_FOLDER)/isort.sentinel
376396
$(ISORT_TARGET): $(MXENV_TARGET)
377397
@echo "Install isort"
@@ -474,7 +494,7 @@ else
474494
@echo "[settings]" > $(PROJECT_CONFIG)
475495
endif
476496

477-
LOCAL_PACKAGE_FILES:=$(wildcard pyproject.toml setup.cfg setup.py requirements.txt constraints.txt)
497+
LOCAL_PACKAGE_FILES:=$(wildcard $(PYTHON_PROJECT_PREFIX)pyproject.toml $(PYTHON_PROJECT_PREFIX)setup.cfg $(PYTHON_PROJECT_PREFIX)setup.py $(PYTHON_PROJECT_PREFIX)requirements.txt $(PYTHON_PROJECT_PREFIX)constraints.txt)
478498

479499
FILES_TARGET:=requirements-mxdev.txt
480500
$(FILES_TARGET): $(PROJECT_CONFIG) $(MXENV_TARGET) $(SOURCES_TARGET) $(LOCAL_PACKAGE_FILES)
@@ -609,6 +629,11 @@ CLEAN_TARGETS+=coverage-clean
609629
# mypy
610630
##############################################################################
611631

632+
# Adjust MYPY_SRC to respect PROJECT_PATH_PYTHON if still at default
633+
ifeq ($(MYPY_SRC),src)
634+
MYPY_SRC:=$(PYTHON_PROJECT_PREFIX)src
635+
endif
636+
612637
MYPY_TARGET:=$(SENTINEL_FOLDER)/mypy.sentinel
613638
$(MYPY_TARGET): $(MXENV_TARGET)
614639
@echo "Install mypy"

docs/source/getting-started.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,101 @@ Both methods create:
9191

9292
To update an existing Makefile without interactive prompts, run `mxmake update`.
9393

94+
## Monorepo Support
95+
96+
mxmake supports monorepo setups where your Python project lives in a subdirectory while the Makefile stays at the repository root.
97+
This is useful when you have multiple applications (e.g., frontend + backend) in one repository.
98+
You may need to edit `mx.ini` and set `requirements-in` or `main-package` to the subfolder.
99+
100+
### Example Directory Structure
101+
102+
```
103+
myrepo/ # Repository root
104+
├── Makefile # Generated by mxmake (at root)
105+
├── mx.ini # mxdev config (at root)
106+
├── .venv/ # Virtual environment (at root)
107+
├── .mxmake/ # Generated files (at root)
108+
├── sources/ # mxdev packages (at root)
109+
├── frontend/ # Frontend application
110+
│ └── package.json
111+
└── backend/ # Python project in subdirectory
112+
├── pyproject.toml
113+
├── src/
114+
│ └── myapp/
115+
└── tests/
116+
```
117+
118+
### Setup Methods
119+
120+
#### Method 1: Auto-detection (Recommended)
121+
122+
If `pyproject.toml` is in a subdirectory, mxmake will detect it automatically:
123+
124+
```shell
125+
cd myrepo
126+
uvx mxmake init
127+
# mxmake will prompt: "Use 'backend' as PROJECT_PATH_PYTHON? (Y/n)"
128+
```
129+
130+
#### Method 2: CLI Flag
131+
132+
Specify the project path explicitly:
133+
134+
```shell
135+
uvx mxmake init --project-path-python backend
136+
```
137+
138+
#### Method 3: Preseed File
139+
140+
Include in your preseed YAML:
141+
142+
```yaml
143+
topics:
144+
core:
145+
base:
146+
PROJECT_PATH_PYTHON: backend
147+
```
148+
149+
Then run:
150+
151+
```shell
152+
uvx mxmake init --preseeds preseed.yaml
153+
```
154+
155+
### What Happens
156+
157+
When `PROJECT_PATH_PYTHON` is set:
158+
159+
1. **Makefile**: References Python package files with the correct path
160+
- Looks for `backend/pyproject.toml` instead of `./pyproject.toml`
161+
162+
2. **mx.ini**: Configure test/coverage paths relative to repository root
163+
- Set `mxmake-test-path = backend/tests` and `mxmake-source-path = backend/src`
164+
165+
3. **GitHub Actions**: Cache uses correct path
166+
- `cache-dependency-glob: "backend/pyproject.toml"`
167+
168+
### Configuration
169+
170+
The `PROJECT_PATH_PYTHON` setting appears in your Makefile:
171+
172+
```makefile
173+
# Path to Python project relative to Makefile (repository root)
174+
PROJECT_PATH_PYTHON?=backend
175+
```
176+
177+
In your `mx.ini`, specify paths relative to the repository root (including the project path):
178+
179+
```ini
180+
[settings]
181+
mxmake-test-path = backend/tests
182+
mxmake-source-path = backend/src
183+
```
184+
185+
```{important}
186+
Future-proofing: This setting is named `PROJECT_PATH_PYTHON` to allow for future `PROJECT_PATH_NODEJS` support in multi-language monorepos.
187+
```
188+
94189
## How to change the settings
95190

96191
The `Makefile` consists of three sections:

0 commit comments

Comments
 (0)