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

migrate from setup.py to pyproject.toml #639

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

deltragon
Copy link
Collaborator

Description

This PR switches configuration from setup.py to pyproject.toml.

This is somewhat of a prerequisite in the plan discussed in #589.
Most of the tools there (type checkers, nox/tox, ruff) expect to be configured with a pyproject.toml file.
This documentation also "strongly recommends" using a pyproject.toml file in some form.

In theory, it would be enough to just use the [build-backend] table, and keep the setup.py mostly as-is.
However, when a pyproject.toml file is detected, it also enables build isolation automatically.

Build isolation means that the way .mo files were generated needs to be changed (it is now a custom build step), and the data_files key is deprecated, so I decided to properly migrate everything to pyproject.toml.

The only thing this should have an impact on is building the release. I have tested locally, and using python -m build properly builds the .whl and .tar.gz as before, with identical contents apart from some metadata differences.

Copy link
Collaborator Author

@deltragon deltragon left a comment

Choose a reason for hiding this comment

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

Move reviews over from #641.

.github/workflows/release.yml Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
setup.py Outdated Show resolved Hide resolved
setup.py Outdated Show resolved Hide resolved
setup.py Outdated Show resolved Hide resolved
setup.py Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
Copy link
Contributor

@nifadyev nifadyev left a comment

Choose a reason for hiding this comment

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

LGTM

@archisman-panigrahi
Copy link
Collaborator

I am not very familiar with this. Will Debian packaging/PPA still work if we migrate away from setup.py?

@deltragon
Copy link
Collaborator Author

@archisman-panigrahi
I followed the recommendation here and added pybuild-plugin-pyproject to the build dependencies.
With that, running debuild -b -uc -us on Debian 12 leaves me with a working .deb file there.
What is the workflow for building the PPA? If that uses Debian's tools, then it should also work there seamlessly.

@deltragon
Copy link
Collaborator Author

(If we want to automate this, we could try to use https://github.com/marketplace/actions/build-debian-packages? That should be able to ensure that the package builds successfully.)

@archisman-panigrahi
Copy link
Collaborator

I tried building it in Launchpad. While it builds for ubuntu 24.04 and 24.10 (both have python3.12), it does not build in 22.04 (python3.10), with the error

I: pybuild plugin_pyproject:107: Building wheel for python3.10 with "build" module
I: pybuild base:239: python3.10 -m build --skip-dependency-check --no-isolation --wheel --outdir /<<PKGBUILDDIR>>/.pybuild/cpython3_3.10 
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pep517/in_process/_in_process.py", line 363, in <module>
    main()
  File "/usr/lib/python3/dist-packages/pep517/in_process/_in_process.py", line 345, in main
    json_out['return_val'] = hook(**hook_input['kwargs'])
  File "/usr/lib/python3/dist-packages/pep517/in_process/_in_process.py", line 261, in build_wheel
    return _build_backend().build_wheel(wheel_directory, config_settings,
  File "/usr/lib/python3/dist-packages/setuptools/build_meta.py", line 230, in build_wheel
    return self._build_with_temp_dir(['bdist_wheel'], '.whl',
  File "/usr/lib/python3/dist-packages/setuptools/build_meta.py", line 215, in _build_with_temp_dir
    self.run_setup()
  File "/usr/lib/python3/dist-packages/setuptools/build_meta.py", line 158, in run_setup
    exec(compile(code, __file__, 'exec'), locals())
  File "setup.py", line 7, in <module>
    from setuptools.command.build import build as OriginalBuildCommand
ModuleNotFoundError: No module named 'setuptools.command.build'
* Building wheel...

ERROR Backend subproccess exited when trying to invoke build_wheel
E: pybuild pybuild:369: build: plugin pyproject failed with: exit code=1: python3.10 -m build --skip-dependency-check --no-isolation --wheel --outdir /<<PKGBUILDDIR>>/.pybuild/cpython3_3.10 
dh_auto_build: error: pybuild --build -i python{version} -p 3.10 returned exit code 13
make: *** [debian/rules:3: build] Error 25
dpkg-buildpackage: error: debian/rules build subprocess returned exit status 2

We can decide to not support 22.04 anymore, but I don't see why it does not seem to work with python 3.10.

@archisman-panigrahi
Copy link
Collaborator

What is the workflow for building the PPA? If that uses Debian's tools, then it should also work there seamlessly.

Yes, it builds like any other debian package

@deltragon
Copy link
Collaborator Author

Hmm, the issue here doesn't seem to be Python 3.10, but the version of setuptools in 22.04 - according to this, setuptools needs to be at 65.2.0 or higher, but 22.04 only has 59.6.0.

That said, when I revert the last commit, it also builds correctly on Debian 12 (albeit with warnings that setup.py is deprecated).
I've pushed the revert, can you test again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants