-
Notifications
You must be signed in to change notification settings - Fork 341
PEP 621: Migrate from setup.py to pyproject.toml #522
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
Conversation
| ] | ||
| dynamic = [ "version" ] | ||
|
|
||
| dependencies = [ "requests>=2.32.5", "setuptools" ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have learned not to trust the GitHub merge editor as it discarded most of my edit consolidating this block into the tool.ruff section below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't use GitHub Merge either. I just did not rebase against a current master. -- Fixed.
|
Do we need dependencies = ["requests>=2.32.5", "setuptools"]It is used to build wheels from the source distribution, but according to: PEP-507 the |
8946d3f to
8c28b27
Compare
|
Given that we are whacking |
8c28b27 to
d331cf2
Compare
But we no longer use the setup.py file, right? After this PR is merged? |
|
Tons of advantages from moving away from |
Just like this, |
|
I would vote for |
I'm only referring to the Hatchling build backend. |
|
@DhavalGojiya Your review, please. |
pyproject.toml
Outdated
| "Programming Language :: Python :: 3.14", | ||
| "Topic :: Internet :: WWW/HTTP :: Indexing/Search", | ||
| ] | ||
| dynamic = [ "version" ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are using a dynamic version, but where are we getting this information from?
The build Metadata file:
Metadata-Version: 2.4
Name: pysolr
Version: 0.0.0
Summary: Lightweight Python client for Apache Solr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
Should we modify this logic to put the version here?
Lines 30 to 36 in ec2ff51
| __author__ = "Daniel Lindsley, Joseph Kocherhans, Jacob Kaplan-Moss, Thomas Rieder" | |
| __all__ = ["Solr"] | |
| try: | |
| __version__ = _get_version(__name__) | |
| except PackageNotFoundError: | |
| __version__ = "0.0.dev0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we're using setuptools-scm, which dynamically determines the next release PyPi version based on the most recent GitHub tag.
The code in the pysolr.py file (lines 30-36) is completely fine - it simply reports which pysolr version is being used when we install pysolr as a dependency in a real project.
Basically, it allows the version to be identified programmatically, similar how pip show pysolr displays the version number.
Code:
Python 3.11.14 (main, Oct 31 2025, 22:57:10) [MSC v.1944 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pysolr
>>> pysolr.__version__ # under the hood `from importlib.metadata import version`
'3.11.0'
>>> from importlib.metadata import version
>>> version("pysolr")
'3.11.0'
>>> version("django")
'5.2.8'There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But can we drop setuptools-scm (dynamic versioning) completely and hard-code the version in pyproject.toml?
Like this:
[project]
name = "pysolr"
description = "Lightweight Python client for Apache Solr"
version = "3.11.0"
This looks very simple approach, especially since the pysolr package doesn't release new versions very often.
Whenever we need a new release for PyPi, we can just create a Bump x.y.z version PR or make a direct commit in master branch.
pyproject.toml
Outdated
| build-backend = "setuptools.build_meta" | ||
| requires = [ | ||
| "setuptools>=61.2", | ||
| "setuptools-scm", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove this setuptools-scm safely from the build backend. Since we are not using dynamic versioning.
d8335b9 to
fd61cd5
Compare
|
@cclauss |
https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html
Migrate
setup.pytosetup.cfgusing setuptools-py2cfg. Then migratesetup.cfgtopyproject.tomlusing ini2toml to do the file conversion, and run pyproject-fmt and then validate-pyproject to validate the results.Related to: