Skip to content

Commit e3762b7

Browse files
committed
build: support uv.lock
1 parent 1b87b47 commit e3762b7

File tree

10 files changed

+2133
-382
lines changed

10 files changed

+2133
-382
lines changed

.github/workflows/tox_matrix.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,12 @@ jobs:
1515
with:
1616
python-version: ${{ matrix.python-version }}
1717
cache: 'pip' # caching pip dependencies
18-
cache-dependency-path: |
19-
requirements/requirements*.txt
20-
requirements*.txt
2118
- name: Install requirements
2219
run: |
23-
pip install wheel
24-
pip install tox
25-
pip install -r requirements-dev.txt
20+
pip install uv
2621
env:
2722
PIP_EXTRA_INDEX_URL: ${{vars.PIP_EXTRA_INDEX_URL}}
2823
- name: Run tox
29-
run: tox -e py -vvv
24+
run: uv run --group tox --with tox-uv --no-dev tox run -e py -vvv --runner uv-venv-lock-runner
3025
env:
3126
PIP_EXTRA_INDEX_URL: ${{vars.PIP_EXTRA_INDEX_URL}}

Dockerfile

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,39 @@
11
FROM python:3.11-slim AS base_image
22

33
FROM base_image AS builder
4-
RUN apt update -y && apt install -y npm
5-
RUN python -m pip install pip --upgrade && \
6-
pip install --upgrade setuptools && \
7-
pip install wheel build
4+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
5+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
6+
apt update -y && apt install --no-install-recommends -y npm
87
COPY getmarcapi /src/getmarcapi/
98
COPY src /src/src/
10-
COPY pyproject.toml README.rst README.md setup.py MANIFEST.in requirements.txt /src/
119
WORKDIR /src
1210
COPY package.json package-lock.json webpack.config.js ./
13-
RUN npm install
11+
RUN --mount=type=cache,target=/root/.npm npm install
12+
RUN npm run env -- webpack --output-path=/output
1413

14+
#
1515
ARG PIP_INDEX_URL
1616
ARG PIP_EXTRA_INDEX_URL
17-
COPY requirements.txt ./requirements.txt
18-
RUN pip wheel --wheel-dir=/wheels -r /src/requirements.txt
19-
RUN python -m build --wheel --outdir /wheels
17+
COPY pyproject.toml uv.lock README.rst README.md setup.py MANIFEST.in /src/
18+
RUN python -m pip install --disable-pip-version-check uv && \
19+
uv build --wheel --out-dir /wheels
2020

2121
FROM base_image
22-
2322
COPY --from=builder /wheels/*.whl /wheels/
24-
COPY requirements.txt ./requirements.txt
25-
RUN pip install --find-links=/wheels --no-index -r requirements.txt
26-
RUN pip install --find-links=/wheels --no-index getmarcapi
27-
EXPOSE 5000
2823
WORKDIR /app
24+
COPY pyproject.toml uv.lock README.rst /app/
25+
ARG PIP_INDEX_URL
26+
ARG UV_INDEX_URL
27+
ARG UV_CACHE_DIR=/.cache/uv
28+
ARG UV_EXTRA_INDEX_URL
29+
RUN --mount=type=cache,target=${UV_CACHE_DIR} \
30+
python -m venv uv && \
31+
./uv/bin/pip install --disable-pip-version-check uv && \
32+
./uv/bin/uv sync --group deploy --no-dev --no-editable --no-install-project --find-links=/wheels && \
33+
./uv/bin/uv pip install --find-links=/wheels --no-index getmarcapi --no-deps
34+
EXPOSE 5000
2935
COPY api.cfg /app/settings.cfg
3036
ENV GETMARCAPI_SETTINGS=/app/settings.cfg
31-
RUN python -m getmarcapi --check
32-
CMD gunicorn getmarcapi.app:app --bind 0.0.0.0:5000 --log-level=debug
37+
RUN ./.venv/bin/python -m getmarcapi --check
38+
CMD ./.venv/bin/gunicorn getmarcapi.app:app --bind 0.0.0.0:5000 --log-level=debug
3339

pyproject.toml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,37 @@ dependencies = [
1010
'uiucprescon.getmarc2>=0.1.3',
1111
'typing-extensions;python_version<"3.8"'
1212
]
13+
requires-python = ">= 3.9"
1314
readme = "README.rst"
14-
license = {text = "University of Illinois/NCSA Open Source License"}
15+
license = "NCSA"
1516
authors = [
1617
{name = "University Library at The University of Illinois at Urbana Champaign: Preservation Services", email = "[email protected]"},
1718
]
1819
maintainers = [
1920
{name = "Henry Borchers", email = "[email protected]"}
2021
]
2122
description = "Provide MARC XML data"
23+
[dependency-groups]
24+
deploy = ['gunicorn', 'python-dotenv']
25+
test = ['pytest']
26+
tox = ["tox"]
27+
publish = ["twine"]
28+
docs = ["sphinx", "sphinxcontrib.spelling"]
29+
dev = [
30+
"bandit",
31+
"coverage",
32+
"flake8",
33+
"lxml-stubs",
34+
"mypy",
35+
"paramiko",
36+
"pydocstyle",
37+
"pylint",
38+
{include-group = "docs"},
39+
{include-group = "publish"},
40+
{include-group = "test"},
41+
{include-group = "tox"},
42+
]
43+
ci = ["pysonar", {include-group = "dev"}]
2244

2345
[project.urls]
2446
Download = "https://github.com/UIUCLibrary/"
@@ -40,3 +62,15 @@ testpaths = [
4062
"tests"
4163
]
4264
junit_family="xunit2"
65+
66+
[[tool.uv.index]]
67+
url = "https://pypi.org/simple"
68+
default = true
69+
70+
[[tool.uv.index]]
71+
name = "uiuc_prescon_python"
72+
url = "https://nexus.library.illinois.edu/repository/uiuc_prescon_python/simple"
73+
explicit = true
74+
75+
[tool.uv.sources]
76+
"uiucprescon-getmarc2" = {index="uiuc_prescon_python"}

0 commit comments

Comments
 (0)