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

Change to build for packaging #33

Open
MichaelKim0407 opened this issue Oct 31, 2023 · 2 comments
Open

Change to build for packaging #33

MichaelKim0407 opened this issue Oct 31, 2023 · 2 comments

Comments

@MichaelKim0407
Copy link
Owner

MichaelKim0407 commented Oct 31, 2023

Using setup.py to build is being deprecated:

SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!

        ********************************************************************************
        Please avoid running ``setup.py`` directly.
        Instead, use pypa/build, pypa/installer or other
        standards-based tools.

        See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
        ********************************************************************************

!!

Right now this library is maintenance-only, and I don't foresee any changes that would justify changing the build system. (Since we probably won't be releasing any new builds anyway.) Furthermore as the maintainer my primary concern is that my library works without introducing things I don't understand.

With that said, as this has been raised a few times (see #19 #31 #32), I'm opening this ticket to keep track of this issue and to create a place for discussion. I am open to be convinced. However I would like to ask people not to just come with a PR without discussing first.

@jmahlik
Copy link
Contributor

jmahlik commented Nov 6, 2023

Coming from #32 (comment). Jotting down some info here.

The main pros to adding a pyproject.toml now days would be:

  • Python 3.12+ no longer installs setuptools into virtualenvs by default. Pip is injecting setuptools for the time being, but that may change. If it does, users may have to install setuptools directly into the virtualenv.
  • Avoid installing setuptools directly into the virtualenv, since it doesn't come by default anymore, it's nice to not install it at all. The pyproject causes pip to make an isolated virtualenv with the build dependencies (setuptools) in it. So it doesn't have to be installed by a user manually.
  • pip may stop invoking the setup.py at some time in the future, it'd be great to ensure this package still works if that does occur. Adding the pyproject would make sure that happens.

The main cons:

  • Because pip will make an isolated venv, the package won't be importable before installed (from an sdist). Need to figure out a way to get the version info from the package without importing it.
    • Prefer not to do it by parsing the __init__.py as text similar to the last example here
    • There is a way to do it via the pyproject.toml's project section and dynamic metadata. Like the example here. That would require moving at least some of the project info from the setup.py into the pyproject.toml.
  • Requires building the project artifacts with a build frontend, build is a pretty minimal frontend but it is still a change.

@MichaelKim0407
Copy link
Owner Author

MichaelKim0407 commented Nov 7, 2023

I would like some clarification here. There are two different processes that currently involve setup.py: 1) building the package for release; 2) installing the package by users.

  1. When you say pip, are you referring to the installation process? I am confused because the issue we have here concerns the build process. Or does build invoke pip?
  2. In what process is pyproject.toml used? The build process, the installation process, or both?
  3. Why does pip make an isolated venv when installing? Does it only happen when pyproject.toml exists? And again, I ran into the problem when I ran build, but you are talking about the installation process, so I'm confused.

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

No branches or pull requests

2 participants