Text of discuss.python.org › t › best-practice-suggestions-including-bootstrap › 12202 as Styx crawled it on Nov 20, 2026. The page may have changed since. Only its words are kept, without pictures or layout, and only the first part of a long page.

Open the live page

Best practice suggestions (including bootstrap) - Packaging - Discussions on Python.org

Best practice suggestions (including bootstrap) Packaging _wiz (Thomas Klausner) November 25, 2021, 9:58pm 1 Hi! pkgsrc has a lot of packages for python modules. I’ve read Why you shouldn't invoke setup.py directly and discovered that the method pkgsrc currently used is going away (setup.py build/setup.py test/setup.py install). I’d like to know to what method we should switch. Some more context/requirements: pkgsrc installs the modules into ${PREFIX}/lib/python${PYVERSION}/site-packages so that they are available for all users pkgsrc provides binary packages for all supported python versions that are also supported by the module pkgsrc only packages the latest version (except for the cases where an older version is needed for python 2.x compatibility, then both this and the latest version are packaged) the bootstrap path currently is: install distuils (comes with python) use it to install setuptools use either of these to install everything else .py, .pyo and .pyc files are installed I’m interested in learning best practices about this (since a lot of time has passed since someone really invested time into this part of pkgsrc) and also what we should switch to, as noted above.

Thanks, Thomas 1 Like brettcannon (Brett Cannon) November 25, 2021, 10:43pm 2 For building you should use GitHub - pypa/build: A simple, correct Python build frontend and move over to pyproject.toml . You can use https://cibuildwheel.readthedocs.io/ if you want help building wheels (which you want to always create). For testing, there is no equivalent replacement, but that’s always been tool-specific. Most people like using Nox and Tox for this sort of thing.

For installation, it depends on why you are executing the installation manually on your project. If it’s for testing you can use pip -e . . If you’re installing a wheel or something from disk you can always pass the path to pip. _wiz (Thomas Klausner) November 25, 2021, 11:02pm 3 Hi! Thanks for the reply, @brettcannon . I think it’s not quite what I was looking for. I’m not maintaining a python module myself, I’m coming from the distro side of things.

What would I use a wheel for? pkgsrc has a binary package format that I want to use for python module binary packages as well. I took a look at build today, and if I’m not mistaken, it depends on packaging, tomli, pep517, and colorama. So before I can use build, I have to install those. They have some more dependencies, e.g. packaging needs pyparsing etc. But how do I build and install those dependencies before I have a build package?

For pkgsrc, I need a bootstrap path that starts from python-only. I hope that makes it clearer. Thomas brettcannon (Brett Cannon) November 25, 2021, 11:10pm 4 It’s what you install a Python package from. It contains all the files and data on what files go where. You can use GitHub - pradyunsg/installer: A fork for making that other thing better. to help do the initial installation of whatever you need. But Python also ships with pip for most installations and so you (should) already have a way to do installs to solve your bootstrapping problem.

