Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Thu, 20 Feb 2020 09:42:37
Message-Id: 1582190335.894dd695f7be1e79f018f9cf3a1c6a13ba49eb71.mgorny@gentoo
1 commit: 894dd695f7be1e79f018f9cf3a1c6a13ba49eb71
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Sun Dec 22 12:13:18 2019 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Thu Feb 20 09:18:55 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=894dd695
7
8 distutils-r1.eclass: Add pyproject.toml support
9
10 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
11
12 eclass/distutils-r1.eclass | 29 +++++++++++++++++++++++++++++
13 1 file changed, 29 insertions(+)
14
15 diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
16 index e546aadfa4a..27ca236ccf5 100644
17 --- a/eclass/distutils-r1.eclass
18 +++ b/eclass/distutils-r1.eclass
19 @@ -86,6 +86,8 @@ esac
20 # - no -- do not add the dependency (pure distutils package)
21 # - bdepend -- add it to BDEPEND (the default)
22 # - rdepend -- add it to BDEPEND+RDEPEND (when using entry_points)
23 +# - pyproject.toml -- use pyproject2setuptools to install a project
24 +# using pyproject.toml (flit, poetry...)
25 # - manual -- do not add the depedency and suppress the checks
26 # (assumes you will take care of doing it correctly)
27 #
28 @@ -135,6 +137,9 @@ _distutils_set_globals() {
29 bdep+=" ${sdep}"
30 rdep+=" ${sdep}"
31 ;;
32 + pyproject.toml)
33 + bdep+=" dev-python/pyproject2setuppy[${PYTHON_USEDEP}]"
34 + ;;
35 *)
36 die "Invalid DISTUTILS_USE_SETUPTOOLS=${DISTUTILS_USE_SETUPTOOLS}"
37 ;;
38 @@ -457,6 +462,7 @@ distutils_enable_tests() {
39 _distutils_verify_use_setuptools() {
40 [[ ${DISTUTILS_OPTIONAL} ]] && return
41 [[ ${DISTUTILS_USE_SETUPTOOLS} == manual ]] && return
42 + [[ ${DISTUTILS_USE_SETUPTOOLS} == pyproject.toml ]] && return
43
44 # ok, those are cheap greps. we can try toimprove them if we hit
45 # false positives.
46 @@ -580,6 +586,28 @@ _distutils-r1_disable_ez_setup() {
47 fi
48 }
49
50 +# @FUNCTION: _distutils-r1_handle_pyproject_toml
51 +# @INTERNAL
52 +# @DESCRIPTION:
53 +# Generate setup.py for pyproject.toml if requested.
54 +_distutils-r1_handle_pyproject_toml() {
55 + if [[ ! -f setup.py && -f pyproject.toml ]]; then
56 + if [[ ${DISTUTILS_USE_SETUPTOOLS} == pyproject.toml ]]; then
57 + cat > setup.py <<-EOF || die
58 + #!/usr/bin/env python
59 + from pyproject2setuppy.main import main
60 + main()
61 + EOF
62 + chmod +x setup.py || die
63 + else
64 + eerror "No setup.py found but pyproject.toml is present. In order to enable"
65 + eerror "pyproject.toml support in distutils-r1, set:"
66 + eerror " DISTUTILS_USE_SETUPTOOLS=pyproject.toml"
67 + die "No setup.py found and DISTUTILS_USE_SETUPTOOLS!=pyproject.toml"
68 + fi
69 + fi
70 +}
71 +
72 # @FUNCTION: distutils-r1_python_prepare_all
73 # @DESCRIPTION:
74 # The default python_prepare_all(). It applies the patches from PATCHES
75 @@ -608,6 +636,7 @@ distutils-r1_python_prepare_all() {
76 fi
77
78 _distutils-r1_disable_ez_setup
79 + _distutils-r1_handle_pyproject_toml
80
81 if [[ ${DISTUTILS_IN_SOURCE_BUILD} && ! ${DISTUTILS_SINGLE_IMPL} ]]
82 then