Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
68 changes: 23 additions & 45 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,54 +10,32 @@ permissions:
actions: read
contents: read

env:
POETRY_VERSION: "1.6.1"
PYTHON_VERSION: "3.11"

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
id: setup-python
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: 🛎️ Checkout
uses: actions/checkout@v4

- name: Load cached Poetry installation
id: cached-poetry
uses: actions/cache@v4
with:
path: ~/.local
key: poetry-${{ runner.os }}-${{ env.POETRY_VERSION }}-${{ steps.setup-python.outputs.python-version }}
- name: Install Poetry
id: install-poetry
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
version: ${{ env.POETRY_VERSION }}
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Poetry git plugin
run: poetry self add poetry-git-version-plugin
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
- name: 📦 Install uv
uses: astral-sh/setup-uv@v4
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the meantime this setup-uv action has gotten a v5 release.

Also, by explicitly setting a python-version, you avoid having to use a .python-version file

Suggested change
uses: astral-sh/setup-uv@v4
uses: astral-sh/setup-uv@v5
with:
python-version: "3.12"

Copy link
Copy Markdown
Author

@itsmeadarsh2008 itsmeadarsh2008 Apr 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think using a .python-version uses a standard way is a better way to declare compatible python version which I can refer to anywhere in the code, if I use it explicitly, I would have edit all the places where I referred to the incompatibility whenever I had to increment the python version.

Edit: Anyways, I am good with using v5


- name: 🐍 Set up Python
uses: actions/setup-python@v5
Comment on lines +23 to +24
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need for this; uv takes care of it all :)

(I can't suggest it as a change because of the interrupted diff unfortunately)

with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Poetry Install
run: poetry install -n -v
- name: Poetry Build
run: poetry build -v

- name: Ruff
run: poetry run ruff .
- name: Black
run: poetry run black .
- name: Pytest
run: poetry run pytest
- name: Check stubs
run: poetry run python -m ziglang build generate-stubs -Dcheck-stubs=true
python-version-file: ".python-version"

- name: 🦾 Install dependencies
run: uv sync --all-extras

- name: 🔍 Lint with Ruff
run: uv run ruff check .

- name: 🖌️ Format with Black
run: uv run black --check .

- name: 🧪 Run tests
run: uv run pytest

- name: 🔎 Check stubs
run: uv run -m ziglang build generate-stubs -Dcheck-stubs=true
46 changes: 12 additions & 34 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,26 @@ permissions:
id-token: write
contents: read

env:
POETRY_VERSION: "1.6.1"
PYTHON_VERSION: "3.11"

jobs:
publish:
environment:
name: pypi
url: https://pypi.org/p/ziggy-pydust-template
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
id: setup-python
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: 🛎️ Checkout
uses: actions/checkout@v4

- name: Load cached Poetry installation
id: cached-poetry
uses: actions/cache@v4
with:
path: ~/.local
key: poetry-${{ runner.os }}-${{ env.POETRY_VERSION }}-${{ steps.setup-python.outputs.python-version }}
- name: Install Poetry
id: install-poetry
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
version: ${{ env.POETRY_VERSION }}
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Poetry git plugin
run: poetry self add poetry-git-version-plugin
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
- name: 📦 Install uv
uses: astral-sh/setup-uv@v4
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my comment above for the juicy deets:

Suggested change
uses: astral-sh/setup-uv@v4
uses: astral-sh/setup-uv@v4
with:
python-version: "3.12"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


- name: 🐍 Set up Python
uses: actions/setup-python@v5
Comment on lines +24 to +25
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this still needed?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just run uv python install

with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
python-version-file: ".python-version"

- name: 🛠️ Build package
run: uv build

- name: Poetry Build
run: poetry build -v
- name: Publish package distributions to PyPI
- name: 🚀 Publish to PyPI
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you're already aware, but uv publish is also a thing nowadays:
https://docs.astral.sh/uv/guides/package/#publishing-your-package

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://docs.astral.sh/uv/guides/package/#publishing-your-package
It requires tokens to authenticate with the PyPI server whereas the pypa action doesn't need that. I would prefer using loginless method

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm yea... that would complicate things

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By loginless, do you mean trusted publishing? uv publish --trusted-publishing

uses: pypa/gh-action-pypi-publish@release/v1
1 change: 1 addition & 0 deletions .python-version
Comment thread
itsmeadarsh2008 marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This repository contains a template for writing and packaging native Python exte

This template includes:

- A Python Poetry project.
- A Python `uv` project.
- A `src/` directory containing a Pydust Python module.
- Pytest setup for running both Python and Zig unit tests.
- GitHub Actions workflows for building and publishing the package.
Expand Down
Loading