-
Notifications
You must be signed in to change notification settings - Fork 1
Migrate Python CLI template to uv #21
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
jonavellecuerdo
wants to merge
8
commits into
main
Choose a base branch
from
IN-1425-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.
+1,040
−853
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
71a252b
Application build, test, and lint with uv
ghukill 4d4638d
Update dependencies and add uv script section
ghukill e596837
Update docker image build and dependencies
ghukill 8331067
Run CI for pushes to branches with PRs
ghukill ca733ec
Update dependencies
jonavellecuerdo 7d37d6b
Remove uv.lock
jonavellecuerdo 6d1c871
Address comments in PR #21
jonavellecuerdo 086b4a1
Update README
jonavellecuerdo 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 |
|---|---|---|
| @@ -1,7 +1,10 @@ | ||
| name: CI | ||
| on: push | ||
| on: | ||
| pull_request: | ||
| paths-ignore: | ||
| - '.github/**' | ||
| jobs: | ||
| test: | ||
| uses: mitlibraries/.github/.github/workflows/python-shared-test.yml@main | ||
| uses: mitlibraries/.github/.github/workflows/python-uv-shared-test.yml@main | ||
| lint: | ||
| uses: mitlibraries/.github/.github/workflows/python-shared-lint.yml@main | ||
| uses: mitlibraries/.github/.github/workflows/python-uv-shared-lint.yml@main |
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,29 +1,29 @@ | ||
| default_language_version: | ||
| python: python3.12 # set for project python version | ||
| python: python3.12 | ||
| repos: | ||
| - repo: local | ||
| hooks: | ||
| - id: black-apply | ||
| name: black-apply | ||
| entry: pipenv run black | ||
| entry: uv run black | ||
| language: system | ||
| pass_filenames: true | ||
| types: ["python"] | ||
| - id: mypy | ||
| name: mypy | ||
| entry: pipenv run mypy | ||
| entry: uv run mypy | ||
| language: system | ||
| pass_filenames: true | ||
| types: ["python"] | ||
| exclude: "tests/" | ||
| - id: ruff-apply | ||
| name: ruff-apply | ||
| entry: pipenv run ruff check --fix | ||
| entry: uv run ruff check --fix | ||
| language: system | ||
| pass_filenames: true | ||
| types: ["python"] | ||
| - id: pip-audit | ||
| name: pip-audit | ||
| entry: pipenv run pip-audit | ||
| entry: uv run pip-audit | ||
| language: system | ||
| pass_filenames: false |
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,12 +1,21 @@ | ||
| FROM python:3.12-slim as build | ||
| FROM python:3.13-slim | ||
|
|
||
| RUN apt-get update && \ | ||
| apt-get install -y --no-install-recommends git ca-certificates && \ | ||
| rm -rf /var/lib/apt/lists/* | ||
|
|
||
| COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv | ||
| ENV UV_SYSTEM_PYTHON=1 | ||
|
|
||
| WORKDIR /app | ||
| COPY . . | ||
|
|
||
| RUN pip install --no-cache-dir --upgrade pip pipenv | ||
| # Copy project metadata | ||
| COPY pyproject.toml uv.lock* ./ | ||
|
|
||
| RUN apt-get update && apt-get upgrade -y && apt-get install -y git | ||
| # Copy CLI application | ||
| COPY my_app ./my_app | ||
|
|
||
| COPY Pipfile* / | ||
| RUN pipenv install | ||
| # Install package into the system Python environment | ||
| RUN uv pip install --system . | ||
|
|
||
| ENTRYPOINT ["pipenv", "run", "my_app"] | ||
| ENTRYPOINT ["my-app"] |
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 was deleted.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to be complicated to discuss I fear in comments, but will try. Happy to realtime chat on this if helpful.
If this is related to the README update for how to run the app, my proposal was just
my-app. This would work becausemy-appis built byuvas an entrypoint script here in thepyproject.toml. It would work without thisMakefiecommand.If possible, I'm feeling like we might benefit from leaning into those
uventrypoint scripts where possible. You can see an example of that in the timdex-embeddings CLI here where theDockerfileis calling thatuventrypoint script directly. Nothing else.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see! How about:
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me! I think it's implied that one needs to operate from within the virtual environment, but I can see how technically
pipenvdidn't explicitly require that (kind of threw you into the venv at time of invocation).Alternately, to lean into normalizing we should always be in a venv:
But your call! Both work for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Precisely! See the latest commit, which applies your suggestion above.