-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
Dependencies & Configs: Proposals for improvement and optimisation #599
Comments
Hi @alexted, Since the Python packaging tool has changed from setuptools to flit, it’s unfortunate that flit does not support Python C extensions, such as those compiled with Mypyc. For this reason, the project needs to continue using setuptools as its packaging tool. Specifically, the project requires the files setup.py, setup.cfg, and MANIFEST.in. To fully migrate to flit, it would be necessary to develop a plugin or a custom backend to support Python C extensions. Additionally, there may be consideration of migrating to another packaging tool like Hatch. The project has transitioned from using black, flake8, and similar tools to ruff, with the entire configuration now located in pyproject.toml. The tox.ini file is intended to facilitate development and testing, and it is not a project dependency. The readability of the new pyproject.toml file is also improved. Furthermore, the requirements/* files are maintained to lock the versions of dependencies and to enable GitHub Dependabot to discover new versions and create pull requests for patch management. Currently, this functionality is not feasible within pyproject.toml. Utilizing tools like poetry or pip-compile to generate requirements/* files is a good approach, as it can lock the versions of all dependencies (similar to pip freeze) and help prevent resolution issues with pip. |
Ok, setuptools is a good choice!
Yeah, and it's beautiful!
According to PEP 621, the pyproject.toml file has a much larger scope than just accounting for project dependencies.
Dependabot has support for pyproject.toml and works fine with it. No problems. |
You are right! Good to know! Also, we can lock the versions with
Thank you! |
Glad to share! I didn't get your comment about using |
For drops entires setuptools configuration files, I think that to wait for it. By the way, the first intention is to deprecate the setuptools and favor of flit.
Certainly, but I see
When a dependency gets bumped use the post-action of GitHub Dependabot PRs that update the requirements/* (pip’s lower-level requirements.txt file) to lock the version of the entire environment (pip freeze), not only the direct dependencies. This can help somebody to always test against the same dependency versions. Also, it makes and checks file hashes, to ensure compliance with hash-locked dependency specifiers, and eases uninstallation of packages and dependencies. |
It is possible to move most settings from separate files, such as setup.py, setup.cfg, MANIFEST.in, and other configuration files, inside pyproject.toml. Below is an example that combines these files and configures dependencies, package instructions, and other settings to reduce the number of separate files to a minimum:
Explanation of New Sections
[build-system] — Specifies the build system requirements, indicating the need for
setuptools
andwheel
for building the package.[project] — Contains essential project metadata, such as name, version, description, authors, classifiers, and main dependencies. It also includes optional dependencies for different environments like development, testing, linting, and documentation.
[project.optional-dependencies] — Defines optional dependencies that can be installed based on the specific needs of the project, such as development tools (
dev
), testing tools (test
), linters (lint
), and documentation tools (docs
).[project.urls] — Provides URLs related to the project, including the homepage, documentation, and source repository.
[tool.setuptools.packages.find] — Configures the packages to be included, similar to
find_packages()
insetup.py
.[tool.black] and [tool.isort] — Configuration settings for code formatting tools like
black
andisort
, defining rules for code style.[tool.pytest.ini_options] — Configuration for
pytest
, specifying minimum version requirements, command-line options, and test paths.[tool.flake8] — Configuration for the
flake8
linter, defining rules such as maximum line length and ignored errors.[tool.tox] — Main section for configuring
tox
, listing the different environments for testing and their dependencies.[tool.tox.env.] — Configuration for individual
tox
environments (likepy37
,py38
,lint
, andtest
), specifying dependencies, commands to run, and descriptions for each environment.This consolidated configuration allows for easier management and eliminates the need for multiple configuration files like
setup.py
,setup.cfg
,MANIFEST.in
,.flake8
,.isort.cfg
,.coveragerc
,tox.ini
, andrequirements/*.txt
, streamlining the project structure.You can then use docker's two-phase image creation in elegant style, where in the first phase you simply convert
pyproject.toml
torequirements.txt
like this:The text was updated successfully, but these errors were encountered: