Skip to content

ENH: Define all dependencies in pyproject.toml #132

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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
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
38 changes: 24 additions & 14 deletions .github/workflows/github-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,46 @@ jobs:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]

env:
UV_PYTHON: ${{ matrix.python-version }}
# Use system python. Necessary for the "uv pip" command:
UV_SYSTEM_PYTHON: 1

steps:
- name: Checkout Code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: 'recursive'

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: ${{ matrix.python-version }}

- name: Upgrade pip
run: python -m pip install --upgrade pip
- name: Install requirements (Python 3)
run: pip install -r requirements/ci.txt -r requirements/dev.txt
run: uv pip install --group ci --group dev
- name: Install pdfly
if: matrix.python-version != '3.8'
run: pip install .
run: uv pip install .
- name: Install pdfly using the minimal versions of the dependencies
if: matrix.python-version == '3.8'
run: |
# We ensure that those minimal versions remain compatible:
sed -i '/dependencies = \[/,/\]/s/>=/==/' pyproject.toml
pip install .
uv pip install .

- name: Run tests
run: pytest -vv
run: uv run pytest -vv

codestyle:
name: Check code style issues
runs-on: ubuntu-latest
env:
# Use system python. Necessary for the "uv pip" command:
UV_SYSTEM_PYTHON: 1
steps:
- name: Checkout Code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
Expand All @@ -60,21 +70,21 @@ jobs:
path: '**/tests/pdf_cache/*'
key: cache-downloaded-files

- name: Upgrade pip
run: python -m pip install --upgrade pip
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Install requirements
run: pip install -r requirements/ci.txt
run: uv pip install --group ci
- name: Install pdfly
run: pip install .
run: uv pip install .

- name: Lint with black
run: black --check --extend-exclude sample-files .
run: uv run black --check --extend-exclude sample-files .
- name: Lint with mypy
run: mypy . --ignore-missing-imports --exclude build
run: uv run mypy . --ignore-missing-imports --exclude build
- name: Test with ruff
run: |
echo `ruff --version`
ruff check pdfly/
echo `uv run ruff --version`
uv run ruff check pdfly/

- name: Spell Check Repo
uses: crate-ci/typos@b1ae8d918b6e85bd611117d3d9a3be4f903ee5e4 # v1.33.1
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ formats: all
# Optionally declare the Python requirements required to build your docs
python:
install:
- requirements: requirements/docs.txt
- method: pip
path: .
extra_requirements:
- full
- docs
7 changes: 5 additions & 2 deletions docs/dev/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ might also use it.

## Installing Requirements

```
pip install -r requirements/dev.txt
```bash
pip install --group '<PATH-TO-ROOT-DIR>/pyproject.toml:dev'

# if 'pyproject.toml' is in the current directory:
pip install --group dev
```

## Running Tests
Expand Down
9 changes: 8 additions & 1 deletion docs/dev/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,11 @@

pdfly uses [`pytest`](https://docs.pytest.org/en/latest/) for testing.

To run the tests you need to install the CI (Continuous Integration) requirements by running `pip install -r requirements/ci.txt`.
To run the tests you need to install the CI (Continuous Integration) requirements by running:

```bash
pip install --group '<PATH-TO-ROOT-DIR>/pyproject.toml:ci'

# if 'pyproject.toml' is in the current directory:
pip install --group ci
```
31 changes: 31 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,34 @@ max-complexity = 20 # Recommended: 10
[tool.ruff.lint.per-file-ignores]
"sample-files/*" = ["D100", "INP001", "FA102", "I001"]
"make_release.py" = ["T201", "S603", "S607"]

[dependency-groups]
Copy link
Member

Choose a reason for hiding this comment

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

We should not duplicate dependency information in both this file and the requirements/ directory.

I'm OK to make the switch from requirements/ to [dependency-groups], but then:

  • the requirements/ directory should be removed
  • .github/workflows/github-ci.yaml should be updated to use [dependency-groups] and not requirements/
  • .readthedocs.yaml should be updated to use [dependency-groups] and not requirements/
  • Makefile should be updated to use [dependency-groups] and not requirements/
  • docs/dev/intro.md & docs/dev/testing.md should be updated to use [dependency-groups] and not requirements/

Either we perform all those changes at once in this PR, or else the changes related to [dependency-groups] & uv.lock should be dropped

Copy link
Contributor Author

@philippesamuel philippesamuel Jun 6, 2025

Choose a reason for hiding this comment

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

Hi @Lucas-C, thank you for your review. In my opinion, it would be a good idea to switch from requirements/ to [dependency-groups], since pip 25.1 started supporting [dependency-groups] in pyproject.toml. This would provide a seamless experience for developers using both pip and uv.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @Lucas-C. I'm tracking down references to requirements/ and I found some in the Makefile. I'm not entirely sure how to deal with them:

pdfly/Makefile

Lines 1 to 5 in 05b4fee

maint:
pre-commit autoupdate
pip-compile -U requirements/ci.in
pip-compile -U requirements/dev.in
pip-compile -U requirements/docs.in

Some options:

  1. simply remove the pip-compile commands:
maint:
	pre-commit autoupdate
  1. add references to pyproject.toml:
maint:
	pre-commit autoupdate
	pip-compile --extra=ci pyproject.toml
	pip-compile --extra=dev pyproject.toml  
	pip-compile --extra=docs pyproject.toml
  1. use uv:
maint:
	pre-commit autoupdate
	uv lock

Which one aligns the best with the project?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I'm getting ahead of myself. Here I'm dealing with possibly using uv for this project, instead of solving the issue with the python version. I'll update the PR and open another one to solve only #130.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I created another, more concise PR here: #133

Copy link
Member

Choose a reason for hiding this comment

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

Sorry for the delay in answering.

I merged your other PR, thank you.

Regarding those pip-compile commands, I think could get rid of them in favour of [dependency-groups] in pyproject.toml

ci = [
"black>=24.8.0",
"flake8>=5.0.4",
"flake8-bugbear>=23.3.12",
"flake8-comprehensions>=3.15.0",
"flake8-isort>=6.1.1",
"flake8-simplify>=0.22.0",
"mypy>=1.14.1",
"ruff>=0.11.12",
]
dev = [
"black>=24.8.0",
"pip-tools>=7.4.1",
"pre-commit>=3.2.0",
"pydantic>=2.9.2",
"pytest>=8.3.3",
"pytest-cov>=5.0.0",
"pytest-socket>=0.7.0",
"pytest-timeout>=2.3.1",
"rich>=13.9.4",
"twine>=5.1.1",
"wheel>=0.45.0",
]
docs = [
"attrs>=25.3.0",
"myst-parser==0.16.1",
"sphinx>=4.5.0",
"sphinx-rtd-theme>=1.3.0",
]
8 changes: 0 additions & 8 deletions requirements/ci.in

This file was deleted.

59 changes: 0 additions & 59 deletions requirements/ci.txt

This file was deleted.

11 changes: 0 additions & 11 deletions requirements/dev.in

This file was deleted.

Loading
Loading