python: Remove usage of PYTHON_VERSIONS

* configure.ac: Remove PYTHON_VERSIONS subst.
* lang/python/Makefile.am: Use basename of python as builddir prefix.
* lang/python/tests/run-tests.py: Likewise.

--

Two variables needs be at sync PYTHONS and PYTHON_VERSIONS, these may go
out of sync in some cases, for example in Gentoo where default python is
3.4 we get:

PYTHON='/usr/bin/python2'
PYTHONS='/usr/bin/python /usr/bin/python2'
PYTHON_VERSIONS='2.7 3.4'

We can use the basename of the python interpreter to achieve similar
effect without having to sync indexes between these two variables.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
This commit is contained in:
Alon Bar-Lev 2017-04-08 16:34:30 +03:00 committed by Justus Winter
parent ebefc6cbf9
commit 25e6444b3f
No known key found for this signature in database
GPG Key ID: DD1A52F9DA8C9020
3 changed files with 13 additions and 15 deletions

View File

@ -474,7 +474,6 @@ if test "$found_py" = "1" -o "$found_py2" = "1" -o "$found_py3" = "1"; then
fi fi
AC_SUBST(PYTHONS, $PYTHONS) AC_SUBST(PYTHONS, $PYTHONS)
AC_SUBST(PYTHON_VERSIONS, $PYTHON_VERSIONS)
fi fi
fi fi

View File

@ -38,12 +38,11 @@ copystamp:
touch $@ touch $@
all-local: copystamp all-local: copystamp
set -e ; set $(PYTHONS); for VERSION in $(PYTHON_VERSIONS); do \ set -e ; for PYTHON in $(PYTHONS); do \
PYTHON="$$1" ; shift ; \
CFLAGS="$(CFLAGS)" \ CFLAGS="$(CFLAGS)" \
srcdir="$(srcdir)" \ srcdir="$(srcdir)" \
top_builddir="$(top_builddir)" \ top_builddir="$(top_builddir)" \
$$PYTHON setup.py build --verbose --build-base=python$${VERSION}-gpg ; \ $$PYTHON setup.py build --verbose --build-base="$$(basename "$${PYTHON}")-gpg" ; \
done done
python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz.asc: copystamp python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz.asc: copystamp
@ -76,26 +75,26 @@ CLEANFILES = copystamp \
# permissions. # permissions.
clean-local: clean-local:
rm -rf -- build rm -rf -- build
for VERSION in $(PYTHON_VERSIONS); do \ for PYTHON in $(PYTHONS); do \
find python$${VERSION}-gpg* -type d ! -perm -200 -exec chmod u+w {} ';' ; \ find "$$(basename "$${PYTHON}")-gpg" -type d ! -perm -200 -exec chmod u+w {} ';' ; \
rm -rf -- python$${VERSION}-gpg* ; \ rm -rf -- "$$(basename "$${PYTHON}")-gpg" ; \
done done
install-exec-local: install-exec-local:
set -e ; set $(PYTHONS); for VERSION in $(PYTHON_VERSIONS); do \ set -e ; for PYTHON in $(PYTHONS); do \
PYTHON="$$1" ; shift ; \
srcdir="$(srcdir)" \ srcdir="$(srcdir)" \
top_builddir="$(top_builddir)" \ top_builddir="$(top_builddir)" \
$$PYTHON setup.py \ $$PYTHON setup.py \
build \ build \
--build-base=python$${VERSION}-gpg \ --build-base="$$(basename "$${PYTHON}")-gpg" \
install \ install \
--prefix "$(DESTDIR)$(prefix)" \ --prefix "$(DESTDIR)$(prefix)" \
--verbose ; \ --verbose ; \
done done
uninstall-local: uninstall-local:
GV=$$(echo $(VERSION) | tr - _); for PV in $(PYTHON_VERSIONS); do \ GV=$$(echo $(VERSION) | tr - _); for PYTHON in $(PYTHONS); do \
rm -rf -- "$(DESTDIR)$(prefix)"/lib*/python$$PV/site-packages/gpg \ PLATLIB="$(prefix)/$$("$${PYTHON}" -c 'import sysconfig, os; print(os.path.relpath(sysconfig.get_path("platlib"), sysconfig.get_config_var("prefix")))')" ; \
"$(DESTDIR)$(prefix)"/lib*/python$$PV/site-packages/gpg-$$GV-py$$PV.egg-info ; \ rm -rf -- "$(DESTDIR)$${PLATLIB}/gpg" \
"$(DESTDIR)$${PLATLIB}"/gpg-$$GV-py*.egg-info ; \
done done

View File

@ -70,8 +70,8 @@ for interpreter in args.interpreters:
[interpreter, "-c", "import sys; print('{0}.{1}'.format(sys.version_info[0], sys.version_info[1]))"]).strip().decode() [interpreter, "-c", "import sys; print('{0}.{1}'.format(sys.version_info[0], sys.version_info[1]))"]).strip().decode()
pattern = os.path.join(args.builddir, "..", pattern = os.path.join(args.builddir, "..",
"python{0}-gpg".format(version), "{0}-gpg".format(os.path.basename(interpreter)),
"lib*"+version) "lib*")
builddirs = glob.glob(pattern) builddirs = glob.glob(pattern)
if len(builddirs) == 0: if len(builddirs) == 0:
sys.exit("Build directory matching {0!r} not found.".format(pattern)) sys.exit("Build directory matching {0!r} not found.".format(pattern))