swadhinbiswas

[email protected]
2026-07-25 16:20:34 +0600 committed NaN years ago
dfed6c2
commit dfed6c2
4 files changed
+32 -38
▼.github/workflows/ci.yml
+6-8
83
83
steps:
84
84
- uses: actions/checkout@v4
85
85
86
- - name: Install Python
87
- uses: actions/setup-python@v5
86
+ - name: Install uv + Python
87
+ uses: astral-sh/setup-uv@v5
88
88
with:
89
89
python-version: "3.12"
90
-
91
- - name: Install dependencies
92
- run: |
93
- python -m pip install --upgrade pip
94
- pip install pytest httpx pydantic typing_extensions uv maturin
90
+ enable-cache: true
95
91
96
92
- name: Build and install justapi
97
93
run: |
94
+ uv venv
95
+ uv pip install pytest httpx pydantic typing_extensions
98
96
maturin develop -m crates/justapi-py/Cargo.toml
99
97
100
98
- name: Run pytest
101
99
run: |
102
- PYTHONPATH=./crates/justapi-py/python pytest
100
+ uv run -- PYTHONPATH=./crates/justapi-py/python pytest
103
101
104
102
pytest-freethreaded:
105
103
name: Pytest (free-threaded / no GIL)
106
104
▼.github/workflows/publish.yml
+10-7
64
64
target: x64
65
65
steps:
66
66
- uses: actions/checkout@v4
67
- - uses: actions/setup-python@v5
67
+ - uses: astral-sh/setup-uv@v5
68
68
with:
69
69
python-version: '3.12'
70
+ enable-cache: true
71
+ cache-dependency-glob: crates/justapi-py/pyproject.toml
70
72
- uses: PyO3/maturin-action@v1
71
73
with:
72
74
target: ${{ matrix.target }}
75
77
- name: Smoke test
76
78
shell: bash
77
79
run: |
78
- python -m pip install dist/*.whl
80
+ uv pip install dist/*.whl
79
81
python -c "import justapi; print(justapi.__version__)"
80
82
- uses: actions/upload-artifact@v4
81
83
with:
90
92
permissions:
91
93
id-token: write
92
94
steps:
95
+ - uses: actions/checkout@v4
96
+ - uses: astral-sh/setup-uv@v5
97
+ with:
98
+ python-version: '3.12'
93
99
- uses: actions/download-artifact@v4
94
100
with:
95
101
pattern: wheels-*
96
102
merge-multiple: true
97
103
path: dist
98
- - uses: pypa/gh-action-pypa-publish@release/v1
99
- with:
100
- packages-dir: dist/
101
- skip-existing: true
102
- verbose: true
104
+ - name: Publish
105
+ run: uv publish --package-dir crates/justapi-py --trusted-publishing always --verbose
103
106
▼.github/workflows/wheels.yml
+10-10
72
72
73
73
steps:
74
74
- uses: actions/checkout@v4
75
- - uses: actions/setup-python@v5
75
+ - uses: astral-sh/setup-uv@v5
76
76
with:
77
77
python-version: '3.12'
78
-
78
+ enable-cache: true
79
+ cache-dependency-glob: crates/justapi-py/pyproject.toml
79
80
- name: Build wheels via Maturin
80
81
uses: PyO3/maturin-action@v1
81
82
with:
82
83
target: ${{ matrix.target }}
83
84
args: --release --out dist ${{ matrix.args }}
84
85
manifest-path: crates/justapi-py/Cargo.toml
85
-
86
86
- name: Install wheel & test
87
87
shell: bash
88
88
run: |
89
- pip install dist/*.whl --force-reinstall
90
- pip install pytest
89
+ uv pip install dist/*.whl pytest
91
90
python -m pytest crates/justapi-py/tests/ -v --tb=short
92
-
93
91
- name: Upload Wheels
94
92
uses: actions/upload-artifact@v4
95
93
with:
105
103
permissions:
106
104
id-token: write
107
105
steps:
106
+ - uses: actions/checkout@v4
107
+ - uses: astral-sh/setup-uv@v5
108
+ with:
109
+ python-version: '3.12'
108
110
- uses: actions/download-artifact@v4
109
111
with:
110
112
pattern: wheels-*
111
113
merge-multiple: true
112
114
path: dist
113
- - uses: pypa/gh-action-pypa-publish@release/v1
114
- with:
115
- skip-existing: true
116
- verbose: true
115
+ - name: Publish
116
+ run: uv publish --package-dir crates/justapi-py --trusted-publishing always --verbose
117
117
▼Dockerfile
+6-13
1
1
# =============================================================================
2
2
# Stage 1: Build the Rust CLI binary and Python wheel
3
3
# =============================================================================
4
-# Pin base image digest for reproducible builds. Run `docker pull rust:1.75-bookworm && docker inspect --format='{{index .RepoDigests 0}}' rust:1.75-bookworm` to get the current digest.
5
4
FROM rust:1.75-bookworm AS builder
6
5
7
-# Install dependencies including python for building maturin wheels
8
6
RUN apt-get update && apt-get install -y --no-install-recommends \
9
7
libssl-dev pkg-config python3 python3-pip python3-venv \
10
8
&& rm -rf /var/lib/apt/lists/*
11
9
12
10
WORKDIR /app
13
11
14
-# Cache dependencies
15
12
COPY Cargo.toml Cargo.lock ./
16
13
COPY crates/ crates/
17
14
COPY python/ python/
18
15
19
-RUN python3 -m venv /opt/venv
16
+RUN python3 -m venv /opt/venv && \
17
+ . /opt/venv/bin/activate && \
18
+ pip install maturin==1.8.3 && \
19
+ pip install uv
20
20
ENV PATH="/opt/venv/bin:$PATH"
21
21
22
-RUN pip install maturin==1.8.3
23
-
24
-# Build the Rust CLI
25
22
RUN cargo build --release -p justapi-cli --features tls,compression
26
23
RUN strip target/release/justapi
27
24
28
-# Build the Python wheel
29
25
RUN maturin build -m crates/justapi-py/Cargo.toml --release -o wheels/
30
26
31
27
# =============================================================================
32
28
# Stage 2: Minimal runtime image with Python
33
29
# =============================================================================
34
-# Pin base image digest for reproducible builds.
35
30
FROM python:3.12-slim-bookworm
36
31
37
32
RUN apt-get update && apt-get install -y --no-install-recommends \
40
35
41
36
WORKDIR /app
42
37
43
-# Copy CLI binary
44
38
COPY --from=builder /app/target/release/justapi /usr/local/bin/justapi
45
-
46
-# Copy and install the wheel
47
39
COPY --from=builder /app/wheels /tmp/wheels
48
-RUN pip install --no-cache-dir /tmp/wheels/*.whl && rm -rf /tmp/wheels
40
+
41
+RUN pip install uv && uv pip install --system /tmp/wheels/*.whl && rm -rf /tmp/wheels
49
42
50
43
COPY demo_app.py /app/
51
44
52
45