Skip to content

Add an explicit --with-python= configure option#37

Closed
monnerat wants to merge 1 commit intomate-desktop:masterfrom
monnerat:python-version
Closed

Add an explicit --with-python= configure option#37
monnerat wants to merge 1 commit intomate-desktop:masterfrom
monnerat:python-version

Conversation

@monnerat
Copy link
Contributor

@monnerat monnerat commented Feb 5, 2019

This allows specifying a Python interpreter without using the obscure trick
of externally defining PYTHON in environment.

The configure report now also displays the effective Python version.

Ref: #34 (comment)

This allows specifying a Python interpreter without using the obscure trick
of externally defining PYTHON in environment.

The configure report now also displays the effective Python version.

Ref: #34 (comment)
@monnerat monnerat mentioned this pull request Feb 5, 2019
Copy link
Member

@lukefromdc lukefromdc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got this error on trying to configure with
./autogen.sh --prefix=/usr --with-python=3.7 :

checking whether 3.7 version is >= 2.7... no
configure: error: Python interpreter is too old

@monnerat
Copy link
Contributor Author

monnerat commented Feb 7, 2019

I got this error on trying to configure with
./autogen.sh --prefix=/usr --with-python=3.7

You have to specify the Python interpreter, not the version. Example:

./autogen.sh --prefix=/usr --with-python=/usr/bin/python3.7

@monsta
Copy link
Contributor

monsta commented Feb 7, 2019

It could be done as --with-python2 and --with-python3, in that case there's no need to specify the value (or specify yes).

Actually, I didn't know that ./configure --help provides some help for PYTHON var after all...

Some influential environment variables:

...

  PYTHON      the Python interpreter
  PYTHON_CFLAGS
              C compiler flags for PYTHON, overriding pkg-config
  PYTHON_LIBS linker flags for PYTHON, overriding pkg-config

@monnerat
Copy link
Contributor Author

monnerat commented Feb 7, 2019

It could be done as --with-python2 and --with-python3, in that case there's no need to specify the value (or specify yes).

This has no effect, because they are not handled by our configure file.
Implementing them as such is quite hard since we have no logic to determine where is the interpreter for a particular version. AM_PATH_PYTHON tries some predefined locations (in descending version order) until it finds one matching the minimum version requirement.

Actually, I didn't know that ./configure --help provides some help for PYTHON var after all...

Yes, and that's the way raveit65's rpm file for Fedora 29 does.

As a consequence, this --with-python= parameter is not really important, but I think mentioning the effective Python version in the configure report could really show if things happened as expected (currrently, a misconfiguration is silently accepted).

@monsta
Copy link
Contributor

monsta commented Feb 9, 2019

Ok, I'm fine with just showing Python version in the configure's summary.

@lukefromdc lukefromdc dismissed their stale review February 9, 2019 19:11

Successful build with new instructions

@lukefromdc
Copy link
Member

I just got a successful build and install with
./autogen.sh --prefix=/usr --with-python=/usr/bin/python3.7
The only thing I had to test it with was my old caja-admin package, at runtime it errored out with



(caja:17448): Caja-Python-WARNING **: 14:10:48.682: g_module_open libpython failed:
/libpython3.7m.so.1.0: cannot open shared object file: No such file or directory

(caja:17448): Caja-Python-WARNING **: 14:10:48.724: pygobject initialization failed

(caja:17448): Caja-Python-WARNING **: 14:10:48.724: caja_python_init_python failed
ImportError: could not import gobject (error was: ImportError('/usr/lib/python3/dist-packages/gi/_gi.cpython-37m-x86_64-linux-gnu.so: undefined symbol: PyExc_NotImplementedError'))

but that's probably something wrong on my end and nothing to do with the package. I did NOT get the "site-packages" wrong directory install problem I often see with python 2.7 packages locally built on Debian

@monsta
Copy link
Contributor

monsta commented Feb 10, 2019

