Skip to content

Commit f4cd96e

Browse files
committed
Upgrade to uv template.
1 parent 7d7acd9 commit f4cd96e

File tree

14 files changed

+542
-844
lines changed

14 files changed

+542
-844
lines changed

.copier-answers.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Changes here will be overwritten by Copier. Do not edit manually.
2-
_commit: 77a7151
2+
_commit: 98316a7
33
_src_path: gh:jlevy/simple-modern-uv
44
package_author_email: [email protected]
55
package_author_name: Joshua Levy
66
package_description: Simple, useful decorators for logging and tallying function calls
77
package_github_org: jlevy
8+
package_module: funlog
89
package_name: funlog
9-
package_slug: funlog

.github/workflows/ci.yml

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,53 +16,48 @@ permissions:
1616

1717
jobs:
1818
build:
19-
runs-on: ubuntu-latest
2019
strategy:
2120
matrix:
2221
# Update this as needed:
23-
python-version: ["3.10","3.11", "3.12", "3.13"]
22+
23+
# Common platforms: ["ubuntu-latest", "macos-latest", "windows-latest"]
24+
os: ["ubuntu-latest"]
25+
python-version: ["3.10", "3.11", "3.12", "3.13"]
26+
27+
# Linux only by default. Use ${{ matrix.os }} for other OSes.
28+
runs-on: ${{ matrix.os }}
2429

2530
steps:
26-
- uses: actions/checkout@v4
31+
# Generally following uv docs:
32+
# https://docs.astral.sh/uv/guides/integration/github/
33+
34+
- name: Checkout (official GitHub action)
35+
uses: actions/checkout@v4
2736
with:
2837
# Important for versioning plugins:
2938
fetch-depth: 0
3039

31-
- name: Set up Python
32-
uses: actions/setup-python@v5
40+
- name: Install uv (official Astral action)
41+
uses: astral-sh/setup-uv@v5
3342
with:
43+
version: "0.6.5"
44+
enable-cache: true
3445
python-version: ${{ matrix.python-version }}
3546

36-
- name: Install Poetry
37-
uses: snok/install-poetry@v1
38-
with:
39-
# Update this as needed:
40-
version: 2.1.1
41-
42-
- name: Configure Poetry to use Python version
43-
run: |
44-
poetry env use ${{ matrix.python-version }}
45-
poetry run python --version
46-
47-
- name: Cache Poetry dependencies
48-
uses: actions/cache@v4
49-
with:
50-
path: |
51-
~/.cache/pypoetry
52-
~/.cache/pip
53-
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}-${{ matrix.python-version }}
54-
restore-keys: |
55-
${{ runner.os }}-poetry-
47+
- name: Set up Python (using uv)
48+
run: uv python install
5649

57-
- name: Install Poetry plugins
58-
run: |
59-
poetry self add "poetry-dynamic-versioning[plugin]"
50+
# Alternately can use the official Python action:
51+
# - name: Set up Python (using actions/setup-python)
52+
# uses: actions/setup-python@v5
53+
# with:
54+
# python-version: ${{ matrix.python-version }}
6055

61-
- name: Install dependencies
62-
run: poetry install
56+
- name: Install all dependencies
57+
run: uv sync --all-extras --dev
6358

6459
- name: Run linting
65-
run: poetry run python devtools/lint.py
60+
run: uv run python devtools/lint.py
6661

6762
- name: Run tests
68-
run: poetry run pytest
63+
run: uv run pytest

.github/workflows/publish.yml

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,30 @@ jobs:
1212
id-token: write # Mandatory for OIDC.
1313
contents: read
1414
steps:
15-
- name: Check out the code
15+
- name: Checkout (official GitHub action)
1616
uses: actions/checkout@v4
1717
with:
1818
# Important for versioning plugins:
1919
fetch-depth: 0
2020

21-
- name: Set up Python
22-
uses: actions/setup-python@v5
21+
- name: Install uv (official Astral action)
22+
uses: astral-sh/setup-uv@v5
2323
with:
24+
version: "0.6.5"
25+
enable-cache: true
2426
python-version: "3.12"
2527

26-
- name: Install Poetry
27-
uses: snok/install-poetry@v1
28-
with:
29-
version: latest
30-
31-
- name: Install Poetry plugins
32-
run: |
33-
poetry self add "poetry-dynamic-versioning[plugin]"
28+
- name: Set up Python (using uv)
29+
run: uv python install
3430

35-
- name: Install dependencies
36-
run: poetry install --no-root
31+
- name: Install all dependencies
32+
run: uv sync --all-extras --dev
3733

34+
- name: Run tests
35+
run: uv run pytest
36+
3837
- name: Build package
39-
run: poetry build
38+
run: uv build
4039

41-
- name: Publish to PyPI
40+
- name: Publish to PyPI (using uv)
4241
uses: pypa/gh-action-pypi-publish@release/v1

Makefile

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1+
# Makefile for easy development workflows.
2+
# GitHub Actions call uv directly.
3+
14
.DEFAULT_GOAL := default
25

3-
.PHONY: default install_deps lint test build clean
6+
.PHONY: default install lint test upgrade build clean
47

5-
default: install_deps lint test
8+
default: install lint test
69

7-
install_deps:
8-
poetry install
10+
install:
11+
uv sync --all-extras --dev
912

1013
lint:
11-
poetry run python devtools/lint.py
14+
uv run python devtools/lint.py
1215

1316
test:
14-
poetry run pytest
17+
uv run pytest
18+
19+
upgrade:
20+
uv sync --upgrade
1521

1622
build:
17-
poetry build
23+
uv build
1824

1925
clean:
2026
-rm -rf dist/

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# funlog
22

3+
<<<<<<< before updating
34
`funlog` is a tiny but useful package that offers a few Python decorators to log
45
function calls, with good control over what gets logged and when.
56

@@ -99,6 +100,44 @@ INFO:⏱ Function tallies:
99100
__main__.fibonacci() was called 465 times, total time 59.73s, avg per call 128ms
100101
__main__.sleep() was called 232 times, total time 9.11s, avg per call 39.25ms
101102
```
103+
=======
104+
\[ **☞☞☞ This is the readme for a project from the
105+
[simple-modern-uv](https://github.com/jlevy/simple-modern-uv) template.** Fill it in and
106+
delete this message!
107+
Below are brief instructions on setup and development workflows that you may use or
108+
modify for your project.
109+
\]
110+
111+
## Installing uv and Python
112+
113+
This project is set up to use [**uv**](https://docs.astral.sh/uv/), the new package
114+
manager for Python. `uv` replaces traditional use of `pyenv`, `pipx`, `poetry`, `pip`,
115+
etc. This is a quick cheat sheet on that:
116+
117+
On macOS or Linux, if you don't have `uv` installed, a quick way to install it:
118+
119+
```shell
120+
curl -LsSf https://astral.sh/uv/install.sh | sh
121+
```
122+
123+
For macOS, you prefer [brew](https://brew.sh/) you can install or upgrade uv with:
124+
125+
```shell
126+
brew update
127+
brew install uv
128+
```
129+
130+
See [uv's docs](https://docs.astral.sh/uv/getting-started/installation/) for more
131+
installation methods and platforms.
132+
133+
Now you can use uv to install a current Python environment:
134+
135+
```shell
136+
uv python install 3.13 # Or pick another version.
137+
```
138+
139+
## Development
140+
>>>>>>> after updating
102141
103142
There are several other options.
104143
See docstrings and [test_examples.py](tests/test_examples.py) for more docs and examples
@@ -107,4 +146,8 @@ on all the options.
107146
* * *
108147

109148
*This project was built from
149+
<<<<<<< before updating
110150
[simple-modern-poetry](https://github.com/jlevy/simple-modern-poetry).*
151+
=======
152+
[simple-modern-uv](https://github.com/jlevy/simple-modern-uv).*
153+
>>>>>>> after updating

development.md

Lines changed: 56 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,80 @@
1-
## Development
1+
# Development
22

3-
[Fork](https://github.com/jlevy/kmd/fork) this repo (having your own fork will make it
4-
easier to contribute),
5-
[check out](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository),
6-
and then install the package dependencies:
3+
## Setting Up uv
74

8-
```shell
9-
poetry install
10-
```
5+
This project is set up to use [uv](https://docs.astral.sh/uv/) to manage Python and
6+
dependencies. First, be sure you
7+
[have uv installed](https://docs.astral.sh/uv/getting-started/installation/).
8+
9+
Then [fork](https://github.com/jlevy/funlog/fork) this
10+
repo (having your own fork will make it easier to contribute) and
11+
[clone it](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository).
1112

12-
Developer workflows:
13+
## Basic Developer Workflows
14+
15+
The `Makefile` simply offers shortcuts to `uv` commands for developer convenience.
16+
(For clarity, GitHub Actions don't use the Makefile and just call `uv` directly.)
1317

1418
```shell
15-
# Run poetry install, lint, and test:
19+
# First, install all dependencies and set up your virtual environment.
20+
# This simply runs `uv sync --all-extras --dev` to install all packages,
21+
# including dev dependencies and optional dependencies.
22+
make install
23+
24+
# Run uv sync, lint, and test:
1625
make
1726

1827
# Build wheel:
1928
make build
2029

21-
# Linting and testing individually:
30+
# Linting:
2231
make lint
32+
33+
# Run tests:
2334
make test
2435

2536
# Delete all the build artifacts:
2637
make clean
2738

28-
# To run a shell within the Python environment:
29-
poetry shell
30-
# Thereafter you can run tests.
31-
32-
# To run tests:
33-
pytest # all tests
34-
pytest -s src/module/some_file.py # one test, showing outputs
35-
36-
# Poetry dependency management commands:
37-
# Upgrade all dependencies:
38-
poetry up
39-
# Update poetry itself:
40-
poetry self update
39+
# Upgrade dependencies to compatible versions:
40+
make upgrade
41+
42+
# To run tests by hand:
43+
uv run pytest # all tests
44+
uv run pytest -s src/module/some_file.py # one test, showing outputs
45+
46+
# Build and install current dev executables, to let you use your dev copies
47+
# as local tools:
48+
uv tool install --editable .
49+
50+
# Dependency management directly with uv:
51+
# Add a new dependency:
52+
uv add package_name
53+
# Add a development dependency:
54+
uv add --dev package_name
55+
# Update to latest compatible versions (including dependencies on git repos):
56+
uv sync --upgrade
57+
# Update a specific package:
58+
uv lock --upgrade-package package_name
59+
# Update dependencies on a package:
60+
uv add package_name@latest
61+
62+
# Run a shell within the Python environment:
63+
uv venv
64+
source .venv/bin/activate
4165
```
4266

67+
See [uv docs](https://docs.astral.sh/uv/) for details.
68+
4369
## Release Process
4470

4571
This project is set up to publish to [PyPI](https://pypi.org/) from GitHub Actions.
4672

4773
Thanks to [the dynamic versioning
48-
plugin](https://github.com/mtkennerly/poetry-dynamic-versioning) and `publish.yml`
49-
workflow, you can simply create tagged releases (using standard format for the tag name,
50-
e.g. `v0.1.0`) on GitHub and the tag will trigger a release build, which then uploads it
51-
to PyPI.
74+
plugin](https://github.com/ninoseki/uv-dynamic-versioning/) and the
75+
[`publish.yml` workflow](.github/workflows/publish.yml), you can simply create tagged
76+
releases (using standard format for the tag name, e.g. `v0.1.0`) on GitHub and the tag
77+
will trigger a release build, which then uploads it to PyPI.
5278

5379
For this to work you will need to have a PyPI account and authorize your repository to
5480
publish to PyPI. The simplest way to do that is on [the publishing settings
@@ -58,5 +84,5 @@ the project name, repo owner, repo name, and `publish.yml` as the workflow name.
5884

5985
* * *
6086

61-
*This file generated by
62-
[simple-modern-poetry](https://github.com/jlevy/simple-modern-poetry).*
87+
*This file was built with
88+
[simple-modern-uv](https://github.com/jlevy/simple-modern-uv).*

0 commit comments

Comments
 (0)