Skip to content

Commit bcde1af

Browse files
committed
Switch form Pipenv to uv
1 parent 55fe9d3 commit bcde1af

File tree

14 files changed

+869
-1056
lines changed

14 files changed

+869
-1056
lines changed

.devcontainer/Dockerfile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ FROM mcr.microsoft.com/devcontainers/python:1-3.12-bookworm
77
# <your-package-list-here> \
88
# && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
99

10-
# Install pipenv dependencies
11-
COPY Pipfile Pipfile.lock /tmp/
12-
RUN cd /tmp && pipenv install --system --dev
10+
# Install UV / UVX
11+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
12+
ENV UV_COMPILE_BYTECODE=1
13+
ENV UV_LINK_MODE=copy
14+
15+
# Install project dependencies
16+
RUN --mount=type=bind,source=pyproject.toml,target=pyproject.toml \
17+
--mount=type=bind,source=uv.lock,target=uv.lock \
18+
uv sync --frozen --no-install-project --all-extras

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// Use 'forwardPorts' to make a list of ports inside the container available locally.
1515
// "forwardPorts": [],
1616
// Use 'postCreateCommand' to run commands after the container is created.
17-
"postCreateCommand": "pip install -e ."
17+
"postCreateCommand": "uv sync"
1818
// Configure tool-specific properties.
1919
// "customizations": {},
2020
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.

.github/workflows/project-build-test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ jobs:
4242
steps:
4343
- name: Checkout code
4444
uses: actions/checkout@v4
45-
- name: Build package
45+
- name: Build Python package
4646
run: ./tools/build-package.sh
47-
- name: Upload python package
47+
- name: Upload Python package
4848
uses: actions/upload-artifact@v4
4949
with:
5050
name: python-package
@@ -77,7 +77,7 @@ jobs:
7777
steps:
7878
- name: Checkout code
7979
uses: actions/checkout@v4
80-
- name: Run pytest
80+
- name: Run tests
8181
run: ./tools/test-package.sh
8282
- name: Upload test results
8383
uses: actions/upload-artifact@v4

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
__pycache__
22
.coverage
3+
.mypy_cache
4+
.pytest_cache
5+
.venv
36
*.egg-info
47
_build
58
build

Pipfile

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

Pipfile.lock

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

README.md

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,12 @@ Commands:
2020

2121
The Python package is based on the following toolchain:
2222

23-
* [Pipenv](https://pipenv.pypa.io/en/latest/) for dependencies and virtual environment
23+
* [uv](https://docs.astral.sh/uv/) for dependencies and virtual environment
2424
* [Sphinx](https://www.sphinx-doc.org/en/master/) for documentation
2525
* [Flake8](https://flake8.pycqa.org/en/latest/) for style guide enforcement
2626
* [mypy](https://mypy-lang.org/) for static type checking
2727
* [Pylint](https://www.pylint.org/) for static code analysis
2828
* [pytest](https://docs.pytest.org/en/stable/) for test creation and execution
29-
* [Twine](https://twine.readthedocs.io/en/stable/) for package deployment
3029

3130

3231
## Directory structure
@@ -43,64 +42,52 @@ The Python package is based on the following toolchain:
4342

4443
## Build, test and deploy instructions
4544

46-
Create and activate the Python virtual environment:
45+
All steps required to build, test or deploy the Python package are wrapped in separate shell scripts.
4746

48-
```bash
49-
pipenv sync --dev # setup virtual environment including development dependencies
50-
pipenv shell # activate virtual environment
51-
```
52-
53-
Note: the Python virtual environment can be removed using `pipenv --rm`.
54-
55-
**IMPORTANT:** all of the following commands have to be executed within the Python virtual environment!
47+
Check the content of the corresponding scripts for details.
5648

5749
### Build documentation
5850

59-
Build the Sphinx documentation: `./tools/build-docs.sh`
51+
Build the Sphinx documentation:
6052

6153
```bash
62-
pip install -e . # package installation is required for Git version
63-
cd docs
64-
make html
54+
./tools/build-docs.sh
6555
```
6656

6757
### Build Python package
6858

69-
Build the Python package: `./tools/build-package.sh`
59+
Build the Python package:
7060

7161
```bash
72-
python -m build --wheel
62+
./tools/build-package.sh
7363
```
7464

7565
### Run Python linters
7666

77-
Run static code analysis: `./tools/lint-package.sh`
67+
Run static code analysis:
7868

7969
```bash
80-
mkdir -p build
81-
flake8 src/python_training_project --format=pylint > build/flake8.txt
82-
pylint src/python_training_project --msg-template="{path}:{line}: [{msg_id}, {obj}] {msg} ({symbol})" > build/pylint.txt
83-
mypy src/python_training_project > build/mypy.txt
70+
./tools/lint-package.sh
8471
```
8572

8673
### Run Python tests
8774

88-
Run Python tests: `./tools/test-package.sh`
75+
Run Python tests:
8976

9077
```bash
91-
pip install -e . # package installation is required for path resolution
92-
mkdir -p build
93-
pytest
78+
./tools/test-package.sh
9479
```
9580

9681
### Deploy Python package
9782

98-
Deploy the Python package: `./tools/deploy-package.sh`
83+
Make sure the set the following environment variables before calling the deployment script:
84+
85+
* `UV_PUBLISH_URL`
86+
* `UV_PUBLISH_USERNAME`
87+
* `UV_PUBLISH_PASSWORD`
88+
89+
Deploy the Python package:
9990

10091
```bash
101-
# Make sure to set the following environment variables
102-
# TWINE_REPOSITORY_URL
103-
# TWINE_USERNAME
104-
# TWINE_PASSWORD
105-
twine upload dist/*
92+
./tools/deploy-package.sh
10693
```

pyproject.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,20 @@ dependencies = [
2525
]
2626
dynamic = ["version"]
2727

28+
[project.optional-dependencies]
29+
dev = [
30+
"coverage",
31+
"flake8",
32+
"mypy",
33+
"myst-parser",
34+
"pylint",
35+
"pytest",
36+
"pytest-cov",
37+
"pytest-mock",
38+
"sphinx",
39+
"sphinx-rtd-theme",
40+
]
41+
2842
[project.urls]
2943
"Homepage" = "https://github.com/devminds-ch/project-python"
3044
"Bug Tracker" = "https://github.com/devminds-ch/project-python/issues"

tools/build-docs.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ REPO_ROOT=$(git rev-parse --show-toplevel)
66
pushd "${REPO_ROOT}" 2>&1 > /dev/null
77

88
echo "Building documentation..."
9-
pip install -e . # required for python_training_project.version
109
mkdir -p build
1110
cd docs
12-
make html
11+
uv run --all-extras make html
1312

1413
popd 2>&1 > /dev/null

tools/build-package.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ REPO_ROOT=$(git rev-parse --show-toplevel)
66
pushd "${REPO_ROOT}" 2>&1 > /dev/null
77

88
echo "Building package..."
9-
python -m build --wheel
9+
uv build
1010

1111
popd 2>&1 > /dev/null

0 commit comments

Comments
 (0)