#12 Use PKG_CHECK_MODULES for python2
Closed 5 years ago by cathay4t. Opened 6 years ago by cathay4t.
cathay4t/volume_key master  into  master

file modified
+4 -4
@@ -20,7 +20,6 @@ 

  AM_CPPFLAGS = $(blkid_CFLAGS) $(glib_CFLAGS) $(GPGME_CFLAGS) \

  	$(libcryptsetup_CFLAGS) $(nss_CFLAGS)

  LOCALEDIR_CPPFLAGS = -DLOCALEDIR='"$(localedir)"'

- PYTHON_CPPFLAGS = -I/usr/include/python$(PYTHON_VERSION)

  

  ## Targets

  SUBDIRS = po
@@ -63,9 +62,10 @@ 

  	$(LTLIBINTL) $(libcryptsetup_LIBS) $(nss_LIBS)

  

  python__volume_key_la_SOURCES = python/volume_key_wrap.c

- python__volume_key_la_CPPFLAGS = $(AM_CPPFLAGS) $(PYTHON_CPPFLAGS)

- python__volume_key_la_LDFLAGS = -module -avoid-version $(glib_LIBS)

- python__volume_key_la_LIBADD = lib/libvolume_key.la -lpython$(PYTHON_VERSION) \

+ python__volume_key_la_CPPFLAGS = $(AM_CPPFLAGS) $(PYTHON_CFLAGS)

+ python__volume_key_la_LDFLAGS = -module -avoid-version $(glib_LIBS) \

+ 	$(PYTHON_LIBS)

+ python__volume_key_la_LIBADD = lib/libvolume_key.la \

  	$(glib_LIBS) $(nss_LIBS)

  

  src_volume_key_SOURCES = src/volume_key.c

file modified
+1
@@ -42,6 +42,7 @@ 

  	  [Stay away from deprecated glib functionality.])

  PKG_CHECK_MODULES(libcryptsetup, [libcryptsetup])

  PKG_CHECK_MODULES(nss, [nss])

+ PKG_CHECK_MODULES([PYTHON], [python2])

  

  AM_PATH_GPGME

  

The hardcoded python CFLAGS and CLIBS are not working on Archlinux where
default python is python3.

Changed to use PKG_CHECK_MODULES to detect CFLAGS and LDFLAGS of python.

Signed-off-by: Gris Ge cnfourt@gmail.com

Tried on python3, it fails. Hence updated the configure.ac to use python2 only.

This will affect Fedora soon since Fedora is changing /usr/bin/python pointing to python3.

https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3

Thanks for the patch.

Is it really necessary to use both AM_PATH_PYTHON and PKG_CHECK_MODULES here? It seems risky to look up the same software package with two completely independent mechanisms and to hope that they will both find exactly the same version.

Gentoo has proposed a similar patch for Python3, where the include/library paths are indeed different (3.5m vs. 3.5), but volume_key currently doesn’t support Python 3 at all, so that difference is moot. Do the hard-coded paths for Python 2 not match on ArchLinux?

Yes. both are needed: AM_PATH_PYTHON and AC_PATH_PROGS are setting the PYTHON variable(and others) where swig will use. PKG_CHECK_MODULES is checking the existence of C header(python2-devel) for compiling python C extension.

The root cause of failure on Archlinux is not caused by hard-coded path, but caused by swig are using python3 folder since /usr/bin/python is pointing to python3 and PYTHON variable is empty.

Isn’t the AC_PATH_PROGS(PYTHON, …)+AM_PATH_PYTHON pair sufficient for AM_PATH_PYTHON to use Python 2, and the Python 2 include directories?

Yes. They do.

The PKG_CHECK_MODULES is for checking C headers of python -- python2-devel rpm package.

BTW. The use of PKG_CHECK_MODULES is to eliminate the hard-coded CFLAGS and LDFLAGS for python C extention.

@mitr Any thing I could do to get this merged?

Just encountered this issue when packaging for NixOS. This patch looks great.

@mitr Why not consider making volume_key support Python 3?

@cathay4t This doesn't apply cleanly anymore to master. Can you rebase?

rebased onto 8eda66d

5 years ago

Gentoo has proposed a similar patch for Python3, where the include/library paths are indeed different (3.5m vs. 3.5), but volume_key currently doesn’t support Python 3 at all, so that difference is moot.

This becomes issue also on Fedora (i.e. the path to Python 3 C headers is /usr/include/python3.6m instead of /usr/include/python3.6) and it can be resolved by python3-config, so PKG_CHECK_MODULES is not necessary.

volume_key now supports Python 3 only. I tried build it on Archlinux and it compiles smoothly. Can this pull request be closed?

Pull-Request has been closed by cathay4t

5 years ago
Metadata