Skip to content

Commit 900ab5e

Browse files
committed
chore: Migrate from Poetry to uv and Hatchling
This commit migrates the project's dependency management and build system from Poetry to uv and Hatchling. This change significantly speeds up dependency installation and testing, providing a more efficient development workflow. Key changes include: - `pyproject.toml` is now configured for Hatchling and uv. - GitHub Actions workflows have been updated to use `astral-sh/setup-uv`. - `tox.ini` is reconfigured to use `tox-uv` for test environments. - `README.md` has been updated with new setup and usage instructions. - Obsolete Poetry and pyenv files (`tool-versions.example`, etc.) have been removed.
1 parent 54ee2a3 commit 900ab5e

File tree

12 files changed

+172
-188
lines changed

12 files changed

+172
-188
lines changed

.github/actions/setup/action.yml

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
name: Setup base (python, pip cache, tox)
1+
name: Setup base (python, uv, tox)
2+
description: "Setup Python, uv and tox for further steps"
23
inputs:
34
python:
45
description: "Python version to use"
@@ -11,41 +12,17 @@ outputs:
1112
runs:
1213
using: "composite"
1314
steps:
14-
- name: pip cache
15-
uses: actions/cache@v4
16-
with:
17-
path: |
18-
~/.cache/pip
19-
key: ${{ runner.os }}-pip-${{ inputs.python }}
20-
21-
- name: Cargo cache
22-
uses: actions/cache/@v4
23-
with:
24-
path: "~/.cargo"
25-
key: ${{ runner.os }}-cargo
26-
27-
- name: Poetry cache
28-
uses: actions/cache/@v4
29-
with:
30-
path: "~/.cache/pypoetry"
31-
key: ${{ runner.os }}-poetry-${{ inputs.python }}
32-
restore-keys: |
33-
${{ runner.os }}-poetry-
34-
3515
- uses: actions/setup-python@v6
3616
id: python
3717
with:
3818
python-version: ${{ inputs.python }}
3919

40-
- name: upgrade pip and install tox
20+
- name: Install uv
21+
uses: astral-sh/setup-uv@v5
22+
with:
23+
enable-cache: true
24+
25+
- name: Install tox, tox-uv and tox-gh-actions
4126
shell: bash
4227
run: |
43-
python -m pip -q install --upgrade pip "setuptools==65.6.2"
44-
pip -q install "tox<4" tox-gh-actions
45-
46-
- name: install Rust and Poetry
47-
shell: bash
48-
run : |
49-
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable --profile minimal
50-
source "$HOME/.cargo/env"
51-
pip -q install poetry>=1.2.0
28+
uv tool install tox --with tox-uv --with tox-gh-actions

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
with:
7575
token: ${{ steps.app-token.outputs.token }}
7676
- uses: ./.github/actions/setup-semantic-release # node+semantic-release
77-
- uses: ./.github/actions/setup # poetry
77+
- uses: ./.github/actions/setup
7878
- id: semantic-release # branch policies defined in .releaserc
7979
env:
8080
GIT_AUTHOR_NAME: appland-release

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
.tool-versions
33

44
poetry.lock
5+
uv.lock
56

67
__pycache__/
78
*.py[cod]
@@ -22,3 +23,4 @@ htmlcov/
2223
/ruff.toml
2324

2425
appmap.log
26+
*.sqlite3

.releaserc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ plugins:
4242
- pyproject.toml
4343
- - '@semantic-release/exec'
4444
- prepareCmd: |
45-
/bin/bash ./ci/scripts/build_with_poetry.sh
45+
/bin/bash ./ci/scripts/build_with_uv.sh
4646
# NOTE: @semantic-release/github plugin removed - GitHub release creation
4747
# now happens in the publish job after smoke tests pass

README.md

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,19 @@ oldest version currently supported (see the
5050

5151
## Dependency management
5252

53-
[poetry](https://https://python-poetry.org/) for dependency management:
53+
[uv](https://docs.astral.sh/uv/) is used for dependency management and provides fast package installation:
5454

55-
```
56-
% brew install poetry
57-
% cd appmap-python
58-
% poetry install
55+
```bash
56+
# Install uv (macOS/Linux)
57+
curl -LsSf https://astral.sh/uv/install.sh | sh
58+
59+
# Install dependencies
60+
cd appmap-python
61+
uv sync --all-extras
5962
```
6063

6164
### wrapt
62-
The one dependency that is not managed using `poetry` is `wrapt`. Because it's possible that
65+
The one dependency that is not managed using `uv` is `wrapt`. Because it's possible that
6366
projects that use `appmap` may also need an unmodified version of `wrapt` (e.g. `pylint` depends on
6467
`astroid`, which in turn depends on `wrapt`), we use
6568
[vendoring](https://github.com/pradyunsg/vendoring) to vendor `wrapt`.
@@ -69,64 +72,63 @@ To update `wrapt`, use `tox` (described below) to run the `vendoring` environmen
6972
## Linting
7073
[pylint](https://www.pylint.org/) for linting:
7174

72-
```
73-
% cd appmap-python
74-
% poetry run pylint appmap
75+
```bash
76+
cd appmap-python
77+
uv run tox -e lint
78+
79+
# Or run pylint directly
80+
uv run pylint appmap
7581

7682
--------------------------------------------------------------------
7783
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)
78-
7984
```
8085

81-
[Note that the current configuration has a threshold set which must be met for the Travis build to
82-
pass. To make this easier to achieve, a number of checks have both been disabled. They should be
83-
reenabled as soon as possible.]
84-
8586

8687
## Testing
8788
### pytest
8889

89-
Note that you must install the dependencies contained in
90-
[requirements-dev.txt](requirements-dev.txt) before running tests. See the explanation in
91-
[pyproject.toml](pyproject.toml) for details.
90+
[pytest](https://docs.pytest.org/en/stable/) for testing:
9291

93-
Additionally, the tests currently require that you set `APPMAP=true` and
94-
`APPMAP_DISPLAY_PARAMS=true`.
92+
```bash
93+
cd appmap-python
9594

96-
[pytest](https://docs.pytest.org/en/stable/) for testing:
95+
# Run all tests
96+
APPMAP_DISPLAY_PARAMS=true uv run appmap-python pytest
9797

98-
```
99-
% cd appmap-python
100-
% pip install -r requirements-test.txt
101-
% APPMAP=true APPMAP_DISPLAY_PARAMS=true poetry run pytest
98+
# Run tests with a specific Python version
99+
APPMAP_DISPLAY_PARAMS=true uv run --python 3.9 appmap-python pytest
100+
101+
# Run tests in parallel
102+
APPMAP_DISPLAY_PARAMS=true uv run appmap-python pytest -n auto
102103
```
103104

104105
### tox
105-
Additionally, the `tox` configuration provides the ability to run the tests for all
106-
supported versions of Python and Django.
106+
The `tox` configuration provides the ability to run the tests for all supported versions of Python and web frameworks (Django, Flask, SQLAlchemy).
107107

108-
`tox` requires that all the correct versions of Python to be available to create
109-
the test environments. [pyenv](https://github.com/pyenv/pyenv) is an easy way to manage
110-
multiple versions of Python, and the [xxenv-latest
111-
plugin](https://github.com/momo-lab/xxenv-latest) can help get all the latest versions.
108+
With `uv`, you don't need to pre-install Python versions - `uv` will automatically download and manage them:
112109

110+
```bash
111+
cd appmap-python
113112

113+
# Run full test matrix (all Python versions and frameworks)
114+
uv run tox
114115

115-
```sh
116-
% brew install pyenv
117-
% git clone https://github.com/momo-lab/xxenv-latest.git "$(pyenv root)"/plugins/xxenv-latest
118-
% cd appmap-python
119-
% pyenv latest local 3.{9,6,7,8}
120-
% for v in 3.{9,6,7,8}; do pyenv latest install $v; done
121-
% poetry run tox
116+
# Run tests for a specific Python version
117+
uv run tox -e py312-web
118+
119+
# Run tests for specific framework
120+
uv run tox -e py312-django5
121+
122+
# Update vendored wrapt dependency
123+
uv run tox -e vendoring sync
122124
```
123125

124126
## Code Coverage
125127
[coverage](https://coverage.readthedocs.io/) for coverage:
126128

127-
```
128-
% cd appmap-python
129-
% poetry run coverage run -m pytest
130-
% poetry run coverage html
131-
% open htmlcov/index.html
129+
```bash
130+
cd appmap-python
131+
uv run coverage run -m pytest
132+
uv run coverage html
133+
open htmlcov/index.html
132134
```
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ set -e
44
set -o pipefail
55

66
if [ -z "$DISTRIBUTION_NAME" ] || [ "$DISTRIBUTION_NAME" = "appmap" ] ; then
7-
exec poetry build $*
7+
exec uv build $*
88
fi
99

10-
echo "Altering distribution name to $DISTRIBUTION_NAME"
10+
echo "Altering distribution name to $DISTRIBUTION_NAME"
1111

1212
cp -v pyproject.toml /tmp/pyproject.bak
1313
sed -i -e "s/^name = \".*\"/name = \"${DISTRIBUTION_NAME}\"/" pyproject.toml
1414
grep -n 'name = "' pyproject.toml
1515

16-
poetry build $*
16+
uv build $*
1717

1818
echo "Not patching artifacts with Provides-Dist, they won't work anyway (this flow is solely for publishing test)"
1919
cp -v /tmp/pyproject.bak pyproject.toml

pylintrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ recursive=no
9595

9696
# When enabled, pylint would attempt to guess common misconfiguration and emit
9797
# user-friendly hints instead of false-positive error messages.
98-
suggestion-mode=yes
9998

10099
# Allow loading of arbitrary C extensions. Extensions are imported into the
101100
# active Python interpreter and may run arbitrary code.

0 commit comments

Comments
 (0)