Add clang workaround for pythonz

needed that to install python 3.6.8 on debian 12
This commit is contained in:
Lance Edgar 2023-08-03 21:20:22 -05:00
parent 94945fbc30
commit ab1baaa6d2

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2022 Lance Edgar
# Copyright © 2010-2023 Lance Edgar
#
# This file is part of Rattail.
#
@ -112,7 +112,8 @@ def configure_pythonz(c, user):
use_sudo=True)
def install_python(c, version, globally=False, verbose=False):
def install_python(c, version, globally=False, verbose=False,
use_clang=False):
"""
Install a specific version of python, via pythonz.
@ -121,10 +122,17 @@ def install_python(c, version, globally=False, verbose=False):
symlink, if installed, will use the "short" version, e.g. if the
``version`` specified is ``'3.5.3'`` then the symlink will be named
``'python3.5'``.
:param use_clang: Use `clang` instead of default compiler. May be
needed in rare cases for older python versions. See also
https://stackoverflow.com/a/73267352
"""
if use_clang:
apt.install(c, 'clang')
if not exists(c, '/usr/local/pythonz/pythons/CPython-{}'.format(version)):
clang = 'CC=clang' if use_clang else ''
verbose = '--verbose' if verbose else ''
c.sudo("bash -lc 'pythonz install {} {}'".format(verbose, version))
c.sudo(f"bash -lc '{clang} pythonz install {verbose} {version}'")
if globally:
short_version = '.'.join(version.split('.')[:2])
c.sudo('ln -sf /usr/local/pythonz/pythons/CPython-{0}/bin/python{1} /usr/local/bin/python{1}'.format(