@lukefromdc: same old Debian-specific problem (#31), you need to keep the patch I've mentioned there...

@lukefromdc
Copy link
Member

OK, applying that patch gave a successful build and install, though it looks like caja-admin(which I used to test a build against python 3.7) might not like python3.7 (though I am no expert on python):


Initializing caja-xattr-tags extension
Initializing caja-open-terminal extension
Initializing caja-image-converter extension
Traceback (most recent call last):
  File "/usr/share/caja-python/extensions/caja-admin.py", line 18, in <module>
    import os, subprocess, urlparse, traceback
ModuleNotFoundError: No module named 'urlparse'

@monnerat
Copy link
Contributor Author

ModuleNotFoundError: No module named 'urlparse'

The problem is definitely not in python-caja: you should report it to the caja-admin project and continue this discussion there.
IMHO, caja-admin has not been ported to Python3: urlparse has been renamed in Python 3. See https://docs.python.org/2/library/urlparse.html.

Ok, I'm fine with just showing Python version in the configure's summary.

Thus my plan is to cancel the current PR and create a new one showing in the configure report:

  • the effective Python version,
  • the python library location to ease visual check on Debian/Ubuntu.

The proposed --with-python= configure argument will not be implemented, leaving the interpreter selectable through the AM_PATH_PYTHON-supported environment variable PYTHON, as it is already now.

@lukefromdc
Copy link
Member

I see caja-admin in four different repos on github, not sure if
https://github.com/infirit/caja-admin
is the original but it hasn't been updated since Oct 2017 and same with the others. Sorry about any noise on this PR from problems with what I was trying to test it with

@monnerat
Copy link
Contributor Author

I see caja-admin in four different repos on github...

This project is not in the Fedora package database , thus I can't help you with some official reference we have. Since you seem to use debian, maybe have a look of their reference if some. If it's a custom package, then you have to chose yourself :-)

@lukefromdc
Copy link
Member

I don't actually use it anymore, I was just trying to test this PR

@monsta
Copy link
Contributor

monsta commented Feb 11, 2019

@monnerat: ok, I'm fine with the plan.

Yes, caja-admin is still Python 2. I see the same urlparse error in my Debian Testing VM.
Looking at the homepage link at https://tracker.debian.org/pkg/caja-admin, I see it points to infirit's repo.

@monnerat
Copy link
Contributor Author

same old Debian-specific problem (#31), you need to keep the patch I've mentioned there...

@monsta: I have found an alternate possible definition for PYTHON_LIB_LOC:

PYTHON_LIB_LOC=`$PYTHON -c 'from distutils.sysconfig import get_config_var; print (get_config_var("LIBDIR"))'`

Can you please test on Debian ? If it works, I propose to integrate it in my next PR. Thanks in advance.

@lukefromdc
Copy link
Member

Using the older Debian patch and a python 2.7 build, caja-admin worked.
A python 2.7 build using your suggested patch, again with caja-admin, gave this error, same as the usual Debian problem it looks like:


(caja:14500): Caja-Python-WARNING **: 20:17:13.716: g_module_open libpython failed: /usr/lib/libpython2.7.so.1.0: cannot open shared object file: No such file or directory
ImportError: could not import gobject (error was: '/usr/lib/python2.7/dist-packages/gi/_gi.x86_64-linux-gnu.so: undefined symbol: _Py_ZeroStruct')

(caja:14500): Caja-Python-WARNING **: 20:17:13.749: pygobject initialization failed

(caja:14500): Caja-Python-WARNING **: 20:17:13.749: caja_python_init_python failed

@monnerat
Copy link
Contributor Author

@lukefromdc: thanks for your testing and reporting. I'll then not change the PYTHON_LIB_LOC definition.

@lukefromdc
Copy link
Member

When things come up that are Debian specific I try to get to them

@monnerat
Copy link
Contributor Author

When things come up that are Debian specific I try to get to them

I note it for eventual future test requests :-)
I was just trying something that could have withdrawn the need for the patch...
Thanks again.

@monnerat
Copy link
Contributor Author

@lukefromdc: you can find a Python 3 version of caja-admin at https://github.com/monnerat/caja-admin/tree/python3

@monnerat
Copy link
Contributor Author

PR #39 replaces this one, thus closing.

@monnerat monnerat closed this Feb 12, 2019
@monnerat monnerat deleted the python-version branch February 12, 2019 02:45
@monsta
Copy link
Contributor

monsta commented Feb 12, 2019

Yeah, that change didn't work in my Debian as well...

monsta@jessica:~$ python -c 'from distutils.sysconfig import get_config_var; print (get_config_var("LIBDIR"))'
/usr/lib
monsta@jessica:~$ python3 -c 'from distutils.sysconfig import get_config_var; print (get_config_var("LIBDIR"))'
/usr/lib
monsta@jessica:~$ pkg-config gobject-introspection-1.0 --variable=libdir
/usr/lib/x86_64-linux-gnu

@monnerat
Copy link
Contributor Author

Yeah, that change didn't work in my Debian as well...

Thanks for the test and info. As established last night with lukefromdc, I've dropped this idea for PR #39.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants