Skip to content

Commit

Permalink
Replace Poetry with Rye (#843)
Browse files Browse the repository at this point in the history
* feat: Replace Poetry with Rye

* misc: switch from pyright to basedpyright

* misc: remove unused dependencies

* misc: default to latest Python 3.12 version

* misc: replace poetry based workflows with rye

* feat(changelog): Replace towncrier to git-cliff (still needs CI and docs)

* feat: make docs and changelog work with rye

* feat: add readthedocs support for rye

* feat: add readthedocs support for rye

* feat: add readthedocs support for rye

* feat: Replace Poetry with Rye

* misc: switch from pyright to basedpyright

* misc: remove unused dependencies

* feat(changelog): Replace towncrier to git-cliff (still needs CI and docs)

* feat: make docs and changelog work with rye

* feat: add readthedocs support for rye

* feat: add readthedocs support for rye

* feat: add readthedocs support for rye

* misc(pyproject): remove unneeded commented out config

* fix(poetry): remove poetry lock

* fix(ci): use correct path when enabling the venv fro building the docs

* fix(ci): run `rye test` instead of `poetry run pytest`

* fix(ci): typo in release workflow regarding latest changelog file
  • Loading branch information
MichaelSasser authored Oct 8, 2024
1 parent 0691547 commit 7f6de82
Show file tree
Hide file tree
Showing 139 changed files with 2,085 additions and 2,375 deletions.
41 changes: 19 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,50 +18,47 @@ name: Python CI

on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master, develop ]
branches: [master, develop]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4.2.1
- name: Set up Python 3.11
uses: actions/setup-python@v5.2.0
with:
python-version: "3.11"
- name: Checkout code
uses: actions/checkout@v4.2.0

- name: Install Poetry
uses: snok/install-poetry@v1.4
- name: Set up Python 3.12
uses: actions/setup-python@v5.2.0
with:
virtualenvs-create: true
virtualenvs-in-project: true
python-version: "3.12"

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4.1.0
- name: Setup Rye
id: setup-rye
uses: eifinger/setup-rye@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
version: "0.41.0"
enable-cache: true
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install Project Dependencies
run: poetry install --with docs
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: rye sync --all-features
if: steps.setup-rye.outputs.cache-hit != 'true'

- name: Run pre-commit
run: |
source .venv/bin/activate
. .venv/bin/activate
pre-commit run --all-files
- name: Sphinx Build
working-directory: ./docs
run: |
source ../.venv/bin/activate
. ../.venv/bin/activate
make html
- name: Test with pytest
run: |
source .venv/bin/activate
poetry run pytest
. .venv/bin/activate
rye test
27 changes: 11 additions & 16 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,23 @@ jobs:
working-directory: ./docs
steps:
- name: Checkout code
uses: actions/checkout@v4.2.1
- name: Set up Python 3.10
uses: actions/setup-python@v5.2.0
with:
python-version: "3.10"
uses: actions/checkout@v4.2.0

- name: Install Poetry
uses: snok/install-poetry@v1.4
- name: Set up Python 3.12
uses: actions/setup-python@v5.2.0
with:
virtualenvs-create: true
virtualenvs-in-project: true
python-version: "3.12"

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4.1.0
- name: Setup Rye
id: setup-rye
uses: eifinger/setup-rye@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
enable-cache: true
version: "0.41.0"

- name: Install Project Dependencies
run: poetry install -E docs
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: rye sync --all-features
if: steps.setup-rye.outputs.cache-hit != 'true'

- name: Make docs
working-directory: ${{env.working-directory}}
Expand Down
70 changes: 31 additions & 39 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,43 +27,33 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4.2.1
- name: Set up Python 3.10
uses: actions/checkout@v4.2.0

- name: Set up Python 3.12
uses: actions/setup-python@v5.2.0
with:
python-version: "3.10"
python-version: "3.12"

- name: Install Poetry
uses: snok/install-poetry@v1.4
- name: Setup Rye
id: setup-rye
uses: eifinger/setup-rye@v4
with:
virtualenvs-create: true
virtualenvs-in-project: true
version: "0.41.0"
enable-cache: true
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4.1.0
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
- name: Install Project Dependencies
run: rye sync --all-features
if: steps.setup-rye.outputs.cache-hit != 'true'

- name: Build project
run: poetry build
run: rye build --all --clean

- name: Zip project
run: zip --junk-paths matrixctl.zip dist/* README.md LICENSE.txt

- name: Generate changelog_latest.rst from CHANGELOG.rst
run: python scripts/get_latest_release.py

- name: Convert from changelog_latest.rst to changelog_latest.md
uses: docker://pandoc/core:3.5.0
with:
args: >-
--output=chagelog_latest.md
--from rst
--to markdown
--markdown-headings=atx
chagelog_latest.rst
- name: Generate changelog_latest.md
run: git cliff --latest > changelog_latest.md

- name: Get the version
id: get_version
Expand All @@ -75,20 +65,22 @@ jobs:
prerelease: false
draft: false
name: Release ${{ steps.get_version.outputs.VERSION }}
body_path: chagelog_latest.md
body_path: changelog_latest.md
files: matrixctl.zip

- name: Delete temp files
run: rm -rf matrixctl.zip chagelog_latest.md chagelog_latest.rst
run: rm -rf matrixctl.zip changelog_latest.md

- name: pypi-publish
uses: pypa/gh-action-pypi-publish@v1.10.3
with:
# PyPI user
# user: # optional, default is __token__
# Password for your PyPI user or an access token
password: ${{ secrets.pypi_token }}
# The repository URL to use
# repository_url: # optional
# The target directory for distribution
# packages_dir: # optional, default is dist
- name: Publish
run: rye publish --token <your_token> --yes --skip-existing
# - name: pypi-publish
# uses: pypa/gh-action-pypi-publish@v1.10.2
# with:
# # PyPI user
# # user: # optional, default is __token__
# # Password for your PyPI user or an access token
# password: ${{ secrets.pypi_token }}
# # The repository URL to use
# # repository_url: # optional
# # The target directory for distribution
# # packages_dir: # optional, default is dist
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
minimum_pre_commit_version: 2.13.0

exclude: ^requirements.*\.lock$
repos:
- repo: meta
hooks:
Expand Down Expand Up @@ -53,7 +54,6 @@ repos:
# - id: double-quote-string-fixer (KEEP DISABLED)
# Makes sure files end in a newline and only a newline.
- id: end-of-file-fixer
exclude: "^CHANGELOG.rst"
# Removes "# -*- coding: utf-8 -*-" on the top of python files.
- id: fix-encoding-pragma
args: ["--remove"]
Expand Down
27 changes: 11 additions & 16 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,18 @@

version: 2

sphinx:
configuration: docs/source/conf.py

formats: all

build:
os: "ubuntu-22.04"
tools:
python: "3.10"
jobs:
post_create_environment:
# Install poetry
# https://python-poetry.org/docs/#installing-manually
- pip install poetry
post_install:
# Install dependencies with 'docs' dependency group
# https://python-poetry.org/docs/managing-dependencies/#dependency-groups
# VIRTUAL_ENV needs to be set manually for now.
# See https://github.com/readthedocs/readthedocs.org/pull/11152/
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --with docs
commands:
# - asdf plugin add uv
- asdf plugin add rye
# - asdf install uv latest
- asdf install rye latest
# - asdf global uv latest
- asdf global rye latest
# - uv venv
# - uv pip install .[docs]
- rye sync --all-features
- .venv/bin/python -m sphinx -T -b html -d docs/_build/doctrees -D language=en docs/source $READTHEDOCS_OUTPUT/html
1 change: 0 additions & 1 deletion CHANGELOG.rst → CHANGELOG.deprecated.rst
Original file line number Diff line number Diff line change
Expand Up @@ -731,4 +731,3 @@ Trivial Changes
.. note:: No significant changes to the Project.

**Internal Release**

Loading

0 comments on commit 7f6de82

Please sign in to comment.