From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 176EC138334 for ; Tue, 24 Dec 2019 11:42:54 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D0C5DE0BB8; Tue, 24 Dec 2019 11:42:49 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 64FA4E0BAD for ; Tue, 24 Dec 2019 11:42:49 +0000 (UTC) Received: from localhost.localdomain (c142-245.icpnet.pl [85.221.142.245]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mgorny) by smtp.gentoo.org (Postfix) with ESMTPSA id 5B8B334DB22; Tue, 24 Dec 2019 11:42:46 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= To: gentoo-dev@lists.gentoo.org Cc: python@gentoo.org, =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Subject: [gentoo-dev] [PATCH] distutils-r1.eclass: Add pyproject.toml support Date: Tue, 24 Dec 2019 12:42:14 +0100 Message-Id: <20191224114214.301636-1-mgorny@gentoo.org> X-Mailer: git-send-email 2.24.1 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Archives-Salt: 10cb6ebd-8dde-4346-a51e-f2c62ff9cc62 X-Archives-Hash: edb2673aa74ad01de7fe7413c0423a8e Signed-off-by: Michał Górny --- eclass/distutils-r1.eclass | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass index 65294a065da7..c3d2b9fc11c3 100644 --- a/eclass/distutils-r1.eclass +++ b/eclass/distutils-r1.eclass @@ -86,6 +86,8 @@ esac # - no -- do not add the dependency (pure distutils package) # - bdepend -- add it to BDEPEND (the default) # - rdepend -- add it to BDEPEND+RDEPEND (when using entry_points) +# - pyproject.toml -- use pyproject2setuptools to install a project +# using pyproject.toml (flit, poetry...) # - manual -- do not add the depedency and suppress the checks # (assumes you will take care of doing it correctly) # @@ -127,6 +129,9 @@ _distutils_set_globals() { bdep+=" dev-python/setuptools[${PYTHON_USEDEP}]" rdep+=" dev-python/setuptools[${PYTHON_USEDEP}]" ;; + pyproject.toml) + bdep+=" dev-python/pyproject2setuppy[${PYTHON_USEDEP}]" + ;; *) die "Invalid DISTUTILS_USE_SETUPTOOLS=${DISTUTILS_USE_SETUPTOOLS}" ;; @@ -439,6 +444,7 @@ distutils_enable_tests() { _distutils_verify_use_setuptools() { [[ ${DISTUTILS_OPTIONAL} ]] && return [[ ${DISTUTILS_USE_SETUPTOOLS} == manual ]] && return + [[ ${DISTUTILS_USE_SETUPTOOLS} == pyproject.toml ]] && return # ok, those are cheap greps. we can try toimprove them if we hit # false positives. @@ -560,6 +566,28 @@ _distutils-r1_disable_ez_setup() { fi } +# @FUNCTION: _distutils-r1_handle_pyproject_toml +# @INTERNAL +# @DESCRIPTION: +# Generate setup.py for pyproject.toml if requested. +_distutils-r1_handle_pyproject_toml() { + if [[ ! -f setup.py && -f pyproject.toml ]]; then + if [[ ${DISTUTILS_USE_SETUPTOOLS} == pyproject.toml ]]; then + cat > setup.py <<-EOF || die + #!/usr/bin/env python + from pyproject2setuppy.main import main + main() + EOF + chmod +x setup.py || die + else + eerror "No setup.py found but pyproject.toml is present. In order to enable" + eerror "pyproject.toml support in distutils-r1, set:" + eerror " DISTUTILS_USE_SETUPTOOLS=pyproject.toml" + die "No setup.py found and DISTUTILS_USE_SETUPTOOLS!=pyproject.toml" + fi + fi +} + # @FUNCTION: distutils-r1_python_prepare_all # @DESCRIPTION: # The default python_prepare_all(). It applies the patches from PATCHES @@ -588,6 +616,7 @@ distutils-r1_python_prepare_all() { fi _distutils-r1_disable_ez_setup + _distutils-r1_handle_pyproject_toml if [[ ${DISTUTILS_IN_SOURCE_BUILD} && ! ${DISTUTILS_SINGLE_IMPL} ]] then -- 2.24.1