Skip to content

Commit f7e478f

Browse files
committed
Migrate from pip to uv: faster, safer, reproducible builds
1 parent fb20014 commit f7e478f

6 files changed

Lines changed: 8875 additions & 26 deletions

File tree

.github/workflows/ci.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ on:
66
branches:
77
- master
88
paths:
9-
- ".github/workflows/type-checking.yml"
9+
- ".github/workflows/ci.yml"
1010
- "docs/**"
1111
- ".readthedocs.yaml"
1212
- "pyproject.toml"
1313
- "setup.cfg"
1414
- "**/*.py"
1515
pull_request:
1616
paths:
17-
- ".github/workflows/type-checking.yml"
17+
- ".github/workflows/ci.yml"
1818
- "docs/**"
1919
- ".readthedocs.yaml"
2020
- "pyproject.toml"
@@ -30,21 +30,23 @@ jobs:
3030
python-version: ["3.10"]
3131
fail-fast: false
3232
steps:
33-
- uses: actions/checkout@v4
34-
- uses: actions/setup-python@v6
33+
- uses: actions/checkout@v6
34+
- uses: astral-sh/setup-uv@v8.2.0
3535
with:
3636
python-version: ${{ matrix.python-version }}
37-
- run: pip install . --group=dev
37+
activate-environment: true
38+
- run: uv sync --locked
3839
- run: mypy . --python-version=${{ matrix.python-version }}
3940

4041
sphinx:
4142
runs-on: ubuntu-22.04 # Keep in sync with build.os in .readthedocs.yaml
4243
steps:
43-
- uses: actions/checkout@v4
44-
- uses: actions/setup-python@v6
44+
- uses: actions/checkout@v6
45+
- uses: astral-sh/setup-uv@v8.2.0
4546
with:
4647
python-version: "3.11" # Keep in sync with build.tools.python in .readthedocs.yaml
47-
- run: pip install . --group=docs
48+
activate-environment: true
49+
- run: uv sync --locked --no-default-groups --group=docs
4850
- name: Build docs
4951
# TODO: Add --fail-on-warning, but still too many warnings right now
5052
run: sphinx-build --keep-going -b html docs/source docs/_build/html

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
venv/
22
.tox/
3+
.python-version
34

45
*.pyc
56
__pycache__/

.readthedocs.yaml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ build:
1313
# nodejs: "20"
1414
# rust: "1.70"
1515
# golang: "1.20"
16-
jobs:
17-
install:
18-
# Since the install step is overridden, pip is no longer updated automatically.
19-
- pip install --upgrade pip
20-
- pip install . --group=docs
2116

2217
# Build documentation in the "docs/" directory with Sphinx
2318
sphinx:
@@ -31,3 +26,14 @@ sphinx:
3126
# formats:
3227
# - pdf
3328
# - epub
29+
30+
# Optional but recommended, declare the Python requirements required
31+
# to build your documentation
32+
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
33+
python:
34+
install:
35+
# https://docs.readthedocs.com/platform/latest/build-customization.html#install-dependencies-with-uv
36+
- method: uv
37+
command: sync
38+
groups:
39+
- docs

README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -223,17 +223,17 @@ Note not all windows/applications will have a menu accessible by these methods.
223223

224224
## Install <a name="install"></a>
225225

226-
To install this module on your system, you can use pip:
226+
To install this module on your system, you can use pip:
227227

228-
pip3 install pywinctl
228+
python -m pip install pywinctl
229229

230-
or
230+
or using uv:
231231

232-
python3 -m pip install pywinctl
232+
uv add pywinctl
233233

234234
Alternatively, you can download the wheel file (.whl) available in the [Download page](https://pypi.org/project/PyWinCtl/#files) and run this (don't forget to replace 'x.xx' with proper version number):
235235

236-
pip install PyWinCtl-x.xx-py3-none-any.whl
236+
python -m pip install PyWinCtl-x.xx-py3-none-any.whl
237237

238238
You may want to add `--force-reinstall` option to be sure you are installing the right dependencies version.
239239

@@ -249,14 +249,20 @@ In case you have a problem, comments or suggestions, do not hesitate to [open is
249249

250250
If you want to use this code or contribute, you can either:
251251

252-
* Create a fork of the [repository](https://github.com/Kalmat/PyWinCtl), or
252+
* Create a fork of the [repository](https://github.com/Kalmat/PyWinCtl), or
253253
* [Download the repository](https://github.com/Kalmat/PyWinCtl/archive/refs/heads/master.zip), uncompress, and open it on your IDE of choice (e.g. PyCharm)
254254

255-
Be sure you install all dev dependencies by using pip: `pip install -e . --group=dev`
255+
Be sure you install all dev dependencies by running:
256+
257+
uv sync
258+
259+
or
260+
python -m venv .venv
261+
python -m pip install -e . --group=dev
256262

257263
## Test <a name="test"></a>
258264

259265
To test this module on your own system, cd to "tests" folder and run:
260266

261-
python3 test_pywinctl.py
267+
uv run test_pywinctl.py
262268

pyproject.toml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ name = "PyWinCtl"
77
dynamic = ["version"]
88
description = "Cross-Platform toolkit to get info on and control windows on screen"
99
authors = [
10-
{ name = "Kalmat", email = "palookjones@gmail.com" },
10+
{ name = "Kalmat", email = "palookjones@gmail.com" }
1111
]
1212
readme = "README.md"
13-
license = {file = "LICENSE.txt"}
13+
license = { file = "LICENSE.txt" }
1414
requires-python = ">=3.9"
1515
keywords = [
1616
"activate",
@@ -66,19 +66,27 @@ docs = [
6666
"myst-parser",
6767
]
6868
dev = [
69-
{include-group = "docs"},
69+
{ include-group = "docs" },
7070
"ewmhlib",
7171
"mypy>=0.990,<2",
7272
"types-python-xlib>=0.32",
7373
"types-pywin32>=305.0.0.3",
7474
"types-setuptools>=65.5",
7575
]
7676

77+
[tool.uv]
78+
exclude-newer = "1 week"
79+
[tool.uv.exclude-newer-package]
80+
# Kalmat owns these packages
81+
ewmhlib = false
82+
pymonctl = false
83+
pywinbox = false
84+
7785
[project.urls]
7886
Homepage = "https://github.com/Kalmat/PyWinCtl"
7987

8088
[tool.setuptools.packages.find]
81-
where = ["src"] # list of folders that contain the packages (["."] by default)
89+
where = ["src"] # list of folders that contain the packages (["."] by default)
8290

8391
[tool.setuptools.dynamic]
84-
version = {attr = "pywinctl.__version__"} # any module attribute compatible with ast.literal_eval
92+
version = { attr = "pywinctl.__version__" } # any module attribute compatible with ast.literal_eval

0 commit comments

Comments
 (0)