Skip to content

use python -m build to build #318

Closed

Description

@egpbos

Currently, the developer readme suggests to use python3 setup.py sdist bdist_wheel to build packages, in a freshly created virtual environment too. The official Python packaging docs recommend using python -m build. I think we should switch to this, also for consistency because explicit use of setup.py is no longer recommended for installing the package either. Mainly though because it is a lot simpler; it creates the virtual environment itself and so makes the instructions a lot shorter.

This requires:

  1. Updating the README.dev.md instructions: replace almost all of the code in the first code block in subsection "2/3" with just python -m build (keep twine as well).
  2. Adding the build package to the dev extras section in setup.cfg.

While we're at it, the instructions should also note that an account on PyPI and on TestPyPI (two separate accounts) are necessary for using twine.

Activity

  1. added
    generated-packageRelated to the generated package, i.e. after running cookiecutter
    on Mar 18, 2022
  2. egpbos commented on Apr 8, 2022

    @egpbos
    CollaboratorAuthor

    As part of this, we should in fact remove setup.py altogether, since its use has been deprecated. See for instance https://packaging.python.org/en/latest/tutorials/packaging-projects/#configuring-metadata:

    Static metadata (setup.cfg) should be preferred. Dynamic metadata (setup.py) should be used only as an escape hatch when absolutely necessary. setup.py used to be required, but can be omitted with newer versions of setuptools and pip.

    And https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html

  3. egpbos commented on Apr 8, 2022

    @egpbos
    CollaboratorAuthor

    We should make sure that everything still works though. @bouweandela mentioned that possibly pip install -e . wouldn't work anymore and there were indeed discussions about this (https://discuss.python.org/t/pip-19-1-and-installing-in-editable-mode-with-pyproject-toml/1553/65). I tried it myself, and it doesn't seem to be a problem in my relatively fresh project, but there may be other things. For instance, I see that tox doesn't immediately work without setup.py, it mentions that it needs additional configuration when I remove setup.py:

    ERROR: pyproject.toml file found.
    To use a PEP 517 build-backend you are required to configure tox to use an isolated_build:
    https://tox.readthedocs.io/en/latest/example/package.html
    
  4. egpbos commented on Apr 8, 2022

    @egpbos
    CollaboratorAuthor

    The fix for tox is to just add isolated_build = True to the tox configuration section in pyproject.toml.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    generated-packageRelated to the generated package, i.e. after running cookiecutter

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions