public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH 1/3] distutils-r1.eclass: Run build_ext only if there are 2+ files
@ 2022-04-22  7:50 Michał Górny
  2022-04-22  7:50 ` [gentoo-dev] [PATCH 2/3] distutils-r1.eclass: Run build_ext only with --jobs -gt 1 Michał Górny
  2022-04-22  7:50 ` [gentoo-dev] [PATCH 3/3] distutils-r1.eclass: Account for func args when counting makejobs Michał Górny
  0 siblings, 2 replies; 3+ messages in thread
From: Michał Górny @ 2022-04-22  7:50 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

Run parallel build_ext only if there are at least two potential source
files to compile.  This call is expensive and parallel builds do not
benefit us if there is only one file to compile.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 eclass/distutils-r1.eclass | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index 5528ff74cccf..d213cca4bb72 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -1189,14 +1189,18 @@ distutils-r1_python_compile() {
 		fi
 
 		if [[ ${DISTUTILS_USE_PEP517} && ${GPEP517_TESTING} ]]; then
-			# issue build_ext only if it looks like we have something
-			# to build; setuptools is expensive to start
+			# issue build_ext only if it looks like we have at least
+			# two source files to build; setuptools is expensive
+			# to start and parallel builds can only benefit us if we're
+			# compiling at least two files
+			#
 			# see extension.py for list of suffixes
 			# .pyx is added for Cython
-			if [[ -n $(
+			if [[ 2 -eq $(
 				find '(' -name '*.c' -o -name '*.cc' -o -name '*.cpp' \
 					-o -name '*.cxx' -o -name '*.c++' -o -name '*.m' \
-					-o -name '*.mm' -o -name '*.pyx' ')' -print -quit
+					-o -name '*.mm' -o -name '*.pyx' ')' -printf '\n' |
+					head -n 2 | wc -l
 			) ]]; then
 				esetup.py build_ext -j "${jobs}" "${@}"
 			fi
-- 
2.35.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [gentoo-dev] [PATCH 2/3] distutils-r1.eclass: Run build_ext only with --jobs -gt 1
  2022-04-22  7:50 [gentoo-dev] [PATCH 1/3] distutils-r1.eclass: Run build_ext only if there are 2+ files Michał Górny
@ 2022-04-22  7:50 ` Michał Górny
  2022-04-22  7:50 ` [gentoo-dev] [PATCH 3/3] distutils-r1.eclass: Account for func args when counting makejobs Michał Górny
  1 sibling, 0 replies; 3+ messages in thread
From: Michał Górny @ 2022-04-22  7:50 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 eclass/distutils-r1.eclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index d213cca4bb72..c314c52a78cd 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -1196,7 +1196,7 @@ distutils-r1_python_compile() {
 			#
 			# see extension.py for list of suffixes
 			# .pyx is added for Cython
-			if [[ 2 -eq $(
+			if [[ 1 -ne ${jobs} && 2 -eq $(
 				find '(' -name '*.c' -o -name '*.cc' -o -name '*.cpp' \
 					-o -name '*.cxx' -o -name '*.c++' -o -name '*.m' \
 					-o -name '*.mm' -o -name '*.pyx' ')' -printf '\n' |
-- 
2.35.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [gentoo-dev] [PATCH 3/3] distutils-r1.eclass: Account for func args when counting makejobs
  2022-04-22  7:50 [gentoo-dev] [PATCH 1/3] distutils-r1.eclass: Run build_ext only if there are 2+ files Michał Górny
  2022-04-22  7:50 ` [gentoo-dev] [PATCH 2/3] distutils-r1.eclass: Run build_ext only with --jobs -gt 1 Michał Górny
@ 2022-04-22  7:50 ` Michał Górny
  1 sibling, 0 replies; 3+ messages in thread
From: Michał Górny @ 2022-04-22  7:50 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

Account for distutils-r1_python_compile arguments when counting
makejobs.  This is needed to correctly detect forced "-j1",
e.g. in dev-python/pandas.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 eclass/distutils-r1.eclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index c314c52a78cd..4b376d6a1cc5 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -1182,7 +1182,7 @@ distutils-r1_python_compile() {
 		fi
 
 		# distutils is parallel-capable since py3.5
-		local jobs=$(makeopts_jobs "${MAKEOPTS}" INF)
+		local jobs=$(makeopts_jobs "${MAKEOPTS} ${*}" INF)
 		if [[ ${jobs} == INF ]]; then
 			local nproc=$(get_nproc)
 			jobs=$(( nproc + 1 ))
-- 
2.35.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-04-22  7:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-22  7:50 [gentoo-dev] [PATCH 1/3] distutils-r1.eclass: Run build_ext only if there are 2+ files Michał Górny
2022-04-22  7:50 ` [gentoo-dev] [PATCH 2/3] distutils-r1.eclass: Run build_ext only with --jobs -gt 1 Michał Górny
2022-04-22  7:50 ` [gentoo-dev] [PATCH 3/3] distutils-r1.eclass: Account for func args when counting makejobs Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox