Skip to content

Commit

Permalink
Migrate Poetry to UV (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
leonlan authored Nov 6, 2024
1 parent 75b2d18 commit ec31d04
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 52 deletions.
49 changes: 21 additions & 28 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,39 @@ on:

jobs:
build:
name: 'Build and test fjsplib using ${{ matrix.python-version }}'
name: Test fjsplib using Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
python-version: ['3.9', '3.12']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.12']
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Update pip and poetry
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Cache Python dependencies
uses: actions/cache@v4
id: cache-python

- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
path: ~/.cache/pypoetry
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}
- name: Install Python dependencies
if: steps.cache-python.outputs.cache-hit != 'true'
run: poetry install
version: "0.4.27"

- name: Install Python version
run: uv python install ${{ matrix.python-version }}

- name: Install the project
run: uv sync

- name: Cache pre-commit
uses: actions/cache@v4
uses: actions/cache@v3
id: cache-pre-commit
with:
path: ~/.cache/pre-commit/
key: pre-commit-${{ env.pythonLocation }}-${{ hashFiles('.pre-commit-config.yaml') }}
key: pre-commit-${{ matrix.python-version }}-${{ hashFiles('.pre-commit-config.yaml') }}

- name: Install pre-commit
if: steps.cache-pre-commit.outputs.cache-hit != 'true'
run: poetry run pre-commit install --install-hooks
run: uv run pre-commit install --install-hooks

- name: Run pre-commit
run: poetry run pre-commit run --all-files
run: uv run pre-commit run --all-files

- name: Run tests
run: poetry run pytest
- if: matrix.python-version == '3.9'
name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
slug: leonlan/FJSPLIB
run: uv run pytest
23 changes: 23 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish

on:
release:
types: [ created ]

jobs:
run:
name: "Build and publish release"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "0.4.27"

- run: uv python install 3.12
- run: uv build
- run: uv publish
env:
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
78 changes: 54 additions & 24 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,49 +1,79 @@
[tool.poetry]
[project]
name = "fjsplib"
version = "0.0.1"
description = "Python package to read and write FJSP instances."
authors = ["Leon Lan <leon.lanyidong@gmail.com>"]
license = "MIT"
authors = [
{ name = "Leon Lan", email = "l.lan@vu.nl"},
]
license = { text = "MIT License" }
readme = "README.md"
repository = "https://github.com/leonlan/FJSPLIB"
keywords = [
"scheduling",
"flexible job shop scheduling",
"fjsp",
]
classifiers = [
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Development Status :: 5 - Production/Stable",
"Topic :: Software Development",
"Topic :: Scientific/Engineering",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
]
requires-python = ">=3.9"
dependencies = [
"numpy>=1.26.0",
]

[tool.poetry.dependencies]
python = "^3.9"
numpy = "^1.26.4"

[tool.poetry.group.dev.dependencies]
pre-commit = "^2.19.0"
pytest = "^7.1.2"
pytest-cov = ">=2.6.1"
[project.urls]
Repository = "https://github.com/PyJobShop/FJSPLIB"


[tool.black]
line-length = 79
[dependency-groups]
dev = [
"pre-commit>=3.8.0",
"pytest>=8.3.2",
]


[tool.uv]
default-groups = ["dev"]


[tool.mypy]
ignore_missing_imports = true


[tool.black]
line-length = 79


[tool.ruff]
line-length = 79
extend-include = ["*.ipynb"]


[tool.ruff.lint]
ignore-init-module-imports = true
select = [
"E", "F", "I", "NPY", "PYI", "Q", "RET", "RSE", "RUF", "SLF", "SIM", "TCH"
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"I", # isort
"C", # flake8-comprehensions
"B", # flake8-bugbear
]
ignore = [
"E741", # ambiguous variable name, needed for indexing
"C901", # too complex
]

[tool.ruff.lint.isort]
case-sensitive = true
known-first-party = ["fjsplib", "tests"]


[tool.pytest.ini_options]
addopts = "--cov=. --cov-report=xml --cov-report=term"
testpaths = "tests"
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"] # ignore unused module imports


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
requires = ["hatchling"]
build-backend = "hatchling.build"

0 comments on commit ec31d04

Please sign in to comment.