But the key thing is you can’t assume setuptools (i.e. setup.py ) is used for all Python packages. FFY00 (Filipe Laíns) November 25, 2021, 11:19pm 5 I have written GitHub - FFY00/python-bootstrap: Helper script to bootstrap a Python environment to help with this, it is a script that runs GitHub - pypa/build: A simple, correct PEP 517 build frontend and GitHub - pradyunsg/installer: A low-level library for installing from a Python wheel distribution. (with Add CLI by FFY00 · Pull Request #66 · pradyunsg/installer · GitHub ) from source to build and install the required tooling to start building and installing Python packages.

I am planning to propose it for PyPA inclusion but wanted to write some docs about the bootstrapping process first. distutils is deprecated and will be removed in Python 3.12, so I wanted to get the bootstrapping process in shape before that. 1 Like _wiz (Thomas Klausner) November 25, 2021, 11:34pm 6 I think we’re still talking past each other. I’m not using wheels. pkgsrc builds (pkgsrc) binary packages from pypi source package files and installs them using pkgsrc tools. pip is not part of python.

There is a separate pip package on pypi. But perhaps it’s the right way for the future, I don’t know, that’s why I’m here. pip does not seem to have any dependencies (except that I need to install pip itself from sources using only python, into my ${PREFIX}). How can I do that? From the documentation, installer looks like the wrong tool, since it uses wheels and I want to use pkgsrc binary packages. _wiz (Thomas Klausner) November 25, 2021, 11:36pm 7 Hi Filipe!

Thanks for the pointer. I’m not sure how this fits into my bootstrapping story, but the example doesn’t work for me. I git cloned it and ran python -m bootstrap.build , and got an error: Traceback (most recent call last): File "/usr/pkg/lib/python3.9/runpy.py", line 188, in _run_module_as_main mod_name, mod_spec, code = _get_module_details(mod_name, _Error) File "/usr/pkg/lib/python3.9/runpy.py", line 111, in _get_module_details __import__(pkg_name) File "/tmp/python-bootstrap/bootstrap/__init__.py", line 78, in <module> shutil.copytree( File "/usr/pkg/lib/python3.9/shutil.py", line 564, in copytree with os.scandir(src) as itr: FileNotFoundError: [Errno 2] No such file or directory: '/tmp/python-bootstrap/external/build/src/build' FFY00 (Filipe Laíns) November 26, 2021, 12:34am 8 Did you also clone the submodules? _wiz (Thomas Klausner) November 26, 2021, 9:15am 9 Filipe, no, I had not, but now I have and something’s still missing: wiz@yt:/tmp/python-bootstrap> git submodule init Submodule 'external/build' (https://github.com/pypa/build.git) registered for path 'external/build' Submodule 'external/flit' (https://github.com/takluyver/flit.git) registered for path 'external/flit' Submodule 'external/installer' (https://github.com/FFY00/installer.git) registered for path 'external/installer' Submodule 'external/pep517' (https://github.com/pypa/pep517.git) registered for path 'external/pep517' Submodule 'external/setuptools' (https://github.com/pypa/setuptools.git) registered for path 'external/setuptools' Submodule 'external/tomli' (https://github.com/hukkin/tomli.git) registered for path 'external/tomli' Submodule 'external/wheel' (https://github.com/pypa/wheel.git) registered for path 'external/wheel' wiz@yt:/tmp/python-bootstrap> git submodule update Cloning into '/tmp/python-bootstrap/external/build'...

Cloning into '/tmp/python-bootstrap/external/flit'... Cloning into '/tmp/python-bootstrap/external/installer'... Cloning into '/tmp/python-bootstrap/external/pep517'... Cloning into '/tmp/python-bootstrap/external/setuptools'... Cloning into '/tmp/python-bootstrap/external/tomli'... Cloning into '/tmp/python-bootstrap/external/wheel'... Submodule path 'external/build': checked out 'c940180b6ace5210e6f00149d45b1358f39fb274' Submodule path 'external/flit': checked out '8b601d3222807c92004967ab3e2b89a627912aab' Submodule path 'external/installer': checked out 'a8710697695b78d8a5b43ca61420b4cc31cdd199' Submodule path 'external/pep517': checked out 'c4848b8899845e6ed746c75698634daa40dcc101' Submodule path 'external/setuptools': checked out '4bce6d5a30accecc848d8e7f0dabd212bfea9475' Submodule path 'external/tomli': checked out '9d416d91656fa14cd48eb97e20d3f0c72257fea6' Submodule path 'external/wheel': checked out 'b8c4aa055cea0132776e7e53edce3538710d5b68' wiz@yt:/tmp/python-bootstrap> python3 -m bootstrap.build Traceback (most recent call last): File "/usr/pkg/lib/python3.9/runpy.py", line 188, in _run_module_as_main mod_name, mod_spec, code = _get_module_details(mod_name, _Error) File "/usr/pkg/lib/python3.9/runpy.py", line 111, in _get_module_details __import__(pkg_name) File "/tmp/python-bootstrap/bootstrap/__init__.py", line 75, in <module> MODULES.mkdir(parents=True) File "/usr/pkg/lib

The rest of this page is on the live site.