public inbox for gentoo-python@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-python] [PATCHES] Use pydistutils.cfg to pass build-dir
@ 2013-09-19 10:31 Michał Górny
  2013-09-19 10:31 ` [gentoo-python] [PATCH 1/3] Make HOME per-impl in addition to TMPDIR Michał Górny
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Michał Górny @ 2013-09-19 10:31 UTC (permalink / raw
  To: gentoo-python; +Cc: python

Currently, we're passing build-dir and stuff implicitly in esetup.py.
We're appending the 'build' and 'egg-info' commands which is confusing
and not always requested.

These patches use different approach for setting build-dir. We create
a per-implementation $HOME, and create .pydistutils.cfg there. This way,
we can set all the build-dirs without explicitly invoking any of
the commands.

Notes:

1. esetup.py no longer explicitly invokes 'build' and 'egg-info' -- can
be used more widely.

2. if esetup.py is called before python_compile(), it doesn't have
build-dir set yet. AFAICS this is not an issue but still worth noticing.

3. if some ebuild relied on 'esetup.py' implicitly appending 'build'
command, it needs to be fixed :).

4. implicit 'build' caused implicit rebuild in python_install() for
a few packages. That should be fixed now.

5. if some package overrides build dirs in setup.cfg, it will override
our setting. We need to see if that's a case somewhere and if it causes
trouble.

That's all I can think of. What do you think?

--
Best regards,
Michał Górny



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

* [gentoo-python] [PATCH 1/3] Make HOME per-impl in addition to TMPDIR.
  2013-09-19 10:31 [gentoo-python] [PATCHES] Use pydistutils.cfg to pass build-dir Michał Górny
@ 2013-09-19 10:31 ` Michał Górny
  2013-09-19 10:31 ` [gentoo-python] [PATCH 2/3] Move _distutils-r1_copy_egg_info to a better location Michał Górny
  2013-09-19 10:31 ` [gentoo-python] [PATCH 3/3] Set build-dir via configuration file rather than implicit options Michał Górny
  2 siblings, 0 replies; 4+ messages in thread
