commit:     3d8f12eae3c3f8996068e05aaa65cb97f0abaeb1
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 25 10:51:05 2022 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Jan 26 08:28:42 2022 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-syntax.git/commit/?id=3d8f12ea

newebuild: Modernize the Python template

Use PEP517 build.  It defaults to setuptools but the eclass will detect
if this is incorrect.

Add a default pypi HOMEPAGE based on the package name.

Skip DEPEND.  Python packages rarely need this class of dependencies,
RDEPEND + BDEPEND are much more common.

Add empty "test?" block in BDEPEND, as this is often necessary.
If it is not, it is easy to yank it.

Add distutils_enable_tests.  It defaults to pytest, as the most common
variant.  It will also trigger explicit failure if the package has
no tests.

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 plugin/newebuild.vim | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/plugin/newebuild.vim b/plugin/newebuild.vim
index 36db2dd..bd80712 100644
--- a/plugin/newebuild.vim
+++ b/plugin/newebuild.vim
@@ -21,6 +21,8 @@ fun! <SID>MakeNewEbuild()
     let l:filename = expand("%:p")
     let l:category = substitute(l:filename,
                 \ "^.*/\\([^/]\\+\\)/[^/]\\+/[^/]\\+\\.ebuild", "\\1", "g")
+    let l:package = substitute(l:filename,
+                \ "^.*/\\([^/]\\+\\)/[^/]\\+\\.ebuild", "\\1", "g")
 
     " use empty keywords for live ebuilds
     if l:filename =~# "-9999\\+.ebuild\$"
@@ -155,6 +157,7 @@ fun! <SID>MakeNewEbuild()
             " {{{ standard default setup
             " {{{ extra inherits for some categories
             if l:category ==# "dev-python"
+                put ='DISTUTILS_USE_PEP517=setuptools'
                 put ='PYTHON_COMPAT=( ' . GentooGetPythonTargets() . ' )'
                 put ='inherit distutils-r1'
                 put =''
@@ -162,7 +165,9 @@ fun! <SID>MakeNewEbuild()
             " }}}
 
             put ='DESCRIPTION=\"\"'
-            put ='HOMEPAGE=\"\"'
+            put ='HOMEPAGE=\"'
+            put ='     https://pypi.org/project/' . l:package . '/'
+            put ='\"'
             put ='SRC_URI=\"\"'
             put =''
             put ='LICENSE=\"\"'
@@ -171,9 +176,19 @@ fun! <SID>MakeNewEbuild()
             put =''
 
             " {{{ extra deps for some categories
-            put ='DEPEND=\"\"'
-            put ='RDEPEND=\"${DEPEND}\"'
-            put ='BDEPEND=\"\"'
+            if l:category ==# "dev-python"
+                put ='RDEPEND=\"\"'
+                put ='BDEPEND=\"'
+                put =' test? ('
+                put =' )'
+                put ='\"'
+                put =''
+                put ='distutils_enable_tests pytest'
+            else
+                put ='DEPEND=\"\"'
+                put ='RDEPEND=\"${DEPEND}\"'
+                put ='BDEPEND=\"\"'
+            endif
             " }}}
         endif
 

Reply via email to