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

Switch to pyproject.toml #2376

Closed
wants to merge 1 commit into from
Closed

Switch to pyproject.toml #2376

wants to merge 1 commit into from

Conversation

schaefi
Copy link
Collaborator

@schaefi schaefi commented Sep 13, 2023

setup.py is marked obsolete for a long time and with this commit pyproject.toml is introduced and used for the development environment setup.

To be more clear, calling setup.py as a tool is deprecated:

The changes here refactors kiwi to no longer call setup.py in any way

@schaefi schaefi self-assigned this Sep 13, 2023
@schaefi
Copy link
Collaborator Author

schaefi commented Sep 13, 2023

@Conan-Kudo I'm pro switching to poetry. I just opened this PR to show a bit of my experiments with moving away from setup.py and the issues I had and still have with it

@schaefi schaefi marked this pull request as draft September 13, 2023 10:23
@schaefi
Copy link
Collaborator Author

schaefi commented Oct 8, 2023

Related to #2370

@schaefi schaefi force-pushed the setup_py_is_obsolete branch 3 times, most recently from 81e8e97 to 2cd2ed9 Compare December 20, 2023 21:14
@schaefi
Copy link
Collaborator Author

schaefi commented Dec 20, 2023

Added more cleanup tasks:

  • Makefile is free from setup.py usage now. For building the sdist tarball for the package build we now use python -m build which of course requires the python build module to be present on the host. pip install build
  • The upload to pypi happens now as a wheel and no longer sdist, this is done by tox calling python -m build for the release target which defaults to wheel

@schaefi
Copy link
Collaborator Author

schaefi commented Dec 20, 2023

setup.py now only holds settings that cannot (or I did not understand how to add them) be used in pyproject.toml. These settings are mainly scripts and entry-points and the license. See the dynamic section

dynamic = [
    "license",
    "entry-points",
    "scripts"
]

ideas welcome

@schaefi
Copy link
Collaborator Author

schaefi commented Dec 20, 2023

setup.py is currently only actively called in the .spec file for installing

python3 setup.py install --prefix=%{_prefix} --root=%{buildroot} %{?is_deb:--install-layout=deb}

If we want to change this it would mean:

  • switch to wheel and call python installer the-wheel
  • This creates a dependency to the installer module which I'm not sure exists for all distros
  • We could delete the requirement for setuptools consequently
  • Our source tarball would be a wheel instead of a tarball. This causes the problem that we add other data e.g the man pages to the source tarball and I don't know how to modify a wheel

@schaefi
Copy link
Collaborator Author

schaefi commented Dec 20, 2023

@Conan-Kudo I made some progress here, if you have a free minute would be nice if you can take a look at the changeset.

@schaefi schaefi marked this pull request as ready for review December 21, 2023 17:32
@schaefi
Copy link
Collaborator Author

schaefi commented Dec 21, 2023

@Conan-Kudo I finished my changes regarding setup.py. I think it is in a review-able state now. My main concern is the change on the .spec file level. I'm not sure if BuildRequires: python%{python3_pkgversion}-installer resolves correctly on all distros we support. Thus I still have the no merge label active

package/python-kiwi-spec-template Outdated Show resolved Hide resolved
package/python-kiwi-spec-template Show resolved Hide resolved
package/python-kiwi-spec-template Outdated Show resolved Hide resolved
package/python-kiwi-spec-template Outdated Show resolved Hide resolved
@Conan-Kudo Conan-Kudo marked this pull request as draft December 21, 2023 17:47
@schaefi schaefi marked this pull request as ready for review December 21, 2023 18:58
@Conan-Kudo
Copy link
Member

We cannot merge this until we drop support for old distributions as stated in #2369. Because otherwise this will be broken for half of our supported platforms.

@schaefi
Copy link
Collaborator Author

schaefi commented Dec 21, 2023

We cannot merge this until we drop support for old distributions as stated in #2369. Because otherwise this will be broken for half of our supported platforms.

I thought with the last commit there should be a safe fallback for these cases, no ?

@Conan-Kudo
Copy link
Member

You ripped all the data out of setup.py, so now we need something to process pyproject.toml to build properly.

Calling setup.py is marked obsolete for a long time and with this commit
pyproject.toml is introduced and used for the development environment
setup. On the packaging side the spec file is kept compatible with
setup.py in a way that we try the build and installer python modules
first and only if those are not present setup.py is called. For the
publishing on pypi both targets wheel and sdist are used which is the
default action of python -m build.
@Conan-Kudo
Copy link
Member

You could try moving the data into a setup.cfg file and tell pyproject.toml that we use setuptools to build. I think that's backward compatible.

@schaefi
Copy link
Collaborator Author

schaefi commented Dec 29, 2023

You ripped all the data out of setup.py, so now we need something to process pyproject.toml to build properly.

I might be missing all details but to my understanding only the direct call of setup.py as a command is obsolete. Meaning setuptools and the use of pyproject.toml in combination with setup.py is still a supported combination. With the current changeset I tried building for a distro that has build and installer python modules available and I also tried building against SLE15 which is py3.6 and there are not out of the box build and installer modules available. The spec tries to create the wheel and fails and as fallback continues with "setup.py install" as we had it before and that worked without any issues. Thus I wonder where the changes here breaks the backward compatibility. I admit that I haven't looked into all details and after effects.

I will close this PR and re-open it against the kiwi-10 branch. I think there we definitely need to move away from setup.py

@schaefi schaefi closed this Dec 29, 2023
@schaefi schaefi deleted the setup_py_is_obsolete branch September 17, 2024 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants