-
Notifications
You must be signed in to change notification settings - Fork 0
Migrate to uv #5
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
Open
figi44
wants to merge
6
commits into
main
Choose a base branch
from
uv
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| # Git and version control | ||
| .git | ||
| .gitignore | ||
|
|
||
| # Virtual environments | ||
| .venv | ||
|
|
||
| # Python cache and bytecode | ||
| __pycache__ | ||
| *.py[cod] | ||
| *$py.class | ||
| *.so | ||
| *.egg-info | ||
| *.egg | ||
|
|
||
| # Testing | ||
| tests | ||
| .pytest_cache | ||
| .coverage | ||
| .coverage.* | ||
| htmlcov | ||
| .tox | ||
| .nox | ||
| .hypothesis | ||
|
|
||
| # Development tools and docs | ||
| Makefile | ||
| .pre-commit-config.yaml | ||
| CHANGELOG.md | ||
| README.md | ||
|
|
||
| # IDE and editor files | ||
| .vscode | ||
| .idea | ||
| *.swp | ||
| *.swo | ||
| *~ | ||
|
|
||
| # OS files | ||
| .DS_Store | ||
| Thumbs.db | ||
|
|
||
| # Build artifacts | ||
| build | ||
| dist | ||
| *.whl | ||
| *.tar.gz | ||
|
|
||
| # Linting and type checking caches | ||
| .ruff_cache | ||
| .mypy_cache | ||
| .dmypy.json | ||
|
|
||
| # Misc | ||
| *.bak | ||
| .cache | ||
|
|
||
| # Docker files | ||
| Dockerfile | ||
| .dockerignore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,22 @@ | ||
| # syntax=docker/dockerfile:1 | ||
| FROM python:3.11-slim-bullseye | ||
| FROM ghcr.io/astral-sh/uv:python3.13-trixie-slim | ||
|
|
||
| RUN rm -f /etc/apt/apt.conf.d/docker-clean; \ | ||
| echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache | ||
| ENV UV_NO_DEV=1 | ||
|
|
||
| RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ | ||
| --mount=type=cache,target=/var/lib/apt,sharing=locked \ | ||
| apt-get update -y && apt-get upgrade -y | ||
| WORKDIR /app | ||
|
|
||
| WORKDIR /CHANGME-component-name | ||
| ADD LICENSE.txt requirements.txt ./ | ||
| ADD CHANGEME-module-name ./CHANGEME-module-name/ | ||
| ADD pyproject.toml ./ | ||
| RUN --mount=type=cache,target=/root/.cache/pip pip3 install -r requirements.txt . | ||
| # Install dependencies | ||
| RUN --mount=type=cache,target=/root/.cache/uv \ | ||
| --mount=type=bind,source=uv.lock,target=uv.lock \ | ||
| --mount=type=bind,source=pyproject.toml,target=pyproject.toml \ | ||
| uv sync --frozen --no-install-project | ||
|
|
||
| # Change as required, eg | ||
| # CMD ["gunicorn", "-w", "2", "-b", "0.0.0.0", "-k", "uvicorn.workers.UvicornWorker", "--log-level", "debug", "mymodule.main:app"] | ||
| CMD python -m my.module | ||
| # Copy project files | ||
| COPY . /app | ||
|
|
||
| # Sync the project | ||
| RUN --mount=type=cache,target=/root/.cache/uv \ | ||
| uv sync --frozen | ||
|
|
||
| # Change as required | ||
| CMD ["uv", "run", "--no-sync", "python", "-m", "my.module"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,58 +1,56 @@ | ||
| .PHONY: dockerbuild dockerpush test testonce ruff black lint isort pre-commit-check requirements-update requirements setup | ||
| VERSION ?= latest | ||
| IMAGENAME = CHANGEME | ||
| DOCKERREPO ?= public.ecr.aws/n1b3o1k2/ukeodhp | ||
| DOCKERREPO ?= public.ecr.aws/eodh | ||
| uv-run ?= uv run --no-sync | ||
|
|
||
| .PHONY: dockerbuild | ||
| dockerbuild: | ||
| DOCKER_BUILDKIT=1 docker build -t ${IMAGENAME}:${VERSION} . | ||
|
|
||
| dockerpush: dockerbuild testdocker | ||
| .PHONY: dockerpush | ||
| dockerpush: dockerbuild | ||
| docker tag ${IMAGENAME}:${VERSION} ${DOCKERREPO}/${IMAGENAME}:${VERSION} | ||
| docker push ${DOCKERREPO}/${IMAGENAME}:${VERSION} | ||
|
|
||
| .PHONY: test | ||
| test: | ||
| ./venv/bin/ptw CHANGEME-test-package-names | ||
| ${uv-run} ptw CHANGEME-test-package-names | ||
|
|
||
| .PHONY: testonce | ||
| testonce: | ||
| ./venv/bin/pytest | ||
| ${uv-run} pytest | ||
|
|
||
| ruff: | ||
| ./venv/bin/ruff check . | ||
|
|
||
| black: | ||
| ./venv/bin/black . | ||
|
|
||
| isort: | ||
| ./venv/bin/isort . --profile black | ||
|
|
||
| validate-pyproject: | ||
| validate-pyproject pyproject.toml | ||
|
|
||
| lint: ruff black isort validate-pyproject | ||
|
|
||
| requirements.txt: venv pyproject.toml | ||
| ./venv/bin/pip-compile | ||
| .git/hooks/pre-commit: | ||
| ${uv-run} pre-commit install | ||
| curl -o .pre-commit-config.yaml https://raw.githubusercontent.com/EO-DataHub/github-actions/main/.pre-commit-config-python.yaml | ||
|
|
||
| requirements-dev.txt: venv pyproject.toml | ||
| ./venv/bin/pip-compile --extra dev -o requirements-dev.txt | ||
| .PHONY: setup | ||
| setup: update .git/hooks/pre-commit | ||
|
|
||
| requirements: requirements.txt requirements-dev.txt | ||
| .PHONY: pre-commit | ||
| pre-commit: | ||
| ${uv-run} pre-commit | ||
|
|
||
| requirements-update: venv | ||
| ./venv/bin/pip-compile -U | ||
| ./venv/bin/pip-compile --extra dev -o requirements-dev.txt -U | ||
| .PHONY: pre-commit-all | ||
| pre-commit-all: | ||
| ${uv-run} pre-commit run --all-files | ||
|
|
||
| venv: | ||
| virtualenv -p python3.11 venv | ||
| ./venv/bin/python -m ensurepip -U | ||
| ./venv/bin/pip3 install pip-tools | ||
| .PHONY: check | ||
| check: | ||
| ${uv-run} ruff check | ||
| ${uv-run} ruff format --check --diff | ||
| ${uv-run} pyright | ||
| ${uv-run} validate-pyproject pyproject.toml | ||
|
|
||
| .make-venv-installed: venv requirements.txt requirements-dev.txt | ||
| ./venv/bin/pip3 install -r requirements.txt -r requirements-dev.txt | ||
| touch .make-venv-installed | ||
| .PHONY: format | ||
| format: | ||
| ${uv-run} ruff check --fix | ||
| ${uv-run} ruff format | ||
|
|
||
| .git/hooks/pre-commit: | ||
| ./venv/bin/pre-commit install | ||
| curl -o .pre-commit-config.yaml https://raw.githubusercontent.com/EO-DataHub/github-actions/main/.pre-commit-config-python.yaml | ||
| .PHONY: install | ||
| install: | ||
| uv sync --frozen | ||
|
|
||
| setup: venv requirements .make-venv-installed .git/hooks/pre-commit | ||
| .PHONY: update | ||
| update: | ||
| uv sync |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| def main() -> None: | ||
| print("Hello, World!") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.