All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/6] pylibfdt: Add installation support
@ 2017-03-29 18:15 Simon Glass
       [not found] ` <20170329181541.28856-1-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
  0 siblings, 1 reply; 12+ messages in thread
From: Simon Glass @ 2017-03-29 18:15 UTC (permalink / raw)
  To: Devicetree Compiler; +Cc: Mike Frysinger, David Gibson, Simon Glass

This series adds support for installation of the Pylib module. It adjusts
the setup.py file to provide this functionality and the Makefile rules
to call it correctly.

It also adds a way to disable building the Python module. This is useful
since some build systems want to use setup.py to do both the build and
the install step. In this case the correct build commands would be:

   make NO_PYTHON=1
   make install_pylibfdt SETUP_PREFIX=/path/to/install_prefix

Version 2 adds support for running setup.py stand-alone.

Changes in v2:
- Add a comment about the VERSION environment variable
- Add new patch to rename libfdt.swig to libfdt.i
- Add new patch to allow setup.py to operation stand-alone
- Rebase to master

Simon Glass (6):
  pylibfdt: Allow building to be disabled
  pylibfdt: Enable installation of Python module
  pylibfdt: Use the correct libfdt version in the module
  pylibfdt: Use the call function to simplify the Makefile
  pylibfdt: Rename libfdt.swig to libfdt.i
  pylibfdt: Allow setup.py to operation stand-alone

 Makefile                           |  3 +-
 README                             | 21 +++++++++
 pylibfdt/Makefile.pylibfdt         | 21 +++++++--
 pylibfdt/{libfdt.swig => libfdt.i} |  0
 pylibfdt/setup.py                  | 97 ++++++++++++++++++++++++++++++++++++--
 5 files changed, 133 insertions(+), 9 deletions(-)
 rename pylibfdt/{libfdt.swig => libfdt.i} (100%)

-- 
2.12.2.564.g063fe858b8-goog

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

* [PATCH v2 1/6] pylibfdt: Allow building to be disabled
       [not found] ` <20170329181541.28856-1-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
@ 2017-03-29 18:15   ` Simon Glass
  2017-03-29 18:15   ` [PATCH v2 2/6] pylibfdt: Enable installation of Python module Simon Glass
                     ` (6 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Simon Glass @ 2017-03-29 18:15 UTC (permalink / raw)
  To: Devicetree Compiler; +Cc: Mike Frysinger, David Gibson, Simon Glass

Some build systems want to build python libraries separately from the
rest of the build.

Add a NO_PYTHON option to enable this.

Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---

Changes in v2: None

 Makefile | 1 +
 README   | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/Makefile b/Makefile
index e6d8251..5cf4aee 100644
--- a/Makefile
+++ b/Makefile
@@ -120,6 +120,7 @@ SCRIPTS = dtdiff
 # We need both Python and swig to build pylibfdt.
 .PHONY: maybe_pylibfdt
 maybe_pylibfdt: FORCE
+	if [ -n "${NO_PYTHON}" ]; then exit; fi; \
 	if $(PKG_CONFIG) --cflags python >/dev/null 2>&1; then \
 		if which swig >/dev/null 2>&1; then \
 			can_build=yes; \
diff --git a/README b/README
index 96d8486..d2323fd 100644
--- a/README
+++ b/README
@@ -50,6 +50,12 @@ If you add new features, please check code coverage:
     # Open 'htmlcov/index.html' in your browser
 
 
+To disable building the python library, even if swig and Python are available,
+use:
+
+    make NO_PYTHON=1
+
+
 More work remains to support all of libfdt, including access to numeric
 values.
 
-- 
2.12.2.564.g063fe858b8-goog

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

* [PATCH v2 2/6] pylibfdt: Enable installation of Python module
       [not found] ` <20170329181541.28856-1-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
  2017-03-29 18:15   ` [PATCH v2 1/6] pylibfdt: Allow building to be disabled Simon Glass
@ 2017-03-29 18:15   ` Simon Glass
  2017-03-29 18:15   ` [PATCH v2 3/6] pylibfdt: Use the correct libfdt version in the module Simon Glass
                     ` (5 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Simon Glass @ 2017-03-29 18:15 UTC (permalink / raw)
  To: Devicetree Compiler; +Cc: Mike Frysinger, David Gibson, Simon Glass

Adjust the setup script to support installation, and call it from the
Makefile if enabled. It will be disabled if we were unable to build the
module (e.g. due to swig being missing), or the NO_PYTHON environment
variable is set.

Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---

Changes in v2: None

 Makefile                   |  2 +-
 README                     |  7 +++++++
 pylibfdt/Makefile.pylibfdt | 14 ++++++++++++++
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 5cf4aee..52ff72c 100644
--- a/Makefile
+++ b/Makefile
@@ -195,7 +195,7 @@ install-includes:
 	$(INSTALL) -d $(DESTDIR)$(INCLUDEDIR)
 	$(INSTALL) -m 644 $(LIBFDT_include) $(DESTDIR)$(INCLUDEDIR)
 
-install: install-bin install-lib install-includes
+install: install-bin install-lib install-includes maybe_install_pylibfdt
 
 $(VERSION_FILE): Makefile FORCE
 	$(call filechk,version)
diff --git a/README b/README
index d2323fd..5add557 100644
--- a/README
+++ b/README
@@ -50,6 +50,13 @@ If you add new features, please check code coverage:
     # Open 'htmlcov/index.html' in your browser
 
 
+To install the library use:
+
+    make install_pylibfdt SETUP_PREFIX=/path/to/install_dir
+
+If SETUP_PREFIX is not provided, the default prefix is used, typically '/usr'
+or '/usr/local'. See Python's distutils documentation for details.
+
 To disable building the python library, even if swig and Python are available,
 use:
 
diff --git a/pylibfdt/Makefile.pylibfdt b/pylibfdt/Makefile.pylibfdt
index 861e67c..a0271da 100644
--- a/pylibfdt/Makefile.pylibfdt
+++ b/pylibfdt/Makefile.pylibfdt
@@ -14,4 +14,18 @@ $(WRAP): $(PYLIBFDT_srcdir)/libfdt.swig
 	@$(VECHO) SWIG $@
 	$(SWIG) -python -o $@ $<
 
+install_pylibfdt: $(WRAP) $(PYMODULE)
+	$(VECHO) INSTALL-PYLIB; \
+	SOURCES="$(PYLIBFDT_srcs) $(WRAP)" CPPFLAGS="$(CPPFLAGS)" \
+	OBJDIR="$(PYLIBFDT_objdir)" \
+	python $(PYLIBFDT_objdir)/setup.py --quiet install \
+		$(if $(SETUP_PREFIX),--prefix=$(SETUP_PREFIX))
+
+maybe_install_pylibfdt:
+	if [ -e $(PYMODULE) ]; then \
+		if [ -z "$(NO_PYTHON)" ]; then \
+			$(MAKE) install_pylibfdt; \
+		fi; \
+	fi
+
 PYLIBFDT_cleanfiles = libfdt_wrap.c libfdt.py libfdt.pyc _libfdt.so
-- 
2.12.2.564.g063fe858b8-goog

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

* [PATCH v2 3/6] pylibfdt: Use the correct libfdt version in the module
       [not found] ` <20170329181541.28856-1-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
  2017-03-29 18:15   ` [PATCH v2 1/6] pylibfdt: Allow building to be disabled Simon Glass
  2017-03-29 18:15   ` [PATCH v2 2/6] pylibfdt: Enable installation of Python module Simon Glass
@ 2017-03-29 18:15   ` Simon Glass
  2017-03-29 18:15   ` [PATCH v2 4/6] pylibfdt: Use the call function to simplify the Makefile Simon Glass
                     ` (4 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Simon Glass @ 2017-03-29 18:15 UTC (permalink / raw)
  To: Devicetree Compiler; +Cc: Mike Frysinger, David Gibson, Simon Glass

Use the same version number in the module as with the rest of libfdt. This
can be examined with:

   import pkg_resources
   print pkg_resources.require('libfdt')[0].version

Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---

Changes in v2:
- Add a comment about the VERSION environment variable

 pylibfdt/Makefile.pylibfdt | 3 ++-
 pylibfdt/setup.py          | 4 +++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/pylibfdt/Makefile.pylibfdt b/pylibfdt/Makefile.pylibfdt
index a0271da..a74cd30 100644
--- a/pylibfdt/Makefile.pylibfdt
+++ b/pylibfdt/Makefile.pylibfdt
@@ -8,6 +8,7 @@ PYMODULE = $(PYLIBFDT_objdir)/_libfdt.so
 $(PYMODULE): $(PYLIBFDT_srcs) $(WRAP)
 	@$(VECHO) PYMOD $@
 	SOURCES="$^" CPPFLAGS="$(CPPFLAGS)" OBJDIR="$(PYLIBFDT_objdir)" \
+	VERSION="$(dtc_version)" \
 	python $(PYLIBFDT_objdir)/setup.py --quiet build_ext --inplace
 
 $(WRAP): $(PYLIBFDT_srcdir)/libfdt.swig
@@ -17,7 +18,7 @@ $(WRAP): $(PYLIBFDT_srcdir)/libfdt.swig
 install_pylibfdt: $(WRAP) $(PYMODULE)
 	$(VECHO) INSTALL-PYLIB; \
 	SOURCES="$(PYLIBFDT_srcs) $(WRAP)" CPPFLAGS="$(CPPFLAGS)" \
-	OBJDIR="$(PYLIBFDT_objdir)" \
+	OBJDIR="$(PYLIBFDT_objdir)" VERSION="$(dtc_version)" \
 	python $(PYLIBFDT_objdir)/setup.py --quiet install \
 		$(if $(SETUP_PREFIX),--prefix=$(SETUP_PREFIX))
 
diff --git a/pylibfdt/setup.py b/pylibfdt/setup.py
index ef6e2c0..9f87fe9 100644
--- a/pylibfdt/setup.py
+++ b/pylibfdt/setup.py
@@ -6,6 +6,7 @@ setup.py file for SWIG libfdt
 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
 """
 
 from distutils.core import setup, Extension
@@ -16,6 +17,7 @@ progname = sys.argv[0]
 files = os.environ['SOURCES'].split()
 cflags = os.environ['CPPFLAGS'].split()
 objdir = os.environ['OBJDIR']
+version = os.environ['VERSION']
 
 libfdt_module = Extension(
     '_libfdt',
@@ -24,7 +26,7 @@ libfdt_module = Extension(
 )
 
 setup (name = 'libfdt',
-       version = '0.1',
+       version = version,
        author      = "Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>",
        description = """Python binding for libfdt""",
        ext_modules = [libfdt_module],
-- 
2.12.2.564.g063fe858b8-goog

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

* [PATCH v2 4/6] pylibfdt: Use the call function to simplify the Makefile
       [not found] ` <20170329181541.28856-1-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
                     ` (2 preceding siblings ...)
  2017-03-29 18:15   ` [PATCH v2 3/6] pylibfdt: Use the correct libfdt version in the module Simon Glass
@ 2017-03-29 18:15   ` Simon Glass
  2017-03-29 18:15   ` [PATCH v2 5/6] pylibfdt: Rename libfdt.swig to libfdt.i Simon Glass
                     ` (3 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Simon Glass @ 2017-03-29 18:15 UTC (permalink / raw)
  To: Devicetree Compiler; +Cc: Mike Frysinger, David Gibson, Simon Glass

This is in a separate patch since I not sure if GNU make features
are permitted in the Makefile.

Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---

Changes in v2: None

 pylibfdt/Makefile.pylibfdt | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/pylibfdt/Makefile.pylibfdt b/pylibfdt/Makefile.pylibfdt
index a74cd30..0d95c11 100644
--- a/pylibfdt/Makefile.pylibfdt
+++ b/pylibfdt/Makefile.pylibfdt
@@ -5,11 +5,13 @@ PYLIBFDT_srcs = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_SRCS))
 WRAP = $(PYLIBFDT_objdir)/libfdt_wrap.c
 PYMODULE = $(PYLIBFDT_objdir)/_libfdt.so
 
+run_setup = SOURCES="$(1)" CPPFLAGS="$(CPPFLAGS)" OBJDIR="$(PYLIBFDT_objdir)" \
+	VERSION="$(dtc_version)" \
+	python $(PYLIBFDT_objdir)/setup.py --quiet $(2)
+
 $(PYMODULE): $(PYLIBFDT_srcs) $(WRAP)
 	@$(VECHO) PYMOD $@
-	SOURCES="$^" CPPFLAGS="$(CPPFLAGS)" OBJDIR="$(PYLIBFDT_objdir)" \
-	VERSION="$(dtc_version)" \
-	python $(PYLIBFDT_objdir)/setup.py --quiet build_ext --inplace
+	$(call run_setup, $^, build_ext --inplace)
 
 $(WRAP): $(PYLIBFDT_srcdir)/libfdt.swig
 	@$(VECHO) SWIG $@
@@ -17,10 +19,8 @@ $(WRAP): $(PYLIBFDT_srcdir)/libfdt.swig
 
 install_pylibfdt: $(WRAP) $(PYMODULE)
 	$(VECHO) INSTALL-PYLIB; \
-	SOURCES="$(PYLIBFDT_srcs) $(WRAP)" CPPFLAGS="$(CPPFLAGS)" \
-	OBJDIR="$(PYLIBFDT_objdir)" VERSION="$(dtc_version)" \
-	python $(PYLIBFDT_objdir)/setup.py --quiet install \
-		$(if $(SETUP_PREFIX),--prefix=$(SETUP_PREFIX))
+	$(call run_setup, $(PYLIBFDT_srcs) $(WRAP), \
+		install $(if $(SETUP_PREFIX),--prefix=$(SETUP_PREFIX)))
 
 maybe_install_pylibfdt:
 	if [ -e $(PYMODULE) ]; then \
-- 
2.12.2.564.g063fe858b8-goog

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

* [PATCH v2 5/6] pylibfdt: Rename libfdt.swig to libfdt.i
       [not found] ` <20170329181541.28856-1-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
                     ` (3 preceding siblings ...)
  2017-03-29 18:15   ` [PATCH v2 4/6] pylibfdt: Use the call function to simplify the Makefile Simon Glass
@ 2017-03-29 18:15   ` Simon Glass
       [not found]     ` <20170329181541.28856-6-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
  2017-03-29 18:15   ` [PATCH v2 6/6] pylibfdt: Allow setup.py to operation stand-alone Simon Glass
                     ` (2 subsequent siblings)
  7 siblings, 1 reply; 12+ messages in thread
From: Simon Glass @ 2017-03-29 18:15 UTC (permalink / raw)
  To: Devicetree Compiler; +Cc: Mike Frysinger, David Gibson, Simon Glass

The .i extension allows Python distutils to automatically handle the swig
file. Rename it.

Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---

Changes in v2:
- Add new patch to rename libfdt.swig to libfdt.i

 pylibfdt/Makefile.pylibfdt         | 2 +-
 pylibfdt/{libfdt.swig => libfdt.i} | 0
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename pylibfdt/{libfdt.swig => libfdt.i} (100%)

diff --git a/pylibfdt/Makefile.pylibfdt b/pylibfdt/Makefile.pylibfdt
index 0d95c11..06f9296 100644
--- a/pylibfdt/Makefile.pylibfdt
+++ b/pylibfdt/Makefile.pylibfdt
@@ -13,7 +13,7 @@ $(PYMODULE): $(PYLIBFDT_srcs) $(WRAP)
 	@$(VECHO) PYMOD $@
 	$(call run_setup, $^, build_ext --inplace)
 
-$(WRAP): $(PYLIBFDT_srcdir)/libfdt.swig
+$(WRAP): $(PYLIBFDT_srcdir)/libfdt.i
 	@$(VECHO) SWIG $@
 	$(SWIG) -python -o $@ $<
 
diff --git a/pylibfdt/libfdt.swig b/pylibfdt/libfdt.i
similarity index 100%
rename from pylibfdt/libfdt.swig
rename to pylibfdt/libfdt.i
-- 
2.12.2.564.g063fe858b8-goog

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

* [PATCH v2 6/6] pylibfdt: Allow setup.py to operation stand-alone
       [not found] ` <20170329181541.28856-1-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
                     ` (4 preceding siblings ...)
  2017-03-29 18:15   ` [PATCH v2 5/6] pylibfdt: Rename libfdt.swig to libfdt.i Simon Glass
@ 2017-03-29 18:15   ` Simon Glass
  2017-03-29 18:16   ` [PATCH v2 0/6] pylibfdt: Add installation support Simon Glass
  2017-04-03  4:37   ` David Gibson
  7 siblings, 0 replies; 12+ messages in thread
From: Simon Glass @ 2017-03-29 18:15 UTC (permalink / raw)
  To: Devicetree Compiler; +Cc: Mike Frysinger, David Gibson, Simon Glass

At present we require that setup.py is executed from the Makefile, which
sets up various important things like the list of files to build and the
version number.

However many installation systems expect to be able to change to the
directory containing setup.py and run it. This allows them to support (for
example) building/installing for multiple Python versions, varying
installation paths, particular C flags, etc.

The problem in implementing this is that we don't want to duplicate the
information in the Makefile. A common solution (so I am told) is to parse
the Makefile to obtain the required information.

Update the setup.py script to read a few Makefiles when it does not see
the required information in its environment. This allows installation
using:

   cd pylibfdt
   python setup.py install

Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---

Changes in v2:
- Add new patch to allow setup.py to operation stand-alone
- Rebase to master

 README            | 10 +++++-
 pylibfdt/setup.py | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 99 insertions(+), 6 deletions(-)

diff --git a/README b/README
index 5add557..561a364 100644
--- a/README
+++ b/README
@@ -55,7 +55,15 @@ To install the library use:
     make install_pylibfdt SETUP_PREFIX=/path/to/install_dir
 
 If SETUP_PREFIX is not provided, the default prefix is used, typically '/usr'
-or '/usr/local'. See Python's distutils documentation for details.
+or '/usr/local'. See Python's distutils documentation for details. You can
+also install using:
+
+    cd pylibfdt
+    python setup.py install
+
+To install both libfdt and pylibfdt you can use:
+
+    make install SETUP_PREFIX=/path/to/install_dir PREFIX=/path/to/install_dir
 
 To disable building the python library, even if swig and Python are available,
 use:
diff --git a/pylibfdt/setup.py b/pylibfdt/setup.py
index 9f87fe9..42c86e4 100644
--- a/pylibfdt/setup.py
+++ b/pylibfdt/setup.py
@@ -2,27 +2,112 @@
 
 """
 setup.py file for SWIG libfdt
+Copyright (C) 2017 Google, Inc.
+Written by Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
 
 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
+allows this script to be run stand-alone, e.g.:
+
+    cd pylibfdt
+    python setup.py install [--prefix=...]
 """
 
 from distutils.core import setup, Extension
 import os
+import re
 import sys
 
+# Decodes a Makefile assignment line into key and value (and plus for +=)
+RE_KEY_VALUE = re.compile('(?P<key>\w+) *(?P<plus>[+])?= *(?P<value>.*)$')
+
+
+def ParseMakefile(fname):
+    """Parse a Makefile to obtain its variables.
+
+    This collects variable assigments of the form:
+
+        VAR = value
+        VAR += more
+
+    It does not pick out := assignments, as these are not needed here. It does
+    handle line continuation.
+
+    Returns a dict:
+        key: Variable name (e.g. 'VAR')
+        value: Variable value (e.g. 'value more')
+    """
+    makevars = {}
+    with open(fname) as fd:
+        prev_text = ''  # Continuation text from previous line(s)
+        for line in fd.read().splitlines():
+          if line and line[-1] == '\\':  # Deal with line continuation
+            prev_text += line[:-1]
+            continue
+          elif prev_text:
+            line = prev_text + line
+            prev_text = ''  # Continuation is now used up
+          m = RE_KEY_VALUE.match(line)
+          if m:
+            value = m.group('value') or ''
+            key = m.group('key')
+
+            # Appending to a variable inserts a space beforehand
+            if 'plus' in m.groupdict() and key in makevars:
+              makevars[key] += ' ' + value
+            else:
+              makevars[key] = value
+    return makevars
+
+def GetEnvFromMakefiles():
+    """Scan the Makefiles to obtain the settings we need.
+
+    This assumes that this script is being run from the pylibfdt directory.
+
+    Returns:
+        Tuple with:
+            List of swig options
+            Version string
+            List of files to build
+            List of extra C preprocessor flags needed
+            Object directory to use (always '')
+    """
+    basedir = os.path.dirname(os.getcwd())
+    swig_opts = ['-I%s' % basedir]
+    makevars = ParseMakefile(os.path.join(basedir, 'Makefile'))
+    version = '%s.%s.%s' % (makevars['VERSION'], makevars['PATCHLEVEL'],
+                            makevars['SUBLEVEL'])
+    makevars = ParseMakefile(os.path.join(basedir, 'libfdt', 'Makefile.libfdt'))
+    files = makevars['LIBFDT_SRCS'].split()
+    files = [os.path.join(basedir, 'libfdt', fname) for fname in files]
+    files.append('libfdt.i')
+    cflags = ['-I%s' % basedir, '-I%s/libfdt' % basedir]
+    objdir = ''
+    return swig_opts, version, files, cflags, objdir
+
+
 progname = sys.argv[0]
-files = os.environ['SOURCES'].split()
-cflags = os.environ['CPPFLAGS'].split()
-objdir = os.environ['OBJDIR']
-version = os.environ['VERSION']
+files = os.environ.get('SOURCES', '').split()
+cflags = os.environ.get('CPPFLAGS', '').split()
+objdir = os.environ.get('OBJDIR')
+version = os.environ.get('VERSION')
+swig_opts = []
+
+# 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)):
+    swig_opts, version, files, cflags, objdir = GetEnvFromMakefiles()
 
 libfdt_module = Extension(
     '_libfdt',
     sources = files,
-    extra_compile_args = cflags
+    extra_compile_args = cflags,
+    swig_opts = swig_opts,
 )
 
 setup (name = 'libfdt',
-- 
2.12.2.564.g063fe858b8-goog

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

* Re: [PATCH v2 0/6] pylibfdt: Add installation support
       [not found] ` <20170329181541.28856-1-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
                     ` (5 preceding siblings ...)
  2017-03-29 18:15   ` [PATCH v2 6/6] pylibfdt: Allow setup.py to operation stand-alone Simon Glass
@ 2017-03-29 18:16   ` Simon Glass
  2017-04-03  4:37   ` David Gibson
  7 siblings, 0 replies; 12+ messages in thread
From: Simon Glass @ 2017-03-29 18:16 UTC (permalink / raw)
  To: Devicetree Compiler; +Cc: Mike Frysinger, David Gibson, Simon Glass

Hi David,

On 29 March 2017 at 12:15, Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> wrote:
>
> This series adds support for installation of the Pylib module. It adjusts
> the setup.py file to provide this functionality and the Makefile rules
> to call it correctly.
>
> It also adds a way to disable building the Python module. This is useful
> since some build systems want to use setup.py to do both the build and
> the install step. In this case the correct build commands would be:
>
>    make NO_PYTHON=1
>    make install_pylibfdt SETUP_PREFIX=/path/to/install_prefix
>
> Version 2 adds support for running setup.py stand-alone.
>
> Changes in v2:
> - Add a comment about the VERSION environment variable
> - Add new patch to rename libfdt.swig to libfdt.i
> - Add new patch to allow setup.py to operation stand-alone
> - Rebase to master
>
> Simon Glass (6):
>   pylibfdt: Allow building to be disabled
>   pylibfdt: Enable installation of Python module
>   pylibfdt: Use the correct libfdt version in the module
>   pylibfdt: Use the call function to simplify the Makefile
>   pylibfdt: Rename libfdt.swig to libfdt.i
>   pylibfdt: Allow setup.py to operation stand-alone
>
>  Makefile                           |  3 +-
>  README                             | 21 +++++++++
>  pylibfdt/Makefile.pylibfdt         | 21 +++++++--
>  pylibfdt/{libfdt.swig => libfdt.i} |  0
>  pylibfdt/setup.py                  | 97 ++++++++++++++++++++++++++++++++++++--
>  5 files changed, 133 insertions(+), 9 deletions(-)
>  rename pylibfdt/{libfdt.swig => libfdt.i} (100%)

Here's a newer version with an additional patch to support
installation bypassing the Makefile. I'll follow up if I have any
other ideas.

Regards,
Simon

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

* Re: [PATCH v2 5/6] pylibfdt: Rename libfdt.swig to libfdt.i
       [not found]     ` <20170329181541.28856-6-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
@ 2017-04-03  4:37       ` David Gibson
       [not found]         ` <20170403043721.GD10997-K0bRW+63XPQe6aEkudXLsA@public.gmane.org>
  0 siblings, 1 reply; 12+ messages in thread
From: David Gibson @ 2017-04-03  4:37 UTC (permalink / raw)
  To: Simon Glass; +Cc: Devicetree Compiler, Mike Frysinger

[-- Attachment #1: Type: text/plain, Size: 1472 bytes --]

On Wed, Mar 29, 2017 at 12:15:40PM -0600, Simon Glass wrote:
> The .i extension allows Python distutils to automatically handle the swig
> file. Rename it.
> 
> Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>

Uh.. please don't.  The existing Makefiles use %.i as a target for
preprocessed-but-not-compiled sources (occasionally useful for
debugging).

> ---
> 
> Changes in v2:
> - Add new patch to rename libfdt.swig to libfdt.i
> 
>  pylibfdt/Makefile.pylibfdt         | 2 +-
>  pylibfdt/{libfdt.swig => libfdt.i} | 0
>  2 files changed, 1 insertion(+), 1 deletion(-)
>  rename pylibfdt/{libfdt.swig => libfdt.i} (100%)
> 
> diff --git a/pylibfdt/Makefile.pylibfdt b/pylibfdt/Makefile.pylibfdt
> index 0d95c11..06f9296 100644
> --- a/pylibfdt/Makefile.pylibfdt
> +++ b/pylibfdt/Makefile.pylibfdt
> @@ -13,7 +13,7 @@ $(PYMODULE): $(PYLIBFDT_srcs) $(WRAP)
>  	@$(VECHO) PYMOD $@
>  	$(call run_setup, $^, build_ext --inplace)
>  
> -$(WRAP): $(PYLIBFDT_srcdir)/libfdt.swig
> +$(WRAP): $(PYLIBFDT_srcdir)/libfdt.i
>  	@$(VECHO) SWIG $@
>  	$(SWIG) -python -o $@ $<
>  
> diff --git a/pylibfdt/libfdt.swig b/pylibfdt/libfdt.i
> similarity index 100%
> rename from pylibfdt/libfdt.swig
> rename to pylibfdt/libfdt.i

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH v2 0/6] pylibfdt: Add installation support
       [not found] ` <20170329181541.28856-1-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
                     ` (6 preceding siblings ...)
  2017-03-29 18:16   ` [PATCH v2 0/6] pylibfdt: Add installation support Simon Glass
@ 2017-04-03  4:37   ` David Gibson
  7 siblings, 0 replies; 12+ messages in thread
From: David Gibson @ 2017-04-03  4:37 UTC (permalink / raw)
  To: Simon Glass; +Cc: Devicetree Compiler, Mike Frysinger

[-- Attachment #1: Type: text/plain, Size: 950 bytes --]

On Wed, Mar 29, 2017 at 12:15:35PM -0600, Simon Glass wrote:
> This series adds support for installation of the Pylib module. It adjusts
> the setup.py file to provide this functionality and the Makefile rules
> to call it correctly.
> 
> It also adds a way to disable building the Python module. This is useful
> since some build systems want to use setup.py to do both the build and
> the install step. In this case the correct build commands would be:
> 
>    make NO_PYTHON=1
>    make install_pylibfdt SETUP_PREFIX=/path/to/install_prefix
> 
> Version 2 adds support for running setup.py stand-alone.

Sorry, I already applied several of your patches from the last round,
but forgot to push out the tree.  Can you rebase the series.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH v2 5/6] pylibfdt: Rename libfdt.swig to libfdt.i
       [not found]         ` <20170403043721.GD10997-K0bRW+63XPQe6aEkudXLsA@public.gmane.org>
@ 2017-04-05  3:18           ` Simon Glass
       [not found]             ` <CAPnjgZ3Bj5AY2nburGFmxScH7-Ws4R6sxWZQkqNW3NxNt5-5aQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 12+ messages in thread
From: Simon Glass @ 2017-04-05  3:18 UTC (permalink / raw)
  To: David Gibson; +Cc: Devicetree Compiler, Mike Frysinger

Hi David,

On 2 April 2017 at 22:37, David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org> wrote:
> On Wed, Mar 29, 2017 at 12:15:40PM -0600, Simon Glass wrote:
>> The .i extension allows Python distutils to automatically handle the swig
>> file. Rename it.
>>
>> Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
>
> Uh.. please don't.  The existing Makefiles use %.i as a target for
> preprocessed-but-not-compiled sources (occasionally useful for
> debugging).

If I don't do this I can't make the setup.py thing work. There might
be a workaround but I don't know of it.

Since it is in a separate directory, do you think we could live with this?

Regards,
Simon

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

* Re: [PATCH v2 5/6] pylibfdt: Rename libfdt.swig to libfdt.i
       [not found]             ` <CAPnjgZ3Bj5AY2nburGFmxScH7-Ws4R6sxWZQkqNW3NxNt5-5aQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2017-04-05  5:10               ` David Gibson
  0 siblings, 0 replies; 12+ messages in thread
From: David Gibson @ 2017-04-05  5:10 UTC (permalink / raw)
  To: Simon Glass; +Cc: Devicetree Compiler, Mike Frysinger

[-- Attachment #1: Type: text/plain, Size: 1177 bytes --]

On Tue, Apr 04, 2017 at 09:18:18PM -0600, Simon Glass wrote:
> Hi David,
> 
> On 2 April 2017 at 22:37, David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org> wrote:
> > On Wed, Mar 29, 2017 at 12:15:40PM -0600, Simon Glass wrote:
> >> The .i extension allows Python distutils to automatically handle the swig
> >> file. Rename it.
> >>
> >> Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
> >
> > Uh.. please don't.  The existing Makefiles use %.i as a target for
> > preprocessed-but-not-compiled sources (occasionally useful for
> > debugging).
> 
> If I don't do this I can't make the setup.py thing work. There might
> be a workaround but I don't know of it.
> 
> Since it is in a separate directory, do you think we could live with
> this?

Ah, I misread your description as implying the default could be
overridden.

Ok, I guess we can live with it, if the setuptools stuff really
doesn't like it otherwise.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

end of thread, other threads:[~2017-04-05  5:10 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-29 18:15 [PATCH v2 0/6] pylibfdt: Add installation support Simon Glass
     [not found] ` <20170329181541.28856-1-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2017-03-29 18:15   ` [PATCH v2 1/6] pylibfdt: Allow building to be disabled Simon Glass
2017-03-29 18:15   ` [PATCH v2 2/6] pylibfdt: Enable installation of Python module Simon Glass
2017-03-29 18:15   ` [PATCH v2 3/6] pylibfdt: Use the correct libfdt version in the module Simon Glass
2017-03-29 18:15   ` [PATCH v2 4/6] pylibfdt: Use the call function to simplify the Makefile Simon Glass
2017-03-29 18:15   ` [PATCH v2 5/6] pylibfdt: Rename libfdt.swig to libfdt.i Simon Glass
     [not found]     ` <20170329181541.28856-6-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2017-04-03  4:37       ` David Gibson
     [not found]         ` <20170403043721.GD10997-K0bRW+63XPQe6aEkudXLsA@public.gmane.org>
2017-04-05  3:18           ` Simon Glass
     [not found]             ` <CAPnjgZ3Bj5AY2nburGFmxScH7-Ws4R6sxWZQkqNW3NxNt5-5aQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-04-05  5:10               ` David Gibson
2017-03-29 18:15   ` [PATCH v2 6/6] pylibfdt: Allow setup.py to operation stand-alone Simon Glass
2017-03-29 18:16   ` [PATCH v2 0/6] pylibfdt: Add installation support Simon Glass
2017-04-03  4:37   ` David Gibson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.