Skip to content

Commit a097ae0

Browse files
authored
Migrate to uv (#1073)
* Migrate pyproject.toml to uv * Update getting started docs * Update workflow to use setup-uv
1 parent 7af127c commit a097ae0

File tree

5 files changed

+755
-69
lines changed

5 files changed

+755
-69
lines changed

.github/workflows/main.yml

+11-41
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,15 @@ jobs:
2929
if: github.event_name == 'pull_request'
3030
run: git fetch origin ${{ github.base_ref }}
3131

32-
- name: Set up Python
33-
uses: actions/setup-python@v5
32+
- name: Set up uv
33+
uses: astral-sh/setup-uv@v3
3434
with:
35-
python-version: '3.10'
36-
37-
- name: Install Poetry
38-
uses: snok/[email protected]
39-
with:
40-
virtualenvs-in-project: true
41-
42-
- name: Setup cache
43-
id: cached-poetry-dependencies
44-
uses: actions/cache@v4
45-
with:
46-
path: .venv
47-
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
48-
49-
- name: Install dependencies
50-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
51-
run: poetry install
35+
version: '0.5.4'
36+
enable-cache: true
5237

5338
- name: Build and publish all modules
5439
if: github.event_name != 'pull_request'
55-
run: poetry run beet -p beet-release.yaml -l ${{ env.LOG_LEVEL }} build
40+
run: uv run beet -p beet-release.yaml -l ${{ env.LOG_LEVEL }} build
5641
env:
5742
BEET_MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
5843
BEET_SMITHED_TOKEN: ${{ secrets.SMITHED_TOKEN }}
@@ -61,7 +46,7 @@ jobs:
6146

6247
- name: Build all modules for pull request
6348
if: github.event_name == 'pull_request'
64-
run: poetry run beet -p beet-release.yaml -l ${{ env.LOG_LEVEL }} build
49+
run: uv run beet -p beet-release.yaml -l ${{ env.LOG_LEVEL }} build
6550
env:
6651
LOG_LEVEL: ${{ runner.debug == 1 && 'DEBUG' || 'INFO'}}
6752

@@ -121,29 +106,14 @@ jobs:
121106
steps:
122107
- uses: actions/checkout@v4
123108

124-
- name: Set up Python 3.10
125-
uses: actions/setup-python@v5
109+
- name: Set up uv
110+
uses: astral-sh/setup-uv@v3
126111
with:
127-
python-version: '3.10'
128-
129-
- name: Install Poetry
130-
uses: snok/[email protected]
131-
with:
132-
virtualenvs-in-project: true
133-
134-
- name: Setup cache
135-
id: cached-poetry-dependencies
136-
uses: actions/cache@v4
137-
with:
138-
path: .venv
139-
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
140-
141-
- name: Install dependencies
142-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
143-
run: poetry install
112+
version: '0.5.4'
113+
enable-cache: true
144114

145115
- name: Build all modules for tests
146-
run: poetry run beet -p beet-test.yaml -l ${{ env.LOG_LEVEL }} build
116+
run: uv run beet -p beet-test.yaml -l ${{ env.LOG_LEVEL }} build
147117
env:
148118
LOG_LEVEL: ${{ runner.debug == 1 && 'DEBUG' || 'INFO'}}
149119

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ __pycache__/
1111
*.py[cod]
1212
*$py.class
1313
.python-version
14+
*.egg-info/
1415

1516
### Beet ###
1617
out/

docs/getting-started.md

+15-8
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,16 @@ This guide will show how to setup a local development environment to build, test
99
## Installation
1010
To contribute to our project you need to install [Git](https://git-scm.com/downloads) and a text editor. We recommend [VSCode](https://code.visualstudio.com/).
1111

12-
Our modules are built using [beet](https://github.com/mcbeet/beet), which allows us to automatically validate and generate part of our data packs and resource packs. However this requires some extra setup:
13-
* [Python](https://www.python.org/downloads/) (version 3.10)
14-
* [Poetry](https://python-poetry.org/docs/)
12+
Our modules are built using [beet](https://github.com/mcbeet/beet), which is a Python framework that allows us to automatically validate and generate part of our data packs and resource packs.
13+
14+
You will need to install [uv](https://docs.astral.sh/uv/) as project manager. If you don't already have Python installed, uv will do that automatically.
15+
```sh
16+
# MacOS, Linux, or Git Bash (recommended)
17+
curl -LsSf https://astral.sh/uv/install.sh | sh
18+
19+
# Powershell on Windows
20+
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
21+
```
1522

1623
Create your own fork of this repository.
1724
![Forking the repository on GitHub](images/create-fork.png)
@@ -21,25 +28,25 @@ Clone your fork locally:
2128
git clone https://github.com/<username>/GM4_Datapacks.git
2229
```
2330

24-
Open the `GM4_Datapacks` folder in VScode. Then run `poetry install`. This will install beet and all our other dependencies.
31+
Open the `GM4_Datapacks` folder in VScode. Then run `uv sync`. This will install beet and all our other dependencies.
2532

2633
You are now ready to build our modules and make changes!
2734

2835
## Building modules
2936
The source of each module is stored in each `gm4_*` folder. To convert them to a valid data pack, you need to use Beet:
3037

3138
```
32-
poetry run beet dev --link <world_name> --watch metallurgy *_shamir
39+
uv run beet dev --link <world_name> --watch metallurgy *_shamir
3340
```
34-
* `poetry run` makes sure that the command uses the correct Python dependencies
41+
* `uv run` makes sure that the command uses the correct Python dependencies
3542
* `beet dev` builds the data packs to the `out` folder
3643
* `--link <world_name>` copies the packs to a local world
3744
* `--watch` watches for file changes and then rebuilds
3845
* `metallurgy *_shamir` specifies the list of module IDs to build
3946

4047
Building the release version of all modules is also possible. It will output the zipped data packs in the `release/<version>` folder. Running this could take a few minutes!
4148
```
42-
poetry run beet -p beet-release.yaml build
49+
uv run beet -p beet-release.yaml build
4350
```
4451

4552
## Submitting changes
@@ -55,7 +62,7 @@ git checkout -b <branch_name>
5562
While making changes, test the data packs in a local world:
5663

5764
```
58-
poetry run beet dev --link <world_name> --watch <module_id>
65+
uv run beet dev --link <world_name> --watch <module_id>
5966
```
6067

6168
When you are happy with the changes, create a commit on the branch.

pyproject.toml

+27-20
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
1-
[tool.poetry]
1+
[project]
22
name = "gm4"
33
version = "1.0.0"
4-
description = "Datapacks for https://gm4.co"
5-
authors = ["Gamemode 4 Contributors"]
4+
description = "Data packs for https://gm4.co"
5+
authors = [
6+
{name = "Gamemode 4 Contributors"},
7+
]
8+
requires-python = ">= 3.10, < 4.0"
9+
dependencies = [
10+
"beet @ git+https://github.com/misode/beet.git@fix-overlay-folders",
11+
"mecha >= 0.95.2",
12+
"bolt >= 0.49.1",
13+
"PyYAML >= 6.0, < 7.0",
14+
"pydantic >= 2.6.1, < 3.0.0",
15+
"requests >= 2.28.1, < 3.0.0",
16+
"pillow >= 10.0.0, < 11.0.0",
17+
"repro-zipfile >= 0.1.0, < 1.0.0",
18+
]
619

7-
[tool.poetry.dependencies]
8-
python = "^3.10"
9-
beet = { git = "https://github.com/misode/beet.git", rev = "fix-overlay-folders" }
10-
mecha = ">=0.95.2"
11-
bolt = ">=0.49.1"
12-
PyYAML = "^6.0"
13-
pydantic = "^2.6.1"
14-
requests = "^2.28.1"
15-
pillow = "^10.0.0"
16-
repro-zipfile = "^0.1.0"
20+
[tool.uv]
21+
dev-dependencies = [
22+
"black >= 22.6.0, < 23.0.0",
23+
"isort >= 5.10.1, < 6.0.0",
24+
"uv >= 0.5.4",
25+
]
1726

18-
[tool.poetry.dev-dependencies]
19-
black = "^22.6.0"
20-
isort = "^5.10.1"
21-
22-
[tool.poetry.plugins.beet]
27+
[project.entry-points.beet]
2328
commands = "gm4.commands"
2429
autoload = "gm4.plugins.autoload"
2530

@@ -32,5 +37,7 @@ typeCheckingMode = "strict"
3237
profile = "black"
3338

3439
[build-system]
35-
requires = ["poetry-core>=1.0.0"]
36-
build-backend = "poetry.core.masonry.api"
40+
requires = ["setuptools"]
41+
42+
[tool.setuptools]
43+
packages = ["gm4"]

0 commit comments

Comments
 (0)