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

setup.pypyproject.toml #509

Closed
DimitriPapadopoulos opened this issue Oct 25, 2022 · 12 comments · Fixed by #566
Closed

setup.pypyproject.toml #509

DimitriPapadopoulos opened this issue Oct 25, 2022 · 12 comments · Fixed by #566

Comments

@DimitriPapadopoulos
Copy link
Contributor

Configuring setuptools using pyproject.toml files

Plan migration from executable setup.py to declarative pyproject.toml:

  1. Move to pyproject.toml and make setup.py a thin wrapper
  2. Optionally use setuptools_scm to automate versioning

Nothing urgent here, just a suggestion to modify at some point.

@adrienverge
Copy link
Owner

  1. Move to pyproject.toml and make setup.py a thin wrapper

+1, since this is the new standard.

@DimitriPapadopoulos
Copy link
Contributor Author

Just keep in mind this is relatively new. Installing from source requires recent versions of pip and/or setuptools, more recent than bundled with Ubuntu 22.04 for example.

See for example codespell-project/codespell#2523.

@DimitriPapadopoulos
Copy link
Contributor Author

DimitriPapadopoulos commented Oct 27, 2022

Also, it might not be possible to share the following variables any more, between the setup process and the rest of the code, because setup now relies on a declarative pyproject.toml instead of the Python script setup.py. Will that necessarily result in duplication?

APP_NAME = 'yamllint'
APP_VERSION = '1.28.0'
APP_DESCRIPTION = __doc__
__author__ = u'Adrien Vergé'
__copyright__ = u'Copyright 2022, Adrien Vergé'
__license__ = 'GPLv3'
__version__ = APP_VERSION

@adrienverge
Copy link
Owner

adrienverge commented Oct 28, 2022

Just keep in mind this is relatively new.

Sure. I don't think we should do the transition now.

Also, it might not be possible to share the following variables any more, [...] Will that necessarily result in duplication?

Well seen. I guess the new "right way to do" is to declare name, version, author, etc. in pyproject.toml, and fetch them from Python code using a setuptools helper?

@DimitriPapadopoulos
Copy link
Contributor Author

DimitriPapadopoulos commented Oct 28, 2022

Indeed, from Package Discovery and Resource Access using pkg_resources:

The pkg_resources module distributed with setuptools provides an API for Python libraries to access their resource files,

Also, for those installing from source, having up to date pip and setuptools is required any way. From Installing Packages:

While pip alone is sufficient to install from pre-built binary archives, up to date copies of the setuptools and wheel projects are useful to ensure you can also install from source archives:

python3 -m pip install --upgrade pip setuptools wheel

Therefore, my first remark about the need for recent versions is not considered to be an issue. Yet, my short experience is that the package documentation should remind this to end-users who attempt to install from source.

@DimitriPapadopoulos
Copy link
Contributor Author

And a very long text with a funny introduction:
Why you shouldn't invoke setup.py directly

I realize that this article is quite long, and unfortunately this is the short version. [...] I hope that this article can be useful when you want to advocate against the use of setup.py: when you make a PR or a comment in a Slack channel, you can link to this Proustian monstrosity and hope that your audience pales before the prospect of reading through the whole thing and just assents to whatever you're asking them to do.

@barrelful
Copy link

@adrienverge now I started having an annoying warning from pip:

  DEPRECATION: yamllint is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559

Maybe now it is a good time to transition? If you don't want to do it yourself, maybe I can make a PR.

@staticdev
Copy link

staticdev commented Apr 2, 2023

I am using pyproject.toml in all my professional projects and also all projects I maintain here on Github. It centralizes configs for the repo and has been working flawlessly for me in the past years.

@DimitriPapadopoulos
Copy link
Contributor Author

The downside is that pyproject.toml often requires recent versions of pip, setuptools and wheel before installing from source. But then that's what the Python Packaging User Guide suggests any way.

I won't have time for a PR in the short term.

@staticdev
Copy link

@DimitriPapadopoulos you don't need.. it is already done #557

@ssbarnea
Copy link
Sponsor Contributor

@adrienverge Can we please make this a reality, it is a share to read:

DEPRECATION: yamllint is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559

@adrienverge
Copy link
Owner

Sure, please see the ongoing discussion at #557.

adrienverge added a commit that referenced this issue Apr 14, 2023
Using `setup.py` is deprecated and the new recommanded way is to declare
a `pyproject.toml` file (see PEP 517 [^1]).

This commit proposes to use setuptools to achieve that, because
setuptools is already used by yamllint, is standard and referenced by
the official Python packaging documentation [^2], and seems to be the
most lightweight solution. An alternative could have been to use Poetry,
see the dedicated pull request and discussion [^3].

For some period, the `setup.py` file will be kept (although almost
empty), to allow old tools versions to keep working.

Closes #509.

[^1]: https://peps.python.org/pep-0517/
[^2]: https://packaging.python.org/en/latest/tutorials/installing-packages/
[^3]: #557
adrienverge added a commit that referenced this issue Apr 21, 2023
Using `setup.py` is deprecated and the new recommanded way is to declare
a `pyproject.toml` file (see PEP 517 [^1]).

This commit proposes to use setuptools to achieve that, because
setuptools is already used by yamllint, is standard and referenced by
the official Python packaging documentation [^2], and seems to be the
most lightweight solution. An alternative could have been to use Poetry,
see the dedicated pull request and discussion [^3].

For some period, the `setup.py` file will be kept (although almost
empty), to allow old tools versions to keep working.

Closes #509.

[^1]: https://peps.python.org/pep-0517/
[^2]: https://packaging.python.org/en/latest/tutorials/installing-packages/
[^3]: #557
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants