Skip to content

Commit 9e96f76

Browse files
committed
#32 - switch from PDM to UV
Signed-off-by: Lance-Drane <Lance-Drane@users.noreply.github.com>
1 parent fcde281 commit 9e96f76

14 files changed

Lines changed: 2063 additions & 1634 deletions

File tree

.dockerignore

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
.venv
2-
dist
3-
build
4-
.pdm-python
5-
.pdm-build
6-
.mypy_cache
7-
.pytest_cache
8-
.ruff_cache
9-
report_unit.xml
10-
coverage.xml
11-
htmlcov/
12-
reports/
1+
# ignore everything by default
2+
*
3+
# but do not ignore core files
4+
!src/
5+
!docs/
6+
!examples/
7+
!tests/
8+
!pyproject.toml
9+
!uv.lock
10+
# README is used in pyproject.toml
11+
!README.md
12+
# but make sure to ignore cache
13+
__pycache__/
14+
*.pyc
15+
# and also ignore the doc website build
16+
docs/_build/

.github/workflows/ci.yml

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,19 @@ jobs:
2020
name: Ruff linting, formating, MyPy
2121
runs-on: ubuntu-latest
2222
steps:
23-
- uses: actions/checkout@v4
24-
- name: Setup PDM
25-
uses: pdm-project/setup-pdm@v4
23+
- uses: actions/checkout@v6
24+
- name: Setup UV
25+
uses: astral-sh/setup-uv@v7
2626
with:
2727
python-version: "3.12"
28-
cache: true
2928
- name: Install dependencies
3029
run: |
31-
pdm venv create --with-pip --force $PYTHON
32-
pdm sync --dev -G:all
33-
- run: |
34-
pdm run ruff format --check
35-
pdm run ruff check
36-
pdm run lint-mypy
30+
uv sync --locked --all-extras --all-groups
31+
- name: Run linters and type checks
32+
run: |
33+
uv run ruff format --check
34+
uv run ruff check
35+
uv run mypy src/intersect_sdk/
3736
3837
# Run unit tests only on Windows/MacOS, we can run the full test suite on Linux
3938
test-unit:
@@ -47,16 +46,15 @@ jobs:
4746
runs-on: ${{ matrix.os }}
4847
steps:
4948
- uses: actions/checkout@v4
50-
- name: Setup PDM
51-
uses: pdm-project/setup-pdm@v4
49+
- name: Setup UV
50+
uses: astral-sh/setup-uv@v7
5251
with:
5352
python-version: ${{ matrix.python-version }}
54-
cache: true
5553
- name: Install dependencies
5654
run: |
57-
pdm venv create --with-pip --force $PYTHON
58-
pdm sync --dev -G:all
59-
- run: pdm run test-unit
55+
uv sync --locked --all-extras --all-groups
56+
- name: Run tests
57+
run: uv run pytest tests/unit/ --cov=src/intersect_sdk/ --cov-report=html:reports/htmlcov/ --cov-report=xml:reports/coverage_report.xml --junitxml=reports/junit.xml
6058

6159
# we can only run our full test suite on Ubuntu due to the Github Actions services requirement
6260
test-complete:
@@ -91,13 +89,12 @@ jobs:
9189
- "9001:9001" # web UI
9290
steps:
9391
- uses: actions/checkout@v4
94-
- name: Setup PDM
95-
uses: pdm-project/setup-pdm@v4
92+
- name: Setup UV
93+
uses: astral-sh/setup-uv@v7
9694
with:
9795
python-version: ${{ matrix.python-version }}
98-
cache: true
9996
- name: Install dependencies
10097
run: |
101-
pdm venv create --with-pip --force $PYTHON
102-
pdm sync --dev -G:all
103-
- run: pdm run test-all
98+
uv sync --locked --all-extras --all-groups
99+
- name: Run tests
100+
run: uv run pytest tests/ --cov=src/intersect_sdk/ --cov-report=html:reports/htmlcov/ --cov-report=xml:reports/coverage_report.xml --junitxml=reports/junit.xml

.github/workflows/publish.yml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,30 @@ name: Release to PyPi
22

33
on:
44
push:
5-
tags: "v[0-9]+.[0-9]+.[0-9]+*"
5+
tags:
6+
- "v[0-9]+.[0-9]+.[0-9]+*"
67
workflow_dispatch:
78

8-
permissions:
9-
contents: write
10-
id-token: write
11-
129
jobs:
1310
build:
1411
if: startsWith(github.ref, 'refs/tags/')
1512
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
id-token: write
16+
environment:
17+
name: pypi
18+
url: https://pypi.org/p/intersect-sdk
1619
steps:
1720
- uses: actions/checkout@v4
18-
- name: Setup PDM
19-
uses: pdm-project/setup-pdm@v4
21+
- name: Setup UV
22+
uses: astral-sh/setup-uv@v7
2023
with:
21-
python-version: "3.8"
22-
cache: true
24+
python-version: "3.12"
25+
- name: "Build package"
26+
run: uv build --no-create-gitignore
2327
- name: Publish package to PyPI
24-
env:
25-
PDM_PUBLISH_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
26-
run: pdm publish --username __token__ --repository pypi
28+
run: uv publish
2729
- name: upload to github release
2830
uses: docker://antonyurchenko/git-release:v5
2931
env:

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ ipython_config.py
370370
# pyenv
371371
# For a library or package, you might want to ignore these files since the code is
372372
# intended to run in multiple environments; otherwise, check them in:
373-
# .python-version
373+
.python-version
374374

375375
# pipenv
376376
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.

.pre-commit-config.yaml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,17 @@ repos:
1313
- id: ruff
1414
args: [ --fix ]
1515
- id: ruff-format
16-
- repo: https://github.com/pdm-project/pdm
17-
rev: 2.17.2
16+
- repo: https://github.com/astral-sh/uv-pre-commit
17+
rev: 0.10.6
1818
hooks:
19-
- id: pdm-export
20-
args: ['--without-hashes']
21-
- id: pdm-lock-check
22-
- id: pdm-sync
19+
- id: uv-lock
20+
#- id: uv-export
2321
- repo: local
2422
hooks:
2523
- id: mypy
2624
name: MyPy
2725
description: use MyPy for static type checking
28-
entry: pdm run lint-mypy
26+
entry: uv run mypy src/intersect_sdk/
2927
pass_filenames: false
3028
language: system
3129
- repo: https://github.com/codespell-project/codespell

DEVELOPING.md

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@ Documentation for the INTERSECT Python SDK can be viewed at https://intersect-py
88

99
## Quickstart (developers)
1010

11-
This project uses [PDM](https://pdm.fming.dev/latest/) for Python tooling. Install PDM and run `pdm install -G:all`, or `pdm update` if resyncing the repository.
11+
This project uses UV for Python tooling. For initial setup:
1212

13-
To install pre-commit hooks, run `pdm run pre-commit install` after installation.
14-
15-
Main commands are specified under `tool.pdm.scripts` in `pyproject.toml`
13+
```bash
14+
uv venv .venv
15+
source .venv/bin/activate
16+
uv sync --all-extras --all-groups
17+
uv run pre-commit install
18+
```
1619

1720
### Docker build instructions
1821

19-
`docker build --target minimal -t intersect-sdk-python .`
22+
`docker build -t intersect-sdk-python .`
2023

2124
You will only need to rebuild this image if you need to add/update dependencies.
2225

@@ -28,25 +31,28 @@ If you don't want to use this docker-compose file, note that running a full Serv
2831

2932
## Adding dependencies
3033

31-
- **Required dependency**: `pdm add <dependency>`
32-
- **Optional dependency**: `pdm add -G <group> <dependency>`
33-
- **Dev dependency** `pdm add --dev -G <dev-group> <dependency>`
34+
- **Required dependency**: `uv add <dependency>`
35+
- **Optional dependency**: `uv add <dependency> --optional`
36+
- **Dev dependency** `uv add --dev <dependency>`
37+
38+
Regarding development dependencies:
3439

35-
For dev dependencies, please always specify the dev group as one of `lint`, `test`, or `doc`.
40+
- install documentation dependencies with `uv add <dependency> --optional docs`
3641

3742
## Linting
3843

39-
Run `pdm run lint` to quickly run all linters. The pre-commit hooks will also catch this.
44+
- Formatting: `uv run ruff format`
45+
- Linting: `uv run ruff check --fix`
46+
- Type analysis: `uv run mypy src/`
4047

41-
## Testing
48+
The pre-commit hooks will also lint for you.
4249

43-
Note that for the integration and e2e tests, you will need to spin up the docker-compose instance.
50+
## Testing
4451

45-
`pdm run test-all` - run all tests in standard format.
46-
`pdm run test-all-debug` - run tests allowing debug output (i.e. print statements in tests)
47-
`pdm run test-unit` - run only the unit tests (no backing services required for these)
52+
If you are running the integration tests or the e2e tests, you will need to spin up the docker-compose instance.
4853

49-
Tests are run with pytest if you'd like to customize how they are run. The full `pdm run test...` scripts can be found in `pyproject.toml`
54+
`uv run pytest tests/` - run all tests in standard format.
55+
`uv run pytest tests/unit/` - run only the unit tests (no backing services required for these)
5056

5157
## Examples
5258

Dockerfile

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,23 @@
1-
# container for CI/CD or development - NOT meant to be an extensible Docker image with the installed package
1+
# Development Dockerfile. Installs all development dependencies, runs as root (so the environment is mutable), intends for you to mount the directory as a volume if you're developing inside of it.
2+
#
3+
FROM ghcr.io/astral-sh/uv:python3.12-trixie-slim
24

3-
ARG REPO=
5+
WORKDIR /app
46

5-
# use this stage for development
6-
FROM ${REPO}python:3.8-slim as minimal
7+
ENV UV_COMPILE_BYTECODE=1
8+
ENV UV_LINK_MODE=copy
9+
ENV UV_TOOL_BIN_DIR=/usr/local/bin
710

8-
ENV PYTHONUNBUFFERED=1 \
9-
PYTHONDONTWRITEBYTECODE=1 \
10-
PIP_NO_CACHE_DIR=off \
11-
PIP_DISABLE_PIP_VERSION_CHECK=on \
12-
PIP_DEFAULT_TIMEOUT=100 \
13-
PDM_VERSION=2.17.3 \
14-
PDM_HOME=/usr/local
15-
# uncomment to allow prereleases to be installed
16-
#ENV PDM_PRERELEASE=1
17-
ENV PATH="/root/.local/bin:$PATH"
11+
RUN --mount=type=cache,target=/root/.cache/uv \
12+
--mount=type=bind,source=uv.lock,target=uv.lock \
13+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
14+
uv sync --no-install-project --all-groups --all-extras
1815

19-
RUN apt update \
20-
&& apt install -y curl make \
21-
&& rm -rf /var/lib/apt/lists/* \
22-
&& curl -sSL https://raw.githubusercontent.com/pdm-project/pdm/main/install-pdm.py | python -
16+
COPY . /app
17+
RUN --mount=type=cache,target=/root/.cache/uv \
18+
uv sync --all-groups --all-extras
2319

24-
WORKDIR /sdk
25-
# add minimal files needed for build
26-
COPY pyproject.toml pdm.lock README.md ./
27-
COPY src/intersect_sdk/version.py src/intersect_sdk/version.py
28-
RUN pdm sync --dev -G:all
20+
ENV PATH="/app/.venv/bin:$PATH"
2921

30-
# use this stage in CI/CD, not useful in development
31-
FROM minimal as complete
32-
COPY . .
22+
ENTRYPOINT ["uv", "run"]
23+
CMD ["/bin/bash"]

docs/Dockerfile

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

docs/contributing.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Read the sections below if you would like to contribute to the development of th
66
Installing for package development
77
----------------------------------
88

9-
Follow the steps discussed in this section to install the intersect-sdk package in a Python development environment. First, install Python and PDM on your local machine. See the :doc:`installation` page for more details. Next, clone the sdk repository as follows:
9+
Follow the steps discussed in this section to install the intersect-sdk package in a Python development environment. First, install Python and UV on your local machine. See the :doc:`installation` page for more details. Next, clone the sdk repository as follows:
1010

1111
.. code-block:: bash
1212
@@ -17,27 +17,27 @@ Create a Python virtual environment in the root level of the repository and acti
1717
.. code-block:: bash
1818
1919
# Create a virtual environment and activate it
20-
cd sdk
21-
python -m venv venv
22-
source venv/bin/activate
20+
cd python-sdk
21+
uv venv .venv
22+
source .venv/bin/activate
2323
24-
Use PDM to install the intersect-sdk package and its dependencies into the virtual environment.
24+
Use UV to install the intersect-sdk package and its dependencies into the virtual environment.
2525

2626
.. code-block:: bash
2727
28-
# Install the intersect-sdk package into the virtual environment using PDM
29-
pdm install
28+
# Install the intersect-sdk package into the virtual environment using UV
29+
uv sync --all-extras --all-groups
3030
3131
Check the installation by running one of the examples, such as the :doc:`examples/hello-world` example. Use the command shown below to deactivate the virtual environment:
3232

3333
.. code-block:: bash
3434
3535
deactivate
3636
37-
PDM
37+
UV
3838
------
3939

40-
The `PDM <https://pdm.fming.dev/latest/>`_ packaging and dependency management tool is used to install the intersect-sdk package in editable (developer) mode. It is also used to run linter checks, formatter checks, and unit tests. Download and install PDM using the instructions on the PDM website.
40+
The `UV <https://docs.astral.sh/uv//>`_ packaging and dependency management tool is used to install the intersect-sdk package in editable (developer) mode. It is also used to run linter checks, formatter checks, and unit tests. Download and install UV using the instructions on the UV website.
4141

4242
Documentation
4343
-------------

0 commit comments

Comments
 (0)