Skip to content

Commit 431995f

Browse files
authored
Use our own rendering exclusively (#277)
I ended up changing more than I planned to.
1 parent fe69868 commit 431995f

File tree

16 files changed

+450
-747
lines changed

16 files changed

+450
-747
lines changed

.github/workflows/publish.yaml

Lines changed: 10 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,81 +8,50 @@ env:
88

99
on:
1010
pull_request:
11-
types: [ opened, reopened, synchronize ]
1211
push:
1312
branches:
1413
- main
14+
workflow_dispatch:
1515

1616
jobs:
1717
publish-packages:
18-
name: Publish python packages
18+
name: Publish package index
1919
runs-on: ubuntu-latest
2020
timeout-minutes: 10
2121

2222
permissions:
2323
contents: write # Needed for GH pages updates
2424

2525
steps:
26-
- uses: actions/checkout@v4
26+
- uses: actions/checkout@v5
2727

2828
- name: Set up uv
29-
run: |
30-
curl -LsSf https://astral.sh/uv/install.sh | sh
29+
uses: astral-sh/setup-uv@v6
3130

3231
- name: Set up Python ${{ env.PYTHON_VERSION }}
3332
uses: actions/setup-python@v5
3433
with:
3534
python-version: "${{ env.PYTHON_VERSION }}"
3635

37-
- name: Install zsh
38-
run: |
39-
sudo apt-get update
40-
sudo apt-get install zsh
41-
4236
- name: Install packages
4337
run: |
4438
uv sync --extra index
4539
46-
- name: Collect scenarios
47-
run: |
48-
scenarios=(scenarios/**/*.(json|yaml|toml))
49-
50-
# Display for debug
51-
for scenario in $scenarios
52-
do
53-
echo "$scenario"
54-
done
55-
echo "SCENARIOS=$scenarios" >> "$GITHUB_ENV"
56-
57-
# Assigning a glob to a variable in `bash` is such a pain I don't want to talk about it
58-
# instead we just use zsh
59-
shell: zsh {0}
60-
6140
- name: View scenarios
6241
run: |
63-
uv run -- packse view $SCENARIOS
42+
uv run -- packse view scenarios/**/*.{toml,yaml,json}
6443
65-
- name: Build scenarios
44+
- name: Build scenarios and index
6645
run: |
67-
uv run -- packse build --skip-root --no-hash $SCENARIOS
68-
69-
- name: Publish scenarios [local]
70-
if: github.ref != 'refs/heads/main'
71-
run: |
72-
# Start the local index server, do not allow packages from PyPI
73-
index_url=$(uv run -- packse index up --bg --offline --dist-dir "./published")
74-
75-
# Publish the packages
76-
uv run -- packse publish --anonymous --index-url "$index_url" dist/*
46+
uv run -- packse index build --no-hash scenarios
7747
78-
# Shutdown the index server
79-
uv run -- packse index down
48+
- name: Publish scenarios
49+
run: echo ${{ github.ref }}
8050

81-
- name: Publish scenarios [gh pages]
51+
- name: Publish scenarios
8252
if: github.ref == 'refs/heads/main'
8353
run: |
8454
commit=$(./scripts/version parts | jq -r ".short_hash")
85-
uv run -- packse index build --no-hash --dist-dir ./dist $SCENARIOS
8655
8756
git fetch origin gh-pages
8857
git branch gh-pages FETCH_HEAD

.gitignore

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
__pycache__
2-
.cache
31
*.pyc
2+
.cache
43
.envrc
4+
__pycache__
55
build/**/*
66
dist/**/*
7-
node_modules
7+
index/**/*
8+
node_modules

README.md

Lines changed: 20 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Notice, when a specific scenario is specified, there is more information display
102102
A scenario can be used to generate packages and build distributions:
103103

104104
```bash
105-
packse build scenario/example.json
105+
packse build scenario/example.toml
106106
```
107107

108108
The `build/` directory will contain sources for all of the packages in the scenario.
@@ -116,71 +116,49 @@ publishing multiple times to a registry that does not allow overwrites.
116116
The `PACKSE_VERSION_SEED` environment variable can be used to override the seed used to generate the unique
117117
identifier, allowing versions to differ based on information outside of packse.
118118

119-
### Publishing scenarios
120-
121-
Built scenarios can be published to a Python Package Index with the `publish` command:
122-
123-
```bash
124-
packse publish dist/example-cd797223
125-
```
126-
127-
By default, packages are published to the Test PyPI server.
128-
129-
Credentials must be provided via the `PACKSE_PYPI_PASSWORD` environment variable. `PACKSE_PYPI_USERNAME` can be
130-
used to set a username if not using an API token. If using a server which does not require authentication, the
131-
`--anonymous` flag can be passed.
132-
133119
### Running a package index
134120

135-
_Requires installation with the `index` extra_
121+
_Requires installation with the `serve` extra_
136122

137-
A local package index can be controlled with the `index` command. For example, to start a local package index:
123+
To start a local package index:
138124

139125
```bash
140-
packse index up
126+
packse serve
141127
```
142128

143-
The `--bg` flag can be passed to run the index in the background.
144-
When running an index in the background, state will be stored in the `~/.packse` directory. The `PACKSE_STATE_PATH`
145-
environment variable can be used to change the state path.
146-
147129
Packages can be installed by passing the `--index-url` flag to the installer e.g. with `pip`:
148130

149131
```bash
150-
pip install --index-url http://127.0.0.1:3141 example-0611cb74
132+
pip install --index-url http://127.0.0.1:3141/simple-html example-a-e656679f
151133
```
152134

153-
Packages can be published to the index by providing the `--index-url` and `--anonymous` flags to the `publish` command:
135+
To also include build dependencies, use the `/vendor` subdirectory:
154136

155137
```bash
156-
packse publish dist/example-cd797223 --index-url http://localhost:3141 --anonymous
138+
pip install --index-url http://127.0.0.1:3141/simple-html --find-links http://127.0.0.1:3141/vendor example-a-e656679f
157139
```
158140

159-
Packages can also be published to the index by placing their distributions in the configured `--dist-dir`. This defaults
160-
to `./dist` which is also the default location used in `packse build`.
161-
162-
By default, the index will fallback to PyPI for missing packages. To test in isolation, use the `--offline` flag.
163-
164-
To stop an index running in the background use `packse index down`:
141+
Packse will watch for changes to the `scenarios` directory, and publish new versions on each change.
165142

166-
```
167-
packse index down
168-
```
143+
Note when developing, it is often useful to use the `--no-hash` flag to avoid having to determine the latest
144+
hash for the scenario.
169145

170-
### Serving scenarios
146+
### Building a package index
171147

172-
_Requires installation with the `serve` extra_
148+
_Requires installation with the `index` extra_
173149

174-
The `serve` command can be used to host, build, and publish scenarios in one step.
150+
Packse can build a file tree that can be served statically, for example, through GitHub Pages, that serve both
151+
the scenarios and the vendored build dependencies, using the `index` command:
175152

176153
```bash
177-
packse serve scenarios
154+
packse index build
178155
```
179156

180-
Packse will watch for changes to the `scenarios` directory, and publish new versions on each change.
157+
This creates three directories in `./index`:
181158

182-
Note when developing, it is often useful to use the `--no-hash` flag to avoid having to determine the latest
183-
hash for the scenario.
159+
* `./index/files`: The distributions.
160+
* `./index/simple-html`: The simple HTML index (PEP 503).
161+
* `./index/vendor`: A flat index of build dependencies.
184162

185163
### Testing scenarios
186164

@@ -189,7 +167,7 @@ Published scenarios can then be tested with your choice of package manager.
189167
For example, with `pip`:
190168

191169
```bash
192-
pip install -i https://test.pypi.org/simple/ example-cd797223
170+
pip install -i https://astral-sh.github.io/packse/548262f/simple-html/ example-cd797223
193171
```
194172

195173
### Exporting scenarios

pyproject.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ dependencies = [
2727
"hatchling>=1.20.0",
2828
"chevron-blue>=0.2.1",
2929
"pyyaml>=6.0.1",
30-
"uv>=0.4.17",
30+
"uv>=0.8",
3131
]
3232

3333
[build-system]
@@ -38,7 +38,11 @@ build-backend = "hatchling.build"
3838
packse = "packse.cli:entrypoint"
3939

4040
[project.optional-dependencies]
41-
index = ["pypiserver>=2.0.1"]
41+
index = [
42+
"fastapi>=0.116.1",
43+
"starlette>=0.47.3",
44+
"uvicorn>=0.35.0",
45+
]
4246
serve = ["packse[index]", "watchfiles>=0.21.0"]
4347

4448
[tool.uv]

0 commit comments

Comments
 (0)