Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH 1/3] distutils-r1.eclass: Fix setuptools without setup.py
Date: Sat, 06 Feb 2021 11:54:21
Message-Id: 20210206115408.118297-1-mgorny@gentoo.org
1 Invoke pyproject2setuppy directly instead of writing the setup.py
2 wrapper. This is necessary to correctly support setuptools via
3 pyproject.toml without setup.py. Writing setup.py confuses
4 pyproject2setuppy into running the setup.py code path instead of
5 the correct non-setup.py path.
6
7 Signed-off-by: Michał Górny <mgorny@g.o>
8 ---
9 eclass/distutils-r1.eclass | 17 ++++++++---------
10 1 file changed, 8 insertions(+), 9 deletions(-)
11
12 diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
13 index d5bb0df4d927..cb64938c8c32 100644
14 --- a/eclass/distutils-r1.eclass
15 +++ b/eclass/distutils-r1.eclass
16 @@ -523,7 +523,13 @@ esetup.py() {
17
18 [[ ${BUILD_DIR} ]] && _distutils-r1_create_setup_cfg
19
20 - set -- "${EPYTHON:-python}" setup.py "${mydistutilsargs[@]}" "${@}"
21 + local setup_py=( setup.py )
22 + if [[ ${DISTUTILS_USE_SETUPTOOLS} == pyproject.toml ]]; then
23 + # TODO: remove '.main' when we require v10
24 + setup_py=( -m pyproject2setuppy.main )
25 + fi
26 +
27 + set -- "${EPYTHON:-python}" "${setup_py[@]}" "${mydistutilsargs[@]}" "${@}"
28
29 echo "${@}" >&2
30 "${@}" || die "${die_args[@]}"
31 @@ -632,14 +638,7 @@ _distutils-r1_disable_ez_setup() {
32 # Generate setup.py for pyproject.toml if requested.
33 _distutils-r1_handle_pyproject_toml() {
34 if [[ ! -f setup.py && -f pyproject.toml ]]; then
35 - if [[ ${DISTUTILS_USE_SETUPTOOLS} == pyproject.toml ]]; then
36 - cat > setup.py <<-EOF || die
37 - #!/usr/bin/env python
38 - from pyproject2setuppy.main import main
39 - main()
40 - EOF
41 - chmod +x setup.py || die
42 - else
43 + if [[ ${DISTUTILS_USE_SETUPTOOLS} != pyproject.toml ]]; then
44 eerror "No setup.py found but pyproject.toml is present. In order to enable"
45 eerror "pyproject.toml support in distutils-r1, set:"
46 eerror " DISTUTILS_USE_SETUPTOOLS=pyproject.toml"
47 --
48 2.30.0

Replies