Skip to content

Commit f18c332

Browse files
Merge branch 'main' into python-typings
2 parents f3ca9f1 + 402b879 commit f18c332

File tree

9 files changed

+124
-78
lines changed

9 files changed

+124
-78
lines changed

.github/workflows/CI.yml

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This file is autogenerated by maturin v1.10.2
1+
# This file is autogenerated by maturin v1.11.5
22
# To update, run
33
#
44
# maturin generate-ci --pytest github
@@ -37,8 +37,8 @@ jobs:
3737
- runner: ubuntu-22.04
3838
target: ppc64le
3939
steps:
40-
- uses: actions/checkout@v4
41-
- uses: actions/setup-python@v5
40+
- uses: actions/checkout@v6
41+
- uses: actions/setup-python@v6
4242
with:
4343
python-version: 3.x
4444
- name: Build wheels
@@ -49,7 +49,7 @@ jobs:
4949
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
5050
manylinux: auto
5151
- name: Upload wheels
52-
uses: actions/upload-artifact@v4
52+
uses: actions/upload-artifact@v5
5353
with:
5454
name: wheels-linux-${{ matrix.platform.target }}
5555
path: dist
@@ -93,8 +93,8 @@ jobs:
9393
- runner: ubuntu-22.04
9494
target: armv7
9595
steps:
96-
- uses: actions/checkout@v4
97-
- uses: actions/setup-python@v5
96+
- uses: actions/checkout@v6
97+
- uses: actions/setup-python@v6
9898
with:
9999
python-version: 3.x
100100
- name: Build wheels
@@ -105,7 +105,7 @@ jobs:
105105
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
106106
manylinux: musllinux_1_2
107107
- name: Upload wheels
108-
uses: actions/upload-artifact@v4
108+
uses: actions/upload-artifact@v5
109109
with:
110110
name: wheels-musllinux-${{ matrix.platform.target }}
111111
path: dist
@@ -147,27 +147,31 @@ jobs:
147147
platform:
148148
- runner: windows-latest
149149
target: x64
150+
python_arch: x64
150151
- runner: windows-latest
151152
target: x86
153+
python_arch: x86
154+
- runner: windows-11-arm
155+
target: aarch64
156+
python_arch: arm64
152157
steps:
153-
- uses: actions/checkout@v4
154-
- uses: actions/setup-python@v5
158+
- uses: actions/checkout@v6
159+
- uses: actions/setup-python@v6
155160
with:
156-
python-version: 3.x
157-
architecture: ${{ matrix.platform.target }}
161+
python-version: 3.13
162+
architecture: ${{ matrix.platform.python_arch }}
158163
- name: Build wheels
159164
uses: PyO3/maturin-action@v1
160165
with:
161166
target: ${{ matrix.platform.target }}
162167
args: --release --out dist --find-interpreter
163168
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
164169
- name: Upload wheels
165-
uses: actions/upload-artifact@v4
170+
uses: actions/upload-artifact@v5
166171
with:
167172
name: wheels-windows-${{ matrix.platform.target }}
168173
path: dist
169174
- name: pytest
170-
if: ${{ !startsWith(matrix.platform.target, 'aarch64') }}
171175
shell: bash
172176
run: |
173177
set -e
@@ -187,8 +191,8 @@ jobs:
187191
- runner: macos-latest
188192
target: aarch64
189193
steps:
190-
- uses: actions/checkout@v4
191-
- uses: actions/setup-python@v5
194+
- uses: actions/checkout@v6
195+
- uses: actions/setup-python@v6
192196
with:
193197
python-version: 3.x
194198
- name: Build wheels
@@ -198,7 +202,7 @@ jobs:
198202
args: --release --out dist --find-interpreter
199203
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
200204
- name: Upload wheels
201-
uses: actions/upload-artifact@v4
205+
uses: actions/upload-artifact@v5
202206
with:
203207
name: wheels-macos-${{ matrix.platform.target }}
204208
path: dist
@@ -214,14 +218,14 @@ jobs:
214218
sdist:
215219
runs-on: ubuntu-latest
216220
steps:
217-
- uses: actions/checkout@v4
221+
- uses: actions/checkout@v6
218222
- name: Build sdist
219223
uses: PyO3/maturin-action@v1
220224
with:
221225
command: sdist
222226
args: --out dist
223227
- name: Upload sdist
224-
uses: actions/upload-artifact@v4
228+
uses: actions/upload-artifact@v5
225229
with:
226230
name: wheels-sdist
227231
path: dist
@@ -240,14 +244,14 @@ jobs:
240244
# Used to generate artifact attestation
241245
attestations: write
242246
steps:
243-
- uses: actions/download-artifact@v4
247+
- uses: actions/download-artifact@v6
244248
- name: Generate artifact attestation
245-
uses: actions/attest-build-provenance@v2
249+
uses: actions/attest-build-provenance@v3
246250
with:
247251
subject-path: 'wheels-*/*'
252+
- name: Install uv
253+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
254+
uses: astral-sh/setup-uv@v7
248255
- name: Publish to PyPI
249256
if: ${{ startsWith(github.ref, 'refs/tags/') }}
250-
uses: PyO3/maturin-action@v1
251-
with:
252-
command: upload
253-
args: --non-interactive --skip-existing wheels-*/*
257+
run: uv publish 'wheels-*/*'

Cargo.lock

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "python-urlpattern"
3-
version = "0.1.6"
3+
version = "0.1.7"
44
authors = ["방성범 (Bang Seongbeom) <bangseongbeom@gmail.com>"]
55
edition = "2024"
66
description = "An implementation of the URL Pattern Standard for Python written in Rust."
@@ -15,4 +15,4 @@ crate-type = ["cdylib"]
1515

1616
[dependencies]
1717
pyo3 = "0.27.2"
18-
deno_urlpattern = { package = "urlpattern", version = "0.4.2" }
18+
deno_urlpattern = { package = "urlpattern", version = "0.5.2" }

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ The URL Pattern Standard is a web standard for URL pattern matching. It is usefu
1313

1414
It's a thin wrapper of [denoland/rust-urlpattern](https://github.com/denoland/rust-urlpattern) with [PyO3](https://github.com/PyO3/pyo3) + [Maturin](https://github.com/PyO3/maturin).
1515

16+
The naming conventions follow [the standard](https://urlpattern.spec.whatwg.org/) as closely as possible, similar to [xml.dom](https://docs.python.org/3/library/xml.dom.html).
17+
1618
## Installation
1719

1820
On Linux/UNIX or macOS:
@@ -55,6 +57,16 @@ result = pattern.exec({"pathname": "/users/4163/"})
5557
print(result["pathname"]["groups"]["id"]) # output: 4163
5658
```
5759

60+
### `baseURL`
61+
62+
```py
63+
from urlpattern import URLPattern
64+
65+
pattern = URLPattern({"pathname": "/admin/*"}, "https://example.com")
66+
print(pattern.test({"pathname": "/admin/main/"}, "https://example.com")) # output: True
67+
print(pattern.test("/admin/main/", "https://example.com")) # output: True
68+
```
69+
5870
### `ignoreCase`
5971

6072
```py
@@ -69,7 +81,7 @@ print(pattern.test("https://example.com/test")) # output: True
6981
print(pattern.test("https://example.com/TeST")) # output: True
7082
```
7183

72-
### Simple WSGI app
84+
### A simple WSGI app
7385

7486
```py
7587
from wsgiref.simple_server import make_server

pyproject.toml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["maturin>=1.10,<2.0"]
2+
requires = ["maturin>=1.11,<2.0"]
33
build-backend = "maturin"
44

55
[project]
@@ -15,14 +15,15 @@ classifiers = [
1515
"License :: OSI Approved :: MIT License",
1616
"Operating System :: OS Independent",
1717
"Programming Language :: Python :: 3",
18+
"Programming Language :: Python :: 3 :: Only",
1819
"Programming Language :: Python :: 3.8",
1920
"Programming Language :: Python :: 3.9",
2021
"Programming Language :: Python :: 3.10",
2122
"Programming Language :: Python :: 3.11",
2223
"Programming Language :: Python :: 3.12",
2324
"Programming Language :: Python :: 3.13",
2425
"Programming Language :: Python :: 3.14",
25-
"Programming Language :: Python :: 3 :: Only",
26+
"Programming Language :: Python :: Free Threading",
2627
"Programming Language :: Python :: Implementation :: CPython",
2728
"Programming Language :: Python :: Implementation :: PyPy",
2829
"Programming Language :: Rust",
@@ -35,6 +36,3 @@ dynamic = ["version"]
3536
Homepage = "https://github.com/urlpattern/python-urlpattern"
3637
Repository = "https://github.com/urlpattern/python-urlpattern.git"
3738
Issues = "https://github.com/urlpattern/python-urlpattern/issues"
38-
39-
[tool.maturin]
40-
features = ["pyo3/extension-module"]

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ impl From<deno_urlpattern::Error> for Error {
353353
}
354354

355355
/// A Python module implemented in Rust.
356-
#[pymodule]
356+
#[pymodule(gil_used = false)]
357357
mod urlpattern {
358358
#[pymodule_export]
359359
use super::UrlPattern;

tests/test_lib.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,17 @@ def test(entry):
4646

4747
if isinstance(entry.get("expected_match"), dict):
4848
result = pattern.exec(*entry["inputs"])
49-
assert result
5049

5150
for key in entry["expected_match"]:
5251
assert result[key] == entry["expected_match"][key]
5352

53+
else:
54+
result = pattern.exec(*entry["inputs"])
55+
assert result is None
56+
5457
if "exactly_empty_components" in entry:
5558
result = pattern.exec(*entry["inputs"])
5659

5760
for component in entry["exactly_empty_components"]:
5861
if result:
59-
assert result[component]["groups"] == {}
62+
assert result[component]["groups"] == {}

tests/urlpatterntestdata.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3108,5 +3108,15 @@
31083108
"hostname": { "input": "www.example.com", "groups": {} },
31093109
"pathname": { "input": "/path/with/x", "groups": { "0": "path/with/x" } }
31103110
}
3111+
},
3112+
{
3113+
"pattern": [{ "hostname": ":domain(.*)" }],
3114+
"inputs": [{ "hostname": "localhost" }],
3115+
"expected_obj": {
3116+
"hostname": ":domain(.*)"
3117+
},
3118+
"expected_match": {
3119+
"hostname": { "input": "localhost", "groups": { "domain" : "localhost"} }
3120+
}
31113121
}
31123122
]

0 commit comments

Comments
 (0)