Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate from poetry to uv #43

Merged
merged 24 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7635f03
convert poetry toml to uv toml using pdm build backend
rbavery Oct 31, 2024
e19f4b5
correct all commands to use currently active env based on which pytho…
rbavery Oct 31, 2024
26b5705
add lockfile, test precommit with relaxed python version to accomodat…
rbavery Oct 31, 2024
6d32293
remove poetry lock
rbavery Oct 31, 2024
1ae1242
check npm versions in CI, reset before npm run format-markdown
rbavery Nov 1, 2024
634bf2b
gitignore reqs generated from make
rbavery Nov 1, 2024
305e40c
poetry>uv in actions
rbavery Nov 1, 2024
6094b22
code linting with ruff, fix makefile command, ignore line length and …
rbavery Nov 1, 2024
fe16953
update example to 1.0.0
rbavery Nov 1, 2024
5a84905
remove docker, point to uv docs, uv badge
rbavery Nov 1, 2024
15b7aae
line length fix
rbavery Nov 1, 2024
a94aaa5
fix style of uv badge and remove github pages badge
rbavery Nov 1, 2024
8471a49
ignore line length for certain lists, remove remove command
rbavery Nov 5, 2024
d7278bf
make format
rbavery Nov 5, 2024
2d3af0d
Merge branch 'main' into migrate-to-uv
rbavery Nov 5, 2024
277b1d7
fix if condition on linux, linitng
rbavery Nov 5, 2024
a8cf7ca
don't run setup on every command in makefile
rbavery Nov 5, 2024
2a5963d
disable dependabot
rbavery Nov 5, 2024
e15f0ad
temporarily remove dependabot
rbavery Nov 5, 2024
9c18aba
update setup command, add back dependabot
rbavery Nov 11, 2024
34fbf3d
merge main with make lint-all
rbavery Nov 11, 2024
021d0a2
add backticks, remove extra | None
rbavery Nov 11, 2024
eb2e5c6
remove noqa, make format
rbavery Nov 12, 2024
9752f5e
backticks, use Optional instead of | None
rbavery Nov 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 0 additions & 39 deletions .dockerignore

This file was deleted.

8 changes: 4 additions & 4 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ jobs:
uses: actions/[email protected]
with:
python-version: "3.10"
- name: Install poetry
run: make poetry-install
- name: Install uv
run: make setup
- name: Publish stac-model to PyPI
run: |
poetry build
poetry publish --username __token__ --password ${{ secrets.PYPI_SECRET }}
uv build
uv publish --username __token__ --password ${{ secrets.PYPI_SECRET }}
6 changes: 3 additions & 3 deletions .github/workflows/stac-model.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install poetry
run: make poetry-install
- name: Install uv
run: make setup

- name: Set up cache
uses: actions/[email protected]
with:
path: .venv
key: venv-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('poetry.lock') }}
key: venv-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('uv.lock') }}
- name: Install dependencies
run: make install-dev

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ jobs:
- uses: actions/checkout@v4
- run: |
npm install
npm list
rbavery marked this conversation as resolved.
Show resolved Hide resolved
npm test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
requirements*.txt

### ArchLinuxPackages ###
*.tar
*.tar.*
Expand Down
3 changes: 1 addition & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
default_language_version:
python: python3.10
python: python3

default_stages: [commit, push]

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
Expand Down
21 changes: 12 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,26 @@

## Project setup

1. If you don't have `Poetry` installed run:
1. If you don't have `uv` installed run:

```bash
make poetry-install
make setup
```

> This installs Poetry as a [standalone application][poetry-install]. <br>
> For more details, see also the [Poetry Documentation][poetry-docs]. <br>
> If you prefer, you can simply install it inside your virtual environment.
> This installs `uv` as a [standalone application][uv-install]. <br>
> For more details, see also the [`uv` documentation][uv-docs]. <br>

2. Initialize project dependencies with poetry and install `pre-commit` hooks:
2. Initialize project dependencies with `uv` and install `pre-commit` hooks:

```bash
make install-dev
make pre-commit-install
```

This will install project dependencies into the currently active environment. If you would like to
use uv's default behavior of managing a project-scoped environment, use `uv` commands directly to
rbavery marked this conversation as resolved.
Show resolved Hide resolved
install dependencies. `uv sync` will install dependencies and dev dependencies in `.venv` and update the `uv.lock`.

## PR submission

Before submitting your code please do the following steps:
Expand Down Expand Up @@ -85,7 +88,7 @@ git push -u origin your-branch
### Building a new version of `stac-model`

- Apply any relevant changes and `CHANGELOG.md` entries in a PR that modifies `stac-model`.
- Bump the version with `poetry version <version>`.
- Bump the version with `bumpversion bump <version>`.
- You can pass the new version explicitly, or a rule such as `major`, `minor`, or `patch`. <br>
For more details, refer to the [Semantic Versions][semver] standard;
- Once CI validation succeeded, merge the corresponding PR branch.
Expand All @@ -110,6 +113,6 @@ You can also share how the ML Model extension does or does
not serve your needs with us in the GitHub Discussions or raise
Issues for bugs.

[poetry-install]: https://github.com/python-poetry/install.python-poetry.org
[poetry-docs]: https://python-poetry.org/docs/
[uv-install]: https://docs.astral.sh/uv/getting-started/installation/
[uv-docs]: https://docs.astral.sh/uv/
[semver]: https://semver.org/
85 changes: 31 additions & 54 deletions Makefile
rbavery marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,58 +1,43 @@
#* Variables
SHELL ?= /usr/bin/env bash
PYTHON ?= python
PYTHONPATH := `pwd`
POETRY ?= poetry
ACTIVEPYTHON = $(shell which python)

#* Poetry
.PHONY: poetry-install
poetry-install:
curl -sSL https://install.python-poetry.org | $(PYTHON) -

.PHONY: poetry-remove
poetry-remove:
curl -sSL https://install.python-poetry.org | $(PYTHON) - --uninstall

.PHONY: poetry-plugins
poetry-plugins:
$(POETRY) self add poetry-plugin-up

.PHONY: poetry-env
poetry-env:
$(POETRY) config virtualenvs.in-project true
#* UV
.PHONY: setup
setup:
which uv >/dev/null || (curl -LsSf https://astral.sh/uv/install.sh | sh)

.PHONY: publish
publish:
$(POETRY) publish --build
uv publish --build

#* Installation
.PHONY: install
install: poetry-env
$(POETRY) lock -n && poetry export --without-hashes > requirements-lock.txt
$(POETRY) install -n
-poetry run mypy --install-types --non-interactive ./
install: setup
uv export --format requirements-txt -o requirements.txt --no-dev
uv pip install --python $(ACTIVEPYTHON) -r requirements.txt

.PHONY: install-dev
install-dev: poetry-env install
$(POETRY) install -n --with dev
install-dev: setup
uv export --format requirements-txt -o requirements-dev.txt
uv pip install --python $(ACTIVEPYTHON) -r requirements-dev.txt

.PHONY: pre-commit-install
pre-commit-install:
$(POETRY) run pre-commit install

pre-commit-install: setup
uv run --python $(ACTIVEPYTHON) pre-commit install

#* Formatters
.PHONY: codestyle
codestyle:
$(POETRY) run ruff format --config=pyproject.toml stac_model tests
codestyle: setup
uv run --python $(ACTIVEPYTHON) ruff format --config=pyproject.toml stac_model tests

.PHONY: format
format: codestyle

#* Linting
.PHONY: test
test:
PYTHONPATH=$(PYTHONPATH) poetry run pytest -c pyproject.toml --cov-report=html --cov=stac_model tests/
test: setup
uv run --python $(ACTIVEPYTHON) pytest -c pyproject.toml --cov-report=html --cov=stac_model tests/

.PHONY: check
check: check-examples check-markdown check-lint check-mypy check-safety check-citation
Expand All @@ -61,37 +46,28 @@ check: check-examples check-markdown check-lint check-mypy check-safety check-ci
check-all: check

.PHONY: mypy
mypy:
$(POETRY) run mypy --config-file pyproject.toml ./
mypy: setup
uv run --python $(ACTIVEPYTHON) mypy --config-file pyproject.toml ./

.PHONY: check-mypy
check-mypy: mypy

# NOTE:
# purposely running with docker rather than python package due to conflicting dependencies
# see https://github.com/citation-file-format/cffconvert/issues/292
.PHONY: check-citation
check-citation:
docker run --rm -v $(PYTHONPATH)/CITATION.cff:/app/CITATION.cff citationcff/cffconvert --validate

.PHONY: check-safety
check-safety:
$(POETRY) check
$(POETRY) run safety check --full-report
$(POETRY) run bandit -ll --recursive stac_model tests
check-safety: setup
uv run --python $(ACTIVEPYTHON) safety check --full-report
uv run --python $(ACTIVEPYTHON) bandit -ll --recursive stac_model tests

.PHONY: lint
lint:
$(POETRY) run ruff --config=pyproject.toml ./
$(POETRY) run pydocstyle --count --config=pyproject.toml ./
$(POETRY) run pydoclint --config=pyproject.toml ./
lint: setup
uv run --python $(ACTIVEPYTHON) ruff check --fix --config=pyproject.toml ./

.PHONY: check-lint
check-lint: lint
uv run --python $(ACTIVEPYTHON) ruff check --config=pyproject.toml ./

.PHONY: format-lint
format-lint:
$(POETRY) run ruff --config=pyproject.toml --fix ./
format-lint: lint
ruff format --config=pyproject.toml ./

.PHONY: install-npm
install-npm:
Expand Down Expand Up @@ -120,8 +96,9 @@ $(addprefix fix-, $(FORMATTERS)): fix-%: format-%
lint-all: lint mypy check-safety check-markdown

.PHONY: update-dev-deps
update-dev-deps:
$(POETRY) up --only=dev-dependencies --latest
update-dev-deps: setup
uv export --only-dev --format requirements-txt -o requirements-only-dev.txt
uv pip install --python $(ACTIVEPYTHON) -r requirements-only-dev.txt

#* Cleaning
.PHONY: pycache-remove
Expand Down
14 changes: 5 additions & 9 deletions README_STAC_MODEL.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
[![PyPI Release][bp3]][bp2]
[![Repository][bscm1]][bp4]
[![Releases][bscm2]][bp5]
[![Docs][bdoc1]][bdoc2]

[![Contributions Welcome][bp8]][bp9]

[![Poetry][bp11]][bp12]
[![uv][bp11]][bp12]
[![Pre-commit][bp15]][bp16]
[![Semantic versions][blic3]][bp5]
[![Pipelines][bscm6]][bscm7]
Expand All @@ -30,10 +29,10 @@ _A PydanticV2 and PySTAC validation and serialization library for the STAC ML Mo
pip install -U stac-model
```

or install with `Poetry`:
or install with uv:

```shell
poetry add stac-model
uv add stac-model
```
Then you can run

Expand Down Expand Up @@ -73,8 +72,8 @@ See [LICENSE][blic2] for more details.
[bp7]: https://kutt.it/7fYqQl
[bp8]: https://img.shields.io/static/v1.svg?label=Contributions&message=Welcome&color=0059b3&style=for-the-badge
[bp9]: https://github.com/stac-extensions/mlm/blob/main/CONTRIBUTING.md
[bp11]: https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json&style=for-the-badge
[bp12]: https://python-poetry.org/
[bp11]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json&style=for-the-badge
[bp12]: https://docs.astral.sh/uv/

[bp15]: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white&style=for-the-badge
[bp16]: https://github.com/stac-extensions/mlm/blob/main/.pre-commit-config.yaml
Expand All @@ -95,6 +94,3 @@ See [LICENSE][blic2] for more details.
[hub6]: https://docs.github.com/en/code-security/dependabot
[hub8]: https://github.com/stac-extensions/mlm/blob/main/.github/release-drafter.yml
[hub9]: https://github.com/stac-extensions/mlm/blob/main/.github/.stale.yml

[bdoc1]: https://img.shields.io/badge/docs-github%20pages-0a507a?style=for-the-badge
[bdoc2]: https://github.com/stac-extensions/mlm/blob/main/README_STAC_MODEL.md
25 changes: 0 additions & 25 deletions docker/Dockerfile

This file was deleted.

47 changes: 0 additions & 47 deletions docker/README.md

This file was deleted.

Loading