pylibfdt: Add installation support
v2 cover pylibfdt: Add installation support
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%)Signature · 1 line
2.12.2.564.g063fe858b8-goog
A message that is not in the archive (sent off-list or not yet received): 20170329181541.28856-1-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org
PATCH v2 1/6 pylibfdt: Allow building to be disabled
Some build systems want to build python libraries separately from the rest of the build.
Add a NO_PYTHON option to enable this.
---
Changes in v2: None
Makefile | 1 + README | 6 ++++++ 2 files changed, 7 insertions(+)
Makefile +1 -0
@@ -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; \
README +6 -0
@@ -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.
Signature · 1 line
2.12.2.564.g063fe858b8-goog
PATCH v2 2/6 pylibfdt: Enable installation of Python module
In reply to a message not in the archiveAdjust 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.
---
Changes in v2: None
Makefile | 2 +- README | 7 +++++++ pylibfdt/Makefile.pylibfdt | 14 ++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-)
Makefile +1 -1
@@ -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)
README +7 -0
@@ -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:
pylibfdt/Makefile.pylibfdt +14 -0
@@ -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
Signature · 1 line
2.12.2.564.g063fe858b8-goog
PATCH v2 3/6 pylibfdt: Use the correct libfdt version in the module
In reply to a message not in the archiveUse 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
---
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(-)
pylibfdt/Makefile.pylibfdt +2 -1
@@ -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))
pylibfdt/setup.py +3 -1
@@ -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 <[email protected]>", description = """Python binding for libfdt""", ext_modules = [libfdt_module],
Signature · 1 line
2.12.2.564.g063fe858b8-goog
PATCH v2 4/6 pylibfdt: Use the call function to simplify the Makefile
In reply to a message not in the archiveThis is in a separate patch since I not sure if GNU make features are permitted in the Makefile.
---
Changes in v2: None
pylibfdt/Makefile.pylibfdt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
pylibfdt/Makefile.pylibfdt +7 -7
@@ -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 \
Signature · 1 line
2.12.2.564.g063fe858b8-goog
PATCH v2 5/6 pylibfdt: Rename libfdt.swig to libfdt.i
In reply to a message not in the archiveThe .i extension allows Python distutils to automatically handle the swig file. Rename it.
---
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%)pylibfdt/Makefile.pylibfdt +1 -1
@@ -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 $@ $<
pylibfdt/libfdt.i renamed from pylibfdt/libfdt.swig +0 -0
Signature · 1 line
2.12.2.564.g063fe858b8-goog
A message that is not in the archive (sent off-list or not yet received): 20170329181541.28856-6-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org
Re: [PATCH v2 5/6] pylibfdt: Rename libfdt.swig to libfdt.i
Quoted 4 lines · Simon Glass
The .i extension allows Python distutils to automatically handle the swig file. Rename it.
Signed-off-by Simon Glass <[email protected]>
Uh.. please don't. The existing Makefiles use %.i as a target for preprocessed-but-not-compiled sources (occasionally useful for debugging).
Quoted 27 lines
---
Changes in v2:
- Add new patch to rename libfdt.swig to libfdt.ipylibfdt/Makefile.pylibfdt | 2 +- pylibfdt/{libfdt.swig => libfdt.i} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename pylibfdt/{libfdt.swig => libfdt.i} (100%)pylibfdt/Makefile.pylibfdt +1
-1@@ -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 $@ $<pylibfdt/libfdt.i renamed from pylibfdt/libfdt.swig +0
-0
Signature · 4 lines
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
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v2 5/6] pylibfdt: Rename libfdt.swig to libfdt.i
Hi David,
Quoted 9 lines · David Gibson
Quoted 4 lines · Simon Glass
The .i extension allows Python distutils to automatically handle the swig file. Rename it.
Signed-off-by Simon Glass <[email protected]>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
A message that is not in the archive (sent off-list or not yet received): CAPnjgZ3Bj5AY2nburGFmxScH7-Ws4R6sxWZQkqNW3NxNt5-5aQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH v2 5/6] pylibfdt: Rename libfdt.swig to libfdt.i
Quoted 13 lines · Simon Glass
Hi David,
Quoted 9 lines · David Gibson
Quoted 4 lines · Simon Glass
The .i extension allows Python distutils to automatically handle the swig file. Rename it.
Signed-off-by Simon Glass <[email protected]>Uh.. please don't. The existing Makefiles use %.i as a target for preprocessed-but-not-compiled sources (occasionally useful for debugging).
Quoted 5 lines
If I don't do this I can't make the
setup.pything 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.
Signature · 4 lines
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
PATCH v2 6/6 pylibfdt: Allow setup.py to operation stand-alone
In reply to a message not in the archiveAt 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
---
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(-)
README +9 -1
@@ -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:
pylibfdt/setup.py +90 -5
117 lines not on this page · raw message
Signature · 1 line
2.12.2.564.g063fe858b8-goog
Hi David,
Quoted 28 lines · Simon Glass
This series adds support for installation of the Pylib module. It adjusts the
setup.pyfile to provide this functionality and theMakefilerules 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.pyto do both the build and the install step. In this case the correct build commands would be:make NO_PYTHON=1
makeinstall_pylibfdtSETUP_PREFIX=/path/to/install_prefixVersion 2 adds support for running
setup.pystand-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 allowsetup.pyto operation stand-alone
- Rebase to masterSimon 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 theMakefile
pylibfdt: Rename libfdt.swig to libfdt.i
pylibfdt: Allowsetup.pyto operation stand-alone
Quoted 7 lines
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
Quoted 4 lines · Simon Glass
This series adds support for installation of the Pylib module. It adjusts the
setup.pyfile to provide this functionality and theMakefilerules to call it correctly.
Quoted 8 lines
It also adds a way to disable building the Python module. This is useful since some build systems want to use
setup.pyto do both the build and the install step. In this case the correct build commands would be:make NO_PYTHON=1
makeinstall_pylibfdtSETUP_PREFIX=/path/to/install_prefixVersion 2 adds support for running
setup.pystand-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.
Signature · 4 lines
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