python: simplify build, some fixups

* lang/python/gpg/version.py.in: Rename to lang/python/version.py.in.
configure.ac: Generate version.py.in in lang/python.
* lang/python/MANIFEST.in: Include version.py explicitly.
* lang/python/gpg: Rename to 'src'.
* lang/python/Makefile.am: Do not copy source files, do not use absolute
directories, support lib64 in uninstall, clean also dist directory, use
symlink for gpg src.
* lang/python/setup.py.in: Use builddir, copy sources into builddir,
copy version.py into module.
--

Simplify build to symlink the gpg sources into builddir instead of
copying. This requires handling of version.py as generated file.

In addition apply some cleanups: Drop the absolution pathes, clean the
dist directory as well, support lib64 for sitelib at uninstall.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
This commit is contained in:
Alon Bar-Lev 2017-04-05 19:47:08 +03:00 committed by Justus Winter
parent e7d9c0c3d7
commit 49195c487e
No known key found for this signature in database
GPG Key ID: DD1A52F9DA8C9020
31 changed files with 24 additions and 40 deletions

View File

@ -881,7 +881,7 @@ AC_CONFIG_FILES([lang/Makefile lang/cl/Makefile lang/cl/gpgme.asd])
AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([lang/qt/doc/Doxyfile])]) AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([lang/qt/doc/Doxyfile])])
AC_CONFIG_FILES(lang/qt/doc/Makefile) AC_CONFIG_FILES(lang/qt/doc/Makefile)
AC_CONFIG_FILES([lang/python/Makefile AC_CONFIG_FILES([lang/python/Makefile
lang/python/gpg/version.py lang/python/version.py
lang/python/tests/Makefile]) lang/python/tests/Makefile])
AC_CONFIG_FILES([lang/python/setup.py], [chmod a+x lang/python/setup.py]) AC_CONFIG_FILES([lang/python/setup.py], [chmod a+x lang/python/setup.py])
AC_OUTPUT AC_OUTPUT

View File

@ -1,4 +1,5 @@
recursive-include examples *.py recursive-include examples *.py
include gpgme.i include gpgme.i
include helpers.c helpers.h private.h include helpers.c helpers.h private.h
include version.py
recursive-include gpg *.py recursive-include gpg *.py

View File

@ -22,28 +22,19 @@ EXTRA_DIST = \
gpgme.i \ gpgme.i \
helpers.c helpers.h private.h \ helpers.c helpers.h private.h \
examples \ examples \
gpg src
SUBDIRS = . tests SUBDIRS = . tests
COPY_FILES_GPG = \
$(srcdir)/gpg/callbacks.py \
$(srcdir)/gpg/constants \
$(srcdir)/gpg/core.py \
$(srcdir)/gpg/errors.py \
$(srcdir)/gpg/__init__.py \
$(srcdir)/gpg/results.py \
$(srcdir)/gpg/util.py
.PHONY: prepare .PHONY: prepare
prepare: copystamp prepare: copystamp
# For VPATH builds we need to copy some files because Python's # For VPATH builds we need to copy some files because Python's
# distutils are not VPATH-aware. # distutils are not VPATH-aware.
copystamp: copystamp:
ln -sf "$(abs_top_srcdir)/src/data.h" . ln -sf "$(top_srcdir)/src/data.h" .
ln -sf "$(abs_top_builddir)/config.h" . ln -sf "$(top_builddir)/config.h" .
if test $(srcdir) != . ; then cp -R $(COPY_FILES_GPG) gpg ; fi ln -sf "$(srcdir)/src" gpg
touch $@ touch $@
all-local: copystamp all-local: copystamp
@ -51,7 +42,7 @@ all-local: copystamp
PYTHON="$$1" ; shift ; \ PYTHON="$$1" ; shift ; \
CFLAGS="$(CFLAGS)" \ CFLAGS="$(CFLAGS)" \
srcdir="$(srcdir)" \ srcdir="$(srcdir)" \
abs_top_builddir="$(abs_top_builddir)" \ top_builddir="$(top_builddir)" \
$$PYTHON setup.py build --verbose --build-base=python$${VERSION}-gpg ; \ $$PYTHON setup.py build --verbose --build-base=python$${VERSION}-gpg ; \
done done
@ -59,7 +50,7 @@ python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz.asc: copystamp
$(MKDIR_P) python$(PYTHON_VERSION)-gpg-dist $(MKDIR_P) python$(PYTHON_VERSION)-gpg-dist
CFLAGS="$(CFLAGS)" \ CFLAGS="$(CFLAGS)" \
srcdir="$(srcdir)" \ srcdir="$(srcdir)" \
abs_top_builddir="$(abs_top_builddir)" \ top_builddir="$(top_builddir)" \
$(PYTHON) setup.py sdist --verbose --dist-dir=python$(PYTHON_VERSION)-gpg-dist \ $(PYTHON) setup.py sdist --verbose --dist-dir=python$(PYTHON_VERSION)-gpg-dist \
--manifest=python$(PYTHON_VERSION)-gpg-dist/MANIFEST --manifest=python$(PYTHON_VERSION)-gpg-dist/MANIFEST
gpg2 --detach-sign --armor python$(PYTHON_VERSION)-gpg-dist/gpg-$(VERSION).tar.gz gpg2 --detach-sign --armor python$(PYTHON_VERSION)-gpg-dist/gpg-$(VERSION).tar.gz
@ -75,6 +66,7 @@ upload: python$(PYTHON_VERSION)-gpg-dist/gpg-$(VERSION).tar.gz \
CLEANFILES = copystamp \ CLEANFILES = copystamp \
config.h \ config.h \
data.h \ data.h \
gpg \
files.txt \ files.txt \
install_files.txt install_files.txt
@ -84,22 +76,16 @@ CLEANFILES = copystamp \
# permissions. # permissions.
clean-local: clean-local:
rm -rf -- build rm -rf -- build
if test $(srcdir) != . ; then \
find gpg -type d ! -perm -200 -exec chmod u+w {} ';' ; \
for FILE in $(COPY_FILES_GPG); do \
rm -rf -- gpg/$$(basename $$FILE) ; \
done \
fi
for VERSION in $(PYTHON_VERSIONS); do \ for VERSION in $(PYTHON_VERSIONS); do \
find python$${VERSION}-gpg -type d ! -perm -200 -exec chmod u+w {} ';' ; \ find python$${VERSION}-gpg* -type d ! -perm -200 -exec chmod u+w {} ';' ; \
rm -rf -- python$${VERSION}-gpg ; \ rm -rf -- python$${VERSION}-gpg* ; \
done done
install-exec-local: install-exec-local:
set -e ; set $(PYTHONS); for VERSION in $(PYTHON_VERSIONS); do \ set -e ; set $(PYTHONS); for VERSION in $(PYTHON_VERSIONS); do \
PYTHON="$$1" ; shift ; \ PYTHON="$$1" ; shift ; \
srcdir="$(srcdir)" \ srcdir="$(srcdir)" \
abs_top_builddir="$(abs_top_builddir)" \ top_builddir="$(top_builddir)" \
$$PYTHON setup.py \ $$PYTHON setup.py \
build \ build \
--build-base=python$${VERSION}-gpg \ --build-base=python$${VERSION}-gpg \
@ -110,6 +96,6 @@ install-exec-local:
uninstall-local: uninstall-local:
GV=$$(echo $(VERSION) | tr - _); for PV in $(PYTHON_VERSIONS); do \ GV=$$(echo $(VERSION) | tr - _); for PV in $(PYTHON_VERSIONS); do \
rm -rf -- "$(DESTDIR)$(prefix)/lib/python$$PV/site-packages/gpg" \ rm -rf -- "$(DESTDIR)$(prefix)"/lib*/python$$PV/site-packages/gpg \
"$(DESTDIR)$(prefix)/lib/python$$PV/site-packages/gpg-$$GV-py$$PV.egg-info" ; \ "$(DESTDIR)$(prefix)"/lib*/python$$PV/site-packages/gpg-$$GV-py$$PV.egg-info ; \
done done

View File

@ -38,18 +38,17 @@ gpgme_config = ["gpgme-config"] + gpgme_config_flags
gpgme_h = "" gpgme_h = ""
include_dirs = [os.getcwd()] include_dirs = [os.getcwd()]
library_dirs = [] library_dirs = []
vpath_build = os.environ.get('srcdir', '.') != '.'
in_tree = False in_tree = False
extra_swig_opts = [] extra_swig_opts = []
extra_macros = dict() extra_macros = dict()
abs_top_builddir = os.environ.get("abs_top_builddir") top_builddir = os.environ.get("top_builddir")
if abs_top_builddir: if top_builddir:
# In-tree build. # In-tree build.
in_tree = True in_tree = True
gpgme_config = [os.path.join(abs_top_builddir, "src/gpgme-config")] + gpgme_config_flags gpgme_config = [os.path.join(top_builddir, "src/gpgme-config")] + gpgme_config_flags
gpgme_h = os.path.join(abs_top_builddir, "src/gpgme.h") gpgme_h = os.path.join(top_builddir, "src/gpgme.h")
library_dirs = [os.path.join(abs_top_builddir, "src/.libs")] # XXX uses libtool internals library_dirs = [os.path.join(top_builddir, "src/.libs")] # XXX uses libtool internals
extra_macros.update( extra_macros.update(
HAVE_CONFIG_H=1, HAVE_CONFIG_H=1,
HAVE_DATA_H=1, HAVE_DATA_H=1,
@ -210,23 +209,21 @@ class BuildExtFirstHack(build):
# Copy due to http://bugs.python.org/issue2624 # Copy due to http://bugs.python.org/issue2624
# Avoid creating in srcdir # Avoid creating in srcdir
for source, target in ((in_srcdir(n), in_build_base(n)) for source, target in ((in_srcdir(n), in_build_base(n))
for n in ('gpgme.i', 'helpers.c')): for n in ('gpgme.i', 'helpers.c', 'private.h', 'helpers.h')):
if not up_to_date(source, target): if not up_to_date(source, target):
shutil.copy2(source, target) shutil.copy2(source, target)
def run(self):
self._generate()
# Append generated files via build_base # Append generated files via build_base
if not os.path.exists(os.path.join(self.build_lib, "gpg")): if not os.path.exists(os.path.join(self.build_lib, "gpg")):
os.makedirs(os.path.join(self.build_lib, "gpg")) os.makedirs(os.path.join(self.build_lib, "gpg"))
shutil.copy2("version.py", os.path.join(self.build_lib, "gpg"))
def run(self):
self._generate()
swig_sources.append(os.path.join(self.build_base, 'gpgme.i')) swig_sources.append(os.path.join(self.build_base, 'gpgme.i'))
swig_opts.extend(['-I' + self.build_base, swig_opts.extend(['-I' + self.build_base,
'-I' + in_srcdir('.'),
'-outdir', os.path.join(self.build_lib, 'gpg')]) '-outdir', os.path.join(self.build_lib, 'gpg')])
if vpath_build:
include_dirs.append(in_srcdir('.'))
include_dirs.append(self.build_base) include_dirs.append(self.build_base)
self.run_command('build_ext') self.run_command('build_ext')