Skip to content
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

Modernize build system to be based on pyproject.toml #1334

Closed
anselor opened this issue Oct 18, 2024 · 8 comments
Closed

Modernize build system to be based on pyproject.toml #1334

anselor opened this issue Oct 18, 2024 · 8 comments
Labels
enhancement github_actions Pull requests that update GitHub Actions code major

Comments

@anselor
Copy link
Contributor

anselor commented Oct 18, 2024

We need to replace the legacy build system based on setup.py, setup.cfg with a modern Python one based on pyproject.toml. This guide on How to modernize a setup.py based project has some useful pointers on where to start. setup.cfg should be deleted entirely and all configuration moved to pyproject.toml. Any python setup.py commands need to be migrated to a modern python -m build or python -m pip install command.

There are several more advanced build system tools which are worth exploring. The current default recommendation from python seems to be hatch. It has impressive features including declaring build/test configurations and managing venv environments. @anselor tried hatch on a couple small projects and found it to be much faster than using nox to set up venvs. The problem is it currently doesn't support a monorepo project with multiple modules or plugin modules. There is a development ticket (pypa/hatch#233) that documents it and it is under active development now. Once that is complete we should be able to migrate to hatch with minimal fuss.

A newer alternative that is taking the Python world by storm is uv which is an extremely fast Python package and project manager, written in Rust. uv is a single tool to replace pip, pip-tools, pipx, poetry, pyenv, virtualenv, pipenv and more. I've used this at work to replace pip in some builds and it has typically sped things up by a factor of 2x.

@tleonhardt
Copy link
Member

tleonhardt commented Oct 18, 2024

I like the idea of moving to something like either hatch or uv and getting rid of nox for running our tests in multiple python environments.

I tried moving to a more modern Python project setup where everything is in pyproject.toml and there are no setup.cfg or setup.py files, but I couldn't get that working properly with nox.

On a semi-related note, I'd already replaced the mix of flake8, black, and isort for auto-formatting and linting with ruff which is far faster.

@tleonhardt
Copy link
Member

#1336 handles the moving to ruff from black, isort, and flake8

@tleonhardt tleonhardt changed the title Migrate to pyproject.toml & hatch Migrate to pyproject.toml Oct 23, 2024
@tleonhardt tleonhardt changed the title Migrate to pyproject.toml Modernize to pyproject.toml Oct 23, 2024
@tleonhardt tleonhardt changed the title Modernize to pyproject.toml Modernize build system to be based on pyproject.toml Oct 23, 2024
@tleonhardt tleonhardt added enhancement major github_actions Pull requests that update GitHub Actions code labels Oct 23, 2024
@tleonhardt
Copy link
Member

#1343 Moved the doc8 config to pyrproject.toml from setup.cfg

@tleonhardt
Copy link
Member

#1344 Moves the mypy config to pyproject.toml from setup.cfg

@tleonhardt
Copy link
Member

tleonhardt commented Oct 23, 2024

#1345 Moves pytest config to pyproject.toml from setup.cfg and deletes setup.cfg entirely

@tleonhardt
Copy link
Member

#1364 is a PR that sets the [project] configuration in pyrproject.toml and ruggedize a couple unit tests

#1365 fully removed setup.py and relies purely on pyproject.toml for the build

@tleonhardt
Copy link
Member

I'm going to resolve this and create a new issue for considering moving to hatch or uv

@tleonhardt
Copy link
Member

I created #1366 to encompass the future work for moving to something like uv or hatch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement github_actions Pull requests that update GitHub Actions code major
Projects
None yet
Development

No branches or pull requests

2 participants