Skip to content

Commit f87faca

Browse files
hrodmngadomski
andauthored
use uv for dependency management during development (#118)
* use uv for dependency management during development Co-authored-by: Pete Gadomski <[email protected]>
1 parent 6837658 commit f87faca

File tree

15 files changed

+2344
-89
lines changed

15 files changed

+2344
-89
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,18 @@ jobs:
3939
path: ~/conda_pkgs_dir
4040
key: ${{ runner.os }}-conda-${{ hashFiles('**/environment.yml') }}
4141
restore-keys: ${{ runner.os }}-conda-
42-
- name: Set up pip cache
43-
uses: actions/cache@v4
42+
- name: Set up uv
43+
uses: astral-sh/setup-uv@v4
4444
with:
45-
path: ~/.cache/pip
46-
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
47-
restore-keys: ${{ runner.os }}-pip-
45+
version: "0.5.*"
4846
- name: Set up Conda with Python ${{ matrix.python-version }}
4947
uses: conda-incubator/setup-miniconda@v3
5048
with:
5149
auto-update-conda: true
5250
python-version: ${{ matrix.python-version }}
5351
- name: Update Conda's environemnt
5452
run: conda env update -f environment.yml -n test
53+
- name: Install package
54+
run: uv sync
5555
- name: Execute linters and test suites
56-
run: ./scripts/cibuild
56+
run: uv run ./scripts/test

.pre-commit-config.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ repos:
88
- id: codespell
99
args: [--ignore-words=.codespellignore]
1010
types_or: [jupyter, markdown, python, shell]
11-
- repo: https://github.com/psf/black
12-
rev: 24.4.2
13-
hooks:
14-
- id: black
1511
- repo: https://github.com/pre-commit/mirrors-mypy
1612
rev: v1.10.1
1713
hooks:
@@ -20,6 +16,8 @@ repos:
2016
- click != 8.1.0
2117
- stactools
2218
- repo: https://github.com/astral-sh/ruff-pre-commit
23-
rev: v0.5.2
19+
rev: v0.8.3
2420
hooks:
2521
- id: ruff
22+
args: [ --fix ]
23+
- id: ruff-format

README-template.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,24 @@ We use [pre-commit](https://pre-commit.com/) to check any changes.
4444
To set up your development environment:
4545

4646
```shell
47-
pip install -e '.[dev]'
48-
pre-commit install
47+
uv sync
48+
uv run pre-commit install
4949
```
5050

5151
To check all files:
5252

5353
```shell
54-
pre-commit run --all-files
54+
uv run pre-commit run --all-files
5555
```
5656

5757
To run the tests:
5858

5959
```shell
60-
pytest -vv
60+
uv run pytest -vv
6161
```
6262

6363
If you've updated the STAC metadata output, update the examples:
6464

6565
```shell
66-
scripts/update-examples
66+
uv run scripts/update-examples
6767
```

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This is a template repo used for creating new packages for `stactools`.
1313
2. Change into the top-level directory of your package and run `scripts/rename`.
1414
This will update _most_ of the files in the repository with your new package name.
1515
3. Update `pyproject.toml` with your package description and such.
16-
4. Install with the development requirements (`pip install -e '.[dev]'`).
16+
4. Install with the development requirements (`uv sync`).
1717
5. Update the LICENSE with your company's information (or whomever holds the copyright).
1818
6. Edit or replace the existing functions to create stac Items and Collections
1919
for your dataset.

docker/Dockerfile

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,62 @@ FROM continuumio/miniconda3 as base
22

33
COPY environment.yml ./
44
RUN conda update conda && \
5-
conda env update -f environment.yml -n base && \
6-
conda clean -af
5+
conda env update -f environment.yml -n base && \
6+
conda clean -af
77

88

99
FROM base as dependencies
1010

11-
ENV PATH="/opt/venv/bin:$PATH"
11+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
12+
13+
ENV UV_LINK_MODE=copy \
14+
UV_COMPILE_BYTECODE=1 \
15+
UV_PYTHON_DOWNLOADS=never \
16+
UV_PYTHON=python3.12 \
17+
UV_PROJECT_ENVIRONMENT=/opt/venv \
18+
PATH="/opt/venv/bin:$PATH"
1219
WORKDIR /opt/stactools-ephemeral
1320
COPY --from=base /opt/conda /opt/conda
1421
COPY pyproject.toml ./
1522
COPY src/stactools/ephemeral/__init__.py src/stactools/ephemeral/
1623
RUN apt-get -y -q update \
17-
&& apt-get -y -q install build-essential \
18-
&& rm -rf /var/lib/apt/lists/
19-
RUN python -m venv /opt/venv
20-
RUN pip install . \
21-
&& ls /opt/venv \
22-
&& rm -r /opt/venv/lib/python3.12/site-packages/stactools/ephemeral
24+
&& apt-get -y -q install build-essential \
25+
&& rm -rf /var/lib/apt/lists/
26+
RUN uv sync --no-install-project --no-editable
2327

2428

2529
FROM dependencies as builder
2630

27-
ENV PATH="/opt/venv/bin:$PATH"
31+
ENV UV_LINK_MODE=copy \
32+
UV_COMPILE_BYTECODE=1 \
33+
UV_PYTHON_DOWNLOADS=never \
34+
UV_PYTHON=python3.12 \
35+
UV_PROJECT_ENVIRONMENT=/opt/venv \
36+
PATH="/opt/venv/bin:$PATH"
2837
WORKDIR /opt/stactools-ephemeral
2938
COPY --from=base /opt/conda /opt/conda
3039
COPY --from=dependencies /opt/venv /opt/venv
3140
COPY pyproject.toml ./
3241
COPY src ./src
33-
RUN pip install -U pip \
34-
&& pip install .
42+
RUN uv sync --no-dev --no-editable
3543
WORKDIR /
3644
RUN rm -rf /opt/stactools-ephemeral
3745
CMD [ "stac", "ephemeralcmd" ]
3846

3947

4048
FROM dependencies as dev-dependencies
4149

42-
ENV PATH="/opt/venv/bin:$PATH"
50+
ENV UV_LINK_MODE=copy \
51+
UV_COMPILE_BYTECODE=1 \
52+
UV_PYTHON_DOWNLOADS=never \
53+
UV_PYTHON=python3.12 \
54+
UV_PROJECT_ENVIRONMENT=/opt/venv \
55+
PATH="/opt/venv/bin:$PATH"
4356
WORKDIR /opt/stactools-ephemeral
4457
COPY --from=dependencies /opt/venv /opt/venv
4558
COPY pyproject.toml .
46-
RUN pip install -e '.[dev]' \
47-
&& git init
59+
RUN uv sync \
60+
&& git init
4861

4962

5063
FROM dev-dependencies as dev-builder

docker/cibuild

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
2020
--target dev-builder \
2121
.
2222
docker run --rm \
23-
--entrypoint scripts/cibuild \
24-
stactools-packages/ephemeral:dev
23+
--entrypoint uv \
24+
stactools-packages/ephemeral:dev \
25+
sync
2526
fi

docs/example.ipynb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1257,8 +1257,10 @@
12571257
],
12581258
"source": [
12591259
"from pathlib import Path\n",
1260-
"from pystac import Collection, Item\n",
1260+
"\n",
12611261
"from IPython.display import display\n",
1262+
"from pystac import Collection\n",
1263+
"\n",
12621264
"import stactools.ephemeral.stac\n",
12631265
"\n",
12641266
"root = Path().cwd().parent\n",

pyproject.toml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ classifiers = [
2121
requires-python = ">=3.9"
2222
dependencies = ["stactools>=0.4.0"]
2323

24-
[project.optional-dependencies]
24+
[dependency-groups]
2525
dev = [
26-
"black~=24.4",
2726
"codespell~=2.3",
2827
"mypy~=1.10",
2928
"pre-commit~=4.0",
@@ -42,9 +41,6 @@ Issues = "https://github.com/stactools-packages/ephemeral/issues"
4241
requires = ["setuptools", "wheel"]
4342
build-backend = "setuptools.build_meta"
4443

45-
[tool.isort]
46-
profile = "black"
47-
4844
[tool.mypy]
4945
explicit_package_bases = true
5046
namespace_packages = true
@@ -53,4 +49,4 @@ strict = true
5349
mypy_path = "src"
5450

5551
[tool.ruff]
56-
select = ["E", "F", "I"]
52+
lint.select = ["E", "F", "I"]

scripts/cibuild

Lines changed: 0 additions & 23 deletions
This file was deleted.

scripts/update

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)