From: Michał Górny @ 2013-09-19 10:31 UTC (permalink / raw
  To: gentoo-python; +Cc: python, Michał Górny

---
 gx86/eclass/distutils-r1.eclass | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass
index dad6eed..2337891 100644
--- a/gx86/eclass/distutils-r1.eclass
+++ b/gx86/eclass/distutils-r1.eclass
@@ -545,9 +545,10 @@ distutils-r1_run_phase() {
 	fi
 	local -x PYTHONPATH="${BUILD_DIR}/lib:${PYTHONPATH}"
 
-	local TMPDIR=${T}/${EPYTHON}
+	local -x TMPDIR=${T}/${EPYTHON}
+	local -x HOME=${TMPDIR}/home
 
-	mkdir -p "${TMPDIR}" || die
+	mkdir -p "${TMPDIR}" "${HOME}" || die
 
 	"${@}"
 
-- 
1.8.3.2



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

* [gentoo-python] [PATCH 2/3] Move _distutils-r1_copy_egg_info to a better location.
  2013-09-19 10:31 [gentoo-python] [PATCHES] Use pydistutils.cfg to pass build-dir Michał Górny
  2013-09-19 10:31 ` [gentoo-python] [PATCH 1/3] Make HOME per-impl in addition to TMPDIR Michał Górny
@ 2013-09-19 10:31 ` Michał Górny
  2013-09-19 10:31 ` [gentoo-python] [PATCH 3/3] Set build-dir via configuration file rather than implicit options Michał Górny
  2 siblings, 0 replies; 4+ messages in thread
From: Michał Górny @ 2013-09-19 10:31 UTC (permalink / raw
  To: gentoo-python; +Cc: python, Michał Górny

---
 gx86/eclass/distutils-r1.eclass | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass
index 2337891..153a12e 100644
--- a/gx86/eclass/distutils-r1.eclass
+++ b/gx86/eclass/distutils-r1.eclass
@@ -323,18 +323,6 @@ _distutils-r1_disable_ez_setup() {
 	fi
 }
 
-# @FUNCTION: _distutils-r1_copy_egg_info
-# @INTERNAL
-# @DESCRIPTION:
-# Copy egg-info files to the ${BUILD_DIR} (that's going to become
-# egg-base in esetup.py). This way, we respect whatever's in upstream
-# egg-info.
-_distutils-r1_copy_egg_info() {
-	mkdir -p "${BUILD_DIR}" || die
-	# stupid freebsd can't do 'cp -t ${BUILD_DIR} {} +'
-	find -name '*.egg-info' -type d -exec cp -pr {} "${BUILD_DIR}"/ ';' || die
-}
-
 # @FUNCTION: distutils-r1_python_prepare_all
 # @DESCRIPTION:
 # The default python_prepare_all(). It applies the patches from PATCHES
@@ -386,6 +374,18 @@ distutils-r1_python_configure() {
 	:
 }
 
+# @FUNCTION: _distutils-r1_copy_egg_info
+# @INTERNAL
+# @DESCRIPTION:
+# Copy egg-info files to the ${BUILD_DIR} (that's going to become
+# egg-base in esetup.py). This way, we respect whatever's in upstream
+# egg-info.
+_distutils-r1_copy_egg_info() {
+	mkdir -p "${BUILD_DIR}" || die
+	# stupid freebsd can't do 'cp -t ${BUILD_DIR} {} +'
+	find -name '*.egg-info' -type d -exec cp -pr {} "${BUILD_DIR}"/ ';' || die
+}
+
 # @FUNCTION: distutils-r1_python_compile
 # @USAGE: [additional-args...]
 # @DESCRIPTION:
-- 
1.8.3.2



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

* [gentoo-python] [PATCH 3/3] Set build-dir via configuration file rather than implicit options.
  2013-09-19 10:31 [gentoo-python] [PATCHES] Use pydistutils.cfg to pass build-dir Michał Górny
  2013-09-19 10:31 ` [gentoo-python] [PATCH 1/3] Make HOME per-impl in addition to TMPDIR Michał Górny
  2013-09-19 10:31 ` [gentoo-python] [PATCH 2/3] Move _distutils-r1_copy_egg_info to a better location Michał Górny
@ 2013-09-19 10:31 ` Michał Górny
  2 siblings, 0 replies; 4+ messages in thread
From: Michał Górny @ 2013-09-19 10:31 UTC (permalink / raw
  To: gentoo-python; +Cc: python, Michał Górny

This has the advantage of not force-calling build in every setup.py
invocation.
---
 gx86/eclass/distutils-r1.eclass | 67 ++++++++++++++++++++---------------------
 1 file changed, 32 insertions(+), 35 deletions(-)

diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass
index 153a12e..2c8c5c8 100644
--- a/gx86/eclass/distutils-r1.eclass
+++ b/gx86/eclass/distutils-r1.eclass
@@ -215,45 +215,13 @@ fi
 #
 # setup.py will be passed the following, in order:
 # 1. ${mydistutilsargs[@]}
-# 2. The 'build' command and standard build options including ${BUILD_DIR}
-# 3. Any additional arguments passed to the esetup.py function.
+# 2. additional arguments passed to the esetup.py function.
 #
 # This command dies on failure.
 esetup.py() {
 	debug-print-function ${FUNCNAME} "${@}"
 
-	local add_args=()
-	if [[ ${BUILD_DIR} ]]; then
-		add_args+=(
-			build
-			--build-base "${BUILD_DIR}"
-
-			# using a single directory for them helps us export
-			# ${PYTHONPATH} and ebuilds find the sources independently
-			# of whether the package installs extensions or not
-			#
-			# note: due to some packages (wxpython) relying on separate
-			# platlib & purelib dirs, we do not set --build-lib (which
-			# can not be overriden with --build-*lib)
-			--build-platlib "${BUILD_DIR}/lib"
-			--build-purelib "${BUILD_DIR}/lib"
-
-			# make the ebuild writer lives easier
-			--build-scripts "${BUILD_DIR}/scripts"
-		)
-
-		# if setuptools is used, adjust egg_info path as well
-		if "${PYTHON:-python}" setup.py --help egg_info &>/dev/null; then
-			add_args+=(
-				egg_info --egg-base "${BUILD_DIR}"
-			)
-		fi
-	elif [[ ! ${DISTUTILS_IN_SOURCE_BUILD} ]]; then
-		die 'Out-of-source build requested, yet BUILD_DIR unset.'
-	fi
-
-	set -- "${PYTHON:-python}" setup.py \
-		"${mydistutilsargs[@]}" "${add_args[@]}" "${@}"
+	set -- "${PYTHON:-python}" setup.py "${mydistutilsargs[@]}" "${@}"
 
 	echo "${@}" >&2
 	"${@}" || die
@@ -374,6 +342,34 @@ distutils-r1_python_configure() {
 	:
 }
 
+# @FUNCTION: _distutils-r1_create_setup_cfg
+# @INTERNAL
+# @DESCRIPTION:
+# Create implementation-specific configuration file for distutils,
+# setting proper build-dir paths.
+_distutils-r1_create_setup_cfg() {
+	cat >> "${HOME}"/.pydistutils.cfg <<-_EOF_ || die
+		[build]
+		build-base = ${BUILD_DIR}
+
+		# using a single directory for them helps us export
+		# ${PYTHONPATH} and ebuilds find the sources independently
+		# of whether the package installs extensions or not
+		#
+		# note: due to some packages (wxpython) relying on separate
+		# platlib & purelib dirs, we do not set --build-lib (which
+		# can not be overriden with --build-*lib)
+		build-platlib = %(build-base)s/lib
+		build-purelib = %(build-base)s/lib
+
+		# make the ebuild writer lives easier
+		build-scripts = %(build-base)s/scripts
+
+		[egg_info]
+		egg-base = ${BUILD_DIR}
+	_EOF_
+}
+
 # @FUNCTION: _distutils-r1_copy_egg_info
 # @INTERNAL
 # @DESCRIPTION:
@@ -395,9 +391,10 @@ _distutils-r1_copy_egg_info() {
 distutils-r1_python_compile() {
 	debug-print-function ${FUNCNAME} "${@}"
 
+	_distutils-r1_create_setup_cfg
 	_distutils-r1_copy_egg_info
 
-	esetup.py "${@}"
+	esetup.py build "${@}"
 }
 
 # @FUNCTION: distutils-r1_python_test
-- 
1.8.3.2



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

end of thread, other threads:[~2013-09-19 10:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-19 10:31 [gentoo-python] [PATCHES] Use pydistutils.cfg to pass build-dir Michał Górny
2013-09-19 10:31 ` [gentoo-python] [PATCH 1/3] Make HOME per-impl in addition to TMPDIR Michał Górny
2013-09-19 10:31 ` [gentoo-python] [PATCH 2/3] Move _distutils-r1_copy_egg_info to a better location Michał Górny
2013-09-19 10:31 ` [gentoo-python] [PATCH 3/3] Set build-dir via configuration file rather than implicit options 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