Skip to contentSkip to conversation

pylibfdt: Fix install location of libfdt.py

PATCH In review Tuomas Tynkkynen 2 participants 3 messages Nov 7, 2017 – Nov 8, 2017 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pylibfdt: Fix install location of libfdt.py

Currently 'make install' produces a directory tree like this for the Python module:

$PREFIX
`-- lib

    `-- python2.7
        `-- site-packages
            |-- _libfdt.so
            |-- libfdt-1.4.5-py2.7.egg-info
            `-- pylibfdt
                |-- libfdt.py
                `-- libfdt.pyc

That is, libfdt.py is installed in an unexpected subdirectory pylibfdt so 'import libfdt' fails. Fix this by properly pointing package_dir to the root of the Python sources, producing the correct directory tree:

$PREFIX
`-- lib

    `-- python2.7
        `-- site-packages
            |-- _libfdt.so
            |-- libfdt-1.4.5-py2.7.egg-info
            |-- libfdt.py
            `-- libfdt.pyc
---
 pylibfdt/Makefile.pylibfdt | 1 -
 pylibfdt/setup.py          | 4 ++--
 2 files changed, 2 insertions(+), 3 deletions(-)
pylibfdt/Makefile.pylibfdt +0 -1
index 9507d3d..2843ef5 100644
@@ -14,7 +14,6 @@ endef
 $(PYMODULE): $(PYLIBFDT_srcs)
 	@$(VECHO) PYMOD $@
 	$(call run_setup, $^, build_ext --inplace)
-	mv _libfdt.so $@
 
 install_pylibfdt: $(PYMODULE)
 	$(VECHO) INSTALL-PYLIB; \
pylibfdt/setup.py +2 -2
index 1a1e832..49ab3cc 100755
@@ -116,6 +116,6 @@ setup(
     author='Simon Glass <[email protected]>',
     description='Python binding for libfdt',
     ext_modules=[libfdt_module],
-    package_dir={'': objdir},
-    py_modules=['pylibfdt/libfdt'],
+    package_dir={'': 'pylibfdt'},
+    py_modules=['libfdt'],
 )
Signature · 1 line
2.15.0

A message that is not in the archive (sent off-list or not yet received): 20171107141741.1733-1-tuomas-yrGDUoBaLx3QT0dZR+AlfA@public.gmane.org

#2 lore raw
Quoted 17 lines · Tuomas Tynkkynen

Currently 'make install' produces a directory tree like this for the Python module:

$PREFIX
`-- lib

    `-- python2.7
        `-- site-packages
            |-- _libfdt.so
            |-- libfdt-1.4.5-py2.7.egg-info
            `-- pylibfdt
                |-- libfdt.py
                `-- libfdt.pyc

That is, libfdt.py is installed in an unexpected subdirectory pylibfdt so 'import libfdt' fails. Fix this by properly pointing package_dir to the root of the Python sources, producing the correct directory tree:

Quoted 8 lines

$PREFIX
`-- lib

    `-- python2.7
        `-- site-packages
            |-- _libfdt.so
            |-- libfdt-1.4.5-py2.7.egg-info
            |-- libfdt.py
            `-- libfdt.pyc

This doesn't seem like the right fix. Shouldn't all the files go into the pylibfdt subdirectory, rather than removing that subdirectory.

Quoted 31 lines
---
 pylibfdt/Makefile.pylibfdt | 1 -
 pylibfdt/setup.py          | 4 ++--
 2 files changed, 2 insertions(+), 3 deletions(-)
pylibfdt/Makefile.pylibfdt +0 -1
index 9507d3d..2843ef5 100644
@@ -14,7 +14,6 @@ endef
 $(PYMODULE): $(PYLIBFDT_srcs)
 	@$(VECHO) PYMOD $@
 	$(call run_setup, $^, build_ext --inplace)
-	mv _libfdt.so $@
 
 install_pylibfdt: $(PYMODULE)
 	$(VECHO) INSTALL-PYLIB; \
pylibfdt/setup.py +2 -2
index 1a1e832..49ab3cc 100755
@@ -116,6 +116,6 @@ setup(
     author='Simon Glass <[email protected]>',
     description='Python binding for libfdt',
     ext_modules=[libfdt_module],
-    package_dir={'': objdir},
-    py_modules=['pylibfdt/libfdt'],
+    package_dir={'': 'pylibfdt'},
+    py_modules=['libfdt'],
 )
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]

#4 lore raw
Quoted 30 lines · David Gibson
Quoted 20 lines · Tuomas Tynkkynen

Currently 'make install' produces a directory tree like this for the Python module:

$PREFIX
`-- lib

    `-- python2.7
        `-- site-packages
            |-- _libfdt.so
            |-- libfdt-1.4.5-py2.7.egg-info
            `-- pylibfdt
                |-- libfdt.py
                `-- libfdt.pyc

That is, libfdt.py is installed in an unexpected subdirectory pylibfdt
so 'import libfdt' fails. Fix this by properly pointing package_dir to
the root of the Python sources, producing the correct directory tree:

Quoted 8 lines

$PREFIX
`-- lib

    `-- python2.7
        `-- site-packages
            |-- _libfdt.so
            |-- libfdt-1.4.5-py2.7.egg-info
            |-- libfdt.py
            `-- libfdt.pyc
Quoted 4 lines

This doesn't seem like the right fix. Shouldn't all the files go into
the pylibfdt subdirectory, rather than removing that subdirectory.

AFAIK you can't add that subdirectory there without breaking 'import libfdt' because the directory structure must match the module structure.

I think it might be possible to achieve this though:

$PREFIX
`-- lib

    `-- python2.7
        `-- site-packages
            |-- libfdt-1.4.5-py2.7.egg-info
            `-- libfdt
                |-- _libfdt.so
                |-- __init__.py
                `-- __init__.pyc

... but I'm not sure that's idiomatic either because now the name of the native module changes from '_libfdt' to 'libfdt._libfdt'. There are already existing similar (as in one .py + one .so) packages with the same directory structure as what I'm trying to achieve:

https://packages.debian.org/sid/amd64/python-gamin/filelist