[PATCH 2/9] pylibfdt: Correctly set build output directory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Our Makefile currently passes PYLIBFDT_objdir into setup.py in an attempt
to set the correct place to put the Python extension module output.  But
that gets passed in the 'package_dir' map in distutils.

But that's basically not what package_dir controls.  What actually makes us
find the module in the right place is the --inplace passed to setup.py
(causing the module to go into the current directory), and the following
'mv' in the Makefile to move it into the right final location.

We can simplify setup.py by dropping the useless objdir stuff, and get the
module put in the right place straight way by instead using the --build-lib
setup.py option.

Signed-off-by: David Gibson <david@xxxxxxxxxxxxxxxxxxxxx>
---
 pylibfdt/Makefile.pylibfdt |  6 ++----
 pylibfdt/setup.py          | 11 +++--------
 2 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/pylibfdt/Makefile.pylibfdt b/pylibfdt/Makefile.pylibfdt
index 9507d3d..0b5364e 100644
--- a/pylibfdt/Makefile.pylibfdt
+++ b/pylibfdt/Makefile.pylibfdt
@@ -6,15 +6,13 @@ PYLIBFDT_srcs = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_SRCS)) \
 PYMODULE = $(PYLIBFDT_objdir)/_libfdt.so
 
 define run_setup
-	SOURCES="$(1)" CPPFLAGS="$(CPPFLAGS)" OBJDIR="$(PYLIBFDT_objdir)"
-	VERSION="$(dtc_version)"
+	SOURCES="$(1)" CPPFLAGS="$(CPPFLAGS)" VERSION="$(dtc_version)"
 	$(PYLIBFDT_objdir)/setup.py --quiet $(2)
 endef
 
 $(PYMODULE): $(PYLIBFDT_srcs)
 	@$(VECHO) PYMOD $@
-	$(call run_setup, $^, build_ext --inplace)
-	mv _libfdt.so $@
+	$(call run_setup, $^, build_ext --build-lib=$(PYLIBFDT_objdir))
 
 install_pylibfdt: $(PYMODULE)
 	$(VECHO) INSTALL-PYLIB; \
diff --git a/pylibfdt/setup.py b/pylibfdt/setup.py
index 8d97ab8..a9e8051 100755
--- a/pylibfdt/setup.py
+++ b/pylibfdt/setup.py
@@ -7,7 +7,6 @@ Written by Simon Glass <sjg@xxxxxxxxxxxx>
 
 Files to be built into the extension are provided in SOURCES
 C flags to use are provided in CPPFLAGS
-Object file directory is provided in OBJDIR
 Version is provided in VERSION
 
 If these variables are not given they are parsed from the Makefiles. This
@@ -73,7 +72,6 @@ def GetEnvFromMakefiles():
             Version string
             List of files to build
             List of extra C preprocessor flags needed
-            Object directory to use (always '')
     """
     basedir = os.path.dirname(os.path.dirname(os.path.abspath(sys.argv[0])))
     makevars = ParseMakefile(os.path.join(basedir, 'Makefile'))
@@ -84,21 +82,19 @@ def GetEnvFromMakefiles():
     files = [os.path.join(basedir, 'libfdt', fname) for fname in files]
     files.append('pylibfdt/libfdt.i')
     cflags = ['-I%s/libfdt' % basedir]
-    objdir = ''
-    return  version, files, cflags, objdir
+    return  version, files, cflags
 
 
 progname = sys.argv[0]
 files = os.environ.get('SOURCES', '').split()
 cflags = os.environ.get('CPPFLAGS', '').split()
-objdir = os.environ.get('OBJDIR')
 version = os.environ.get('VERSION')
 
 # If we were called directly rather than through our Makefile (which is often
 # the case with Python module installation), read the settings from the
 # Makefile.
-if not all((version, files, cflags, objdir)):
-    version, files, cflags, objdir = GetEnvFromMakefiles()
+if not all((version, files, cflags)):
+    version, files, cflags= GetEnvFromMakefiles()
 
 libfdt_module = Extension(
     '_libfdt',
@@ -112,6 +108,5 @@ setup(
     author='Simon Glass <sjg@xxxxxxxxxxxx>',
     description='Python binding for libfdt',
     ext_modules=[libfdt_module],
-    package_dir={'': objdir},
     py_modules=['pylibfdt/libfdt'],
 )
-- 
2.17.1




[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux