1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-26 21:57:41 +03:00

buildtools: Add --extra-python configure option

This allows building Python support for two different Python versions
at the same time.

Signed-off-by: Petr Viktorin <pviktori@redhat.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jelmer Vernooij <jelmer@samba.org>
This commit is contained in:
Petr Viktorin 2015-01-15 14:22:22 +01:00 committed by Andrew Bartlett
parent 13a91e5427
commit 616dfae8ff
4 changed files with 48 additions and 4 deletions

View File

@ -59,6 +59,10 @@ def install_library(self):
bld = self.bld
default_env = bld.all_envs['default']
if self.env['IS_EXTRA_PYTHON']:
bld.all_envs['default'] = bld.all_envs['extrapython']
install_ldflags = install_rpath(self)
build_ldflags = build_rpath(bld)
@ -83,7 +87,7 @@ def install_library(self):
# install link. That stops us from overwriting the existing build
# target, which has different ldflags
self.done_install_library = True
t = self.clone('default')
t = self.clone(self.env)
t.posted = False
t.target += '.inst'
self.env.RPATH = build_ldflags
@ -144,6 +148,8 @@ def install_library(self):
if dev_link:
bld.symlink_as(os.path.join(install_path, dev_link), os.path.basename(install_name))
bld.all_envs['default'] = default_env
@feature('cshlib')
@after('apply_implib')

View File

@ -9,20 +9,50 @@ from Configure import conf
@conf
def SAMBA_CHECK_PYTHON(conf, mandatory=True, version=(2,4,2)):
# enable tool to build python extensions
if conf.env['EXTRA_PYTHON']:
conf.all_envs['extrapython'] = conf.env.copy()
conf.setenv('extrapython')
conf.env['PYTHON'] = conf.env['EXTRA_PYTHON']
conf.env['IS_EXTRA_PYTHON'] = 'yes'
conf.find_program('python', var='PYTHON', mandatory=True)
conf.check_tool('python')
try:
conf.check_python_version((3, 3, 0))
except Exception:
warn('extra-python needs to be Python 3.3 or later')
raise
conf.setenv('default')
conf.find_program('python', var='PYTHON', mandatory=mandatory)
conf.check_tool('python')
path_python = conf.find_program('python')
conf.env.PYTHON_SPECIFIED = (conf.env.PYTHON != path_python)
conf.check_python_version(version)
@conf
def SAMBA_CHECK_PYTHON_HEADERS(conf, mandatory=True):
if conf.env["python_headers_checked"] == []:
conf.check_python_headers(mandatory)
if conf.env['EXTRA_PYTHON']:
conf.setenv('extrapython')
_check_python_headers(conf, mandatory=True)
conf.setenv('default')
_check_python_headers(conf, mandatory)
conf.env["python_headers_checked"] = "yes"
if conf.env['EXTRA_PYTHON']:
extraversion = conf.all_envs['extrapython']['PYTHON_VERSION']
if extraversion == conf.env['PYTHON_VERSION']:
raise Utils.WafError("extrapython %s is same as main python %s" % (
extraversion, conf.env['PYTHON_VERSION']))
else:
conf.msg("python headers", "using cache")
def _check_python_headers(conf, mandatory):
conf.check_python_headers(mandatory=mandatory)
if conf.env['PYTHON_VERSION'] > '3':
abi_pattern = os.path.splitext(conf.env['pyext_PATTERN'])[0]
conf.env['PYTHON_SO_ABI_FLAG'] = abi_pattern % ''

View File

@ -217,10 +217,10 @@ def SAMBA_LIBRARY(bld, libname, source,
if vnum is None and soname is None:
raise Utils.WafError("public library '%s' must have a vnum" %
libname)
if pc_files is None:
if pc_files is None and not bld.env['IS_EXTRA_PYTHON']:
raise Utils.WafError("public library '%s' must have pkg-config file" %
libname)
if public_headers is None:
if public_headers is None and not bld.env['IS_EXTRA_PYTHON']:
raise Utils.WafError("public library '%s' must have header files" %
libname)

View File

@ -195,6 +195,12 @@ def set_options(opt):
help='tag release in git at the same time',
type='string', action='store', dest='TAG_RELEASE')
opt.add_option('--extra-python', type=str,
help=("build selected libraries for the specified "
"additional version of Python "
"(example: --extra-python=/usr/bin/python3)"),
metavar="PYTHON", dest='EXTRA_PYTHON', default=None)
@wafsamba.runonce
def configure(conf):
@ -266,6 +272,8 @@ def configure(conf):
conf.env.AUTOCONF_HOST = Options.options.AUTOCONF_HOST
conf.env.AUTOCONF_PROGRAM_PREFIX = Options.options.AUTOCONF_PROGRAM_PREFIX
conf.env.EXTRA_PYTHON = Options.options.EXTRA_PYTHON
if (conf.env.AUTOCONF_HOST and
conf.env.AUTOCONF_BUILD and
conf.env.AUTOCONF_BUILD != conf.env.AUTOCONF_HOST):