[SRU] python3-build cannot create venv virtual environment

Bug #1992108 reported by Enrique
22
This bug affects 4 people
Affects Status Importance Assigned to Milestone
python-build (Debian)
Fix Released
Unknown
python-build (Ubuntu)
Fix Released
Undecided
Unassigned
Jammy
Fix Committed
Undecided
Unassigned

Bug Description

[ Impact ]

The version in Ubuntu 22.04 of python3-build cannot create a virtual
environment, which severely hampers the use of the package. While this
can be worked around to some extent by installing python3-virtualenv,
this still fails with the use of interpreters from deadsnakes.

Given the intent of the package is to cleanly build sdist and binary
wheels, e.g. for PyPI, the ability to work with deadsnakes
interpreters is extremely useful.

[ Test Plan ]

* Verify the current situation in a jammy instance / container:

sudo apt install python3-build python3-venv
mkdir myproj
cd myproj
cat << EOF > pyproject.toml
[build-system]
# Minimum requirements for the build system to execute.
requires = ["setuptools >= 40.6.0", "wheel", "numpy"]
build-backend = "setuptools.build_meta"
EOF
python3 -m build .

* Verify this fails with the error Virtual environment creation
  failed
* Enable proposed (https://wiki.ubuntu.com/Testing/EnableProposed)
* Upgrade python3-build and check the error no longer occurs:

sudo apt install -t jammy-proposed python3-build
python3 -m build .

* Verify this produces a valid sdist and wheel (for UNKNOWN 0.0.0)

[ Regression Potential ]

Given the package does not currently work without workarounds, the
potential for regression is already pretty low. The backported version
is the same upstream version, and simply adds a single Debian patch to
work around the issue. The patched version was already present in
lunar, and worked without incident there.

There is one concerning reverse dependency, which is dh-python (which
relies on this package for handling pyproject builds), however in
mitigation I again note that the updated version worked without issue
in lunar.

[ Original Description ]

The version in Ubuntu 22.04 of python3-build cannot create a virtual environment, which makes the package rather unusable.
For instance, in a directory with a file pyproject.toml like this:
# cat pyproject.toml
[build-system]
# Minimum requirements for the build system to execute.
requires = ["setuptools >= 40.6.0", "wheel", "numpy"]
build-backend = "setuptools.build_meta"

If running "python3 -m build ." one gets the following:
# python3 -m build .
* Creating venv isolated environment...

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/build/__main__.py", line 372, in main
    built = build_call(
  File "/usr/lib/python3/dist-packages/build/__main__.py", line 229, in build_package_via_sdist
    sdist = _build(isolation, builder, outdir, 'sdist', config_settings, skip_dependency_check)
  File "/usr/lib/python3/dist-packages/build/__main__.py", line 140, in _build
    return _build_in_isolated_env(builder, outdir, distribution, config_settings)
  File "/usr/lib/python3/dist-packages/build/__main__.py", line 104, in _build_in_isolated_env
    with _IsolatedEnvBuilder() as env:
  File "/usr/lib/python3/dist-packages/build/env.py", line 104, in __enter__
    executable, scripts_dir = _create_isolated_env_venv(self._path)
  File "/usr/lib/python3/dist-packages/build/env.py", line 258, in _create_isolated_env_venv
    executable, script_dir, purelib = _find_executable_and_scripts(path)
  File "/usr/lib/python3/dist-packages/build/env.py", line 303, in _find_executable_and_scripts
    raise RuntimeError(f'Virtual environment creation failed, executable {executable} missing')
RuntimeError: Virtual environment creation failed, executable /tmp/build-env-iz5c20gn/local/bin/python missing

ERROR Virtual environment creation failed, executable /tmp/build-env-iz5c20gn/local/bin/python missing

This seems to be the same error as reported elsewhere (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1009916, https://github.com/pypa/build/pull/463).
The patched version python3-build 0.7.0-3 in Ubuntu 22.10 already fixes that.

It would be great if the patch is also applied to Ubuntu 22.04, since otherwise the main method to build python packages is kind of broken in an Ubuntu LTS version.

The patch seems to be this one (but I have not tried it myself):
https://sources.debian.org/src/python-build/0.7.0-3/debian/patches/debian-sysconfig-layouts.patch/

Thank you!

ProblemType: Bug
DistroRelease: Ubuntu 22.04
Package: python3-build 0.7.0-2
ProcVersionSignature: Ubuntu 4.15.0-189.200-generic 4.15.18
Uname: Linux 4.15.0-189-generic x86_64
ApportVersion: 2.20.11-0ubuntu82.1
Architecture: amd64
CasperMD5CheckResult: unknown
Date: Fri Oct 7 01:08:34 2022
PackageArchitecture: all
SourcePackage: python-build
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Enrique (enrique-garcia) wrote :
Revision history for this message
Francesco Mauro (skz5k2) wrote :

a quick fix I used is
python3 -m pip install --upgrade build

bug still present
package install today
Distributor ID: Ubuntu
Description: Ubuntu 22.04.2 LTS
Release: 22.04
Codename: jammy
Date: Sat Jun 3 08:01:18 PM -04 2023

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in python-build (Ubuntu):
status: New → Confirmed
Revision history for this message
Dave Jones (waveform) wrote :

Yes, this is indeed the issue that 0.7.0-3 fixed, which it would seem would be reasonable to backport (same upstream version as is currently in jammy, with addition of one patch from Debian to fix the issue). I'll prepare an upload.

summary: - pyhon3-build cannot create venv virtual environment
+ [SRU] python3-build cannot create venv virtual environment
Dave Jones (waveform)
description: updated
Changed in python-build (Ubuntu):
status: Confirmed → In Progress
Changed in python-build (Debian):
status: Unknown → Fix Released
Revision history for this message
Timo Aaltonen (tjaalton) wrote : Please test proposed package

Hello Enrique, or anyone else affected,

Accepted python-build into jammy-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/python-build/0.7.0-2ubuntu0.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-jammy to verification-done-jammy. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-jammy. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in python-build (Ubuntu):
status: In Progress → Fix Released
Changed in python-build (Ubuntu Jammy):
status: New → Fix Committed
tags: added: verification-needed verification-needed-jammy
Revision history for this message
Ubuntu SRU Bot (ubuntu-sru-bot) wrote : Autopkgtest regression report (python-build/0.7.0-2ubuntu0.1)

All autopkgtests for the newly accepted python-build (0.7.0-2ubuntu0.1) for jammy have finished running.
The following regressions have been reported in tests triggered by the package:

dh-python/5.20220403 (amd64)

Please visit the excuses page listed below and investigate the failures, proceeding afterwards as per the StableReleaseUpdates policy regarding autopkgtest regressions [1].

https://people.canonical.com/~ubuntu-archive/proposed-migration/jammy/update_excuses.html#python-build

[1] https://wiki.ubuntu.com/StableReleaseUpdates#Autopkgtest_Regressions

Thank you!

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.