[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gpsd-dev] [PATCH]: Link Python extensions with libpython
From: |
Matt |
Subject: |
Re: [gpsd-dev] [PATCH]: Link Python extensions with libpython |
Date: |
Sun, 07 Dec 2014 21:59:48 +1100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.2.0 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Bernd, thank you for your response - it helped my understanding a lot.
I did some further research, yielding the attached patch. Could you
review it, please?
Details:
Under Cygwin, the relevant entries in the dictionary returned by
sysconfig.get_config_vars are:
'BLDLIBRARY': 'libpython2.7.dll.a'
'DLLLIBRARY': 'libpython2.7.dll'
'INSTSONAME': 'libpython2.7.dll.a'
'LDLIBRARY': 'libpython2.7.dll.a'
'LIBDIR': '/usr/lib'
'LIBRARY': 'libpython2.7.a'
'LIBS': '-ldl'
Note the absence of 'python2.7' and '-lpython2.7'.
Nevertheless, /usr/bin/python2.7-config --libs outputs:
$ /usr/bin/python2.7-config --libs
- -ldl -lpython2.7
This is because python2.7-config does:
elif opt in ('--libs', '--ldflags'):
libs = getvar('LIBS').split() + getvar('SYSLIBS').split()
libs.append('-lpython'+pyver)
Given this, I suppose that we should either:
1. Shell out to "python-config --libs" instead of using distutils; or
2. Mimic python-config, by hard-coding "-lpython"+pyver into
SConstruct; or
3. Call sysconfig.get_config_var('LIBRARY') and merge it into
python_env as LIBS
I am not sure whether we should use LIBRARY (static link) or LDLIBRARY
(dynamic link). Either works on Cygwin.
In any case, the attached patch implements approach #3 above.
It fixes the Cygwin build, doesn't break the Linux build, and does not
cause the 'overlinking' that my previous attempt caused.
Matt
- -----Original Message-----
From: Bernd Zeimetz [mailto:address@hidden
Sent: Monday, 17 November 2014 06:50
To: Matt; address@hidden
Subject: Re: [gpsd-dev] [PATCH]: Link Python extensions with libpython
On 09/09/2014 10:34 AM, Matt wrote:
> This patch isn't entirely correct - it links all binaries and
> shared objects against the python runtime library, but only some of
> them (not all) actually need libpython. I don't yet see how to fix
> this.
The patch shouldn't be necessary at all, or something around the lines of
vars = sysconfig.get_config_vars('CC', 'CXX', 'OPT', 'BASECFLAGS',
'CCSHARED', 'LDSHARED', 'SO', 'INCLUDEPY', 'LDFLAGS')
for i in range(len(vars)):
if vars[i] is None:
vars[i] = []
(cc, cxx, opt, basecflags, ccshared, ldshared, so_ext, includepy,
ldflags) = vars
is wrong - or distutils is broken on cygwin.
>
> With this change, all binaries compile on Cygwin, but regression
> tests fail due to:
>
> gpsfake: socket error [ Errno 111] Connection refused.
>
> I haven't root-caused this yet, but it appears shallow.
- --
Bernd Zeimetz Debian GNU/Linux Developer
http://bzed.de http://www.debian.org
GPG Fingerprint: ECA1 E3F2 8E11 2432 D485 DD95 EB36 171A 6FF9 435F
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iQEcBAEBAgAGBQJUhDMkAAoJECH/phKUbjXC3GwH+wbozT5VtbfpcOivjz5wh6dL
s0iwmotQEyXoR70XyRzzuc6LX9lx9XK6Plf8sRF+LAhKdmd0STe9tv03SEJOV4bQ
bo7NOnF9T0ppOAbxu5J+vi10J21kQn6n39Jy/MuntI2Iz0CYvjsQ2RM3e73wCovi
ETnToE0Jpa4QsU67E9UTl0nQsdBPa1bb1dZwo104AjeYKtsr5k/2LWvcakbakk6u
7crbjqbEdDyUQulSua71XyaQMG++cMXd5ifBTirIwjW8UanNetvqH641PEHoP0np
vJ8o/7u1R8XlaoOjx25TsrQBstfBwa2qGLrSznE19a1NeADFLHLnqNFvVVtcMBA=
=LafR
-----END PGP SIGNATURE-----
link-python-extensions-with-libpython-attempt-2.patch
Description: Text Data
- Re: [gpsd-dev] [PATCH]: Link Python extensions with libpython,
Matt <=