Skip to content

Commit

Permalink
Stop adding PYTHON_CFGDIR to LD_RUN_PATH and PYTHON_LDFLAGS if there …
Browse files Browse the repository at this point in the history
…is no libpython

The PYTHON_CFGDIR variable is more or less something like /usr/lib64/python3.12/config.

Not only does this directory not exist on Python 3.6+ (it is called differently),
but there is no libpython.so in it.
Adding it to LD paths makes no difference.

I could fix up the way the path is determined,
but I decided not to touch this code not to break old use cases.

Instead, the directory is only added to LD paths when there is something relevant in it.

Fixes GrahamDumpleton#872
  • Loading branch information
hroncok committed Jan 15, 2024
1 parent f54eadd commit dbbbd24
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,19 +300,21 @@ def get_apu_includes():
if not os.path.exists(PYTHON_CFGDIR):
PYTHON_CFGDIR = '%s-%s' % (PYTHON_CFGDIR, sys.platform)

PYTHON_LDFLAGS = ['-L%s' % PYTHON_CFGDIR]
PYTHON_LDFLAGS = []
if PYTHON_LIBDIR != APXS_LIBDIR:
PYTHON_LDFLAGS.insert(0, '-L%s' % PYTHON_LIBDIR)
PYTHON_LDFLAGS.append('-L%s' % PYTHON_LIBDIR)

PYTHON_LDLIBS = ['-lpython%s' % PYTHON_LDVERSION]

if os.path.exists(os.path.join(PYTHON_LIBDIR,
'libpython%s.a' % PYTHON_VERSION)):
PYTHON_LDLIBS = ['-lpython%s' % PYTHON_VERSION]
PYTHON_LDFLAGS.append('-L%s' % PYTHON_CFGDIR)

if os.path.exists(os.path.join(PYTHON_CFGDIR,
'libpython%s.a' % PYTHON_VERSION)):
PYTHON_LDLIBS = ['-lpython%s' % PYTHON_VERSION]
PYTHON_LDFLAGS.append('-L%s' % PYTHON_CFGDIR)

# Create the final set of compilation flags to be used.

Expand All @@ -326,7 +328,9 @@ def get_apu_includes():
LD_RUN_PATHS = []
if os.name != 'nt':
LD_RUN_PATH = os.environ.get('LD_RUN_PATH', '')
LD_RUN_PATHS = [PYTHON_CFGDIR]
LD_RUN_PATHS = []
if '-L%s' % PYTHON_CFGDIR in PYTHON_LDFLAGS:
LD_RUN_PATHS.append(PYTHON_CFGDIR)
if PYTHON_LIBDIR != APXS_LIBDIR:
LD_RUN_PATHS.insert(0, PYTHON_LIBDIR)
LD_RUN_PATH += ':' + ':'.join(LD_RUN_PATHS)
Expand Down

0 comments on commit dbbbd24

Please sign in to comment.