enabled=True):
'''build a python extension for Samba'''
+ if bld.env['IS_EXTRA_PYTHON']:
+ name = 'extra-' + name
+
# when we support static python modules we'll need to gather
# the list from all the SAMBA_PYTHON() targets
if init_function_sentinel is not None:
return name + bld.env['PYTHON_SO_ABI_FLAG']
Build.BuildContext.pyembed_libname = pyembed_libname
+
+
+def gen_python_environments(bld, extra_env_vars=()):
+ """Generate all Python environments
+
+ To be used in a for loop. Normally, the loop body will be executed once.
+
+ When --extra-python is used, the body will additionaly be executed
+ with the extra-python environment active.
+ """
+ yield
+
+ if bld.env['EXTRA_PYTHON']:
+ copied = ('GLOBAL_DEPENDENCIES', 'TARGET_TYPE') + tuple(extra_env_vars)
+ for name in copied:
+ bld.all_envs['extrapython'][name] = bld.all_envs['default'][name]
+ default_env = bld.all_envs['default']
+ bld.all_envs['default'] = bld.all_envs['extrapython']
+ yield
+ bld.all_envs['default'] = default_env
+
+Build.BuildContext.gen_python_environments = gen_python_environments
manpages='man/talloc.3')
if not bld.CONFIG_SET('USING_SYSTEM_PYTALLOC_UTIL') and not bld.env.disable_python:
- name = bld.pyembed_libname('pytalloc-util')
-
- bld.SAMBA_LIBRARY(name,
- source='pytalloc_util.c',
- public_deps='talloc',
- pyembed=True,
- vnum=VERSION,
- hide_symbols=True,
- abi_directory='ABI',
- abi_match='pytalloc_*',
- private_library=private_library,
- public_headers='pytalloc.h',
- pc_files='pytalloc-util.pc'
- )
- bld.SAMBA_PYTHON('pytalloc',
- 'pytalloc.c',
- deps='talloc ' + name,
- enabled=True,
- realname='talloc.so')
-
- bld.SAMBA_PYTHON('test_pytalloc',
- 'test_pytalloc.c',
- deps='pytalloc',
- enabled=True,
- realname='_test_pytalloc.so',
- install=False)
-
- if bld.env['EXTRA_PYTHON']:
- for var_name in ('GLOBAL_DEPENDENCIES', 'TARGET_TYPE', 'PKGCONFIGDIR'):
- bld.all_envs['extrapython'][var_name] = bld.all_envs['default'][var_name]
- bak = bld.all_envs['default']
- bld.all_envs['default'] = bld.all_envs['extrapython']
-
- name = bld.pyembed_libname('pytalloc-util')
-
- bld.SAMBA_LIBRARY(name,
- source='pytalloc_util.c',
- public_deps='talloc',
- pyembed=True,
- vnum=VERSION,
- hide_symbols=True,
- abi_directory='ABI',
- abi_match='pytalloc_*',
- private_library=private_library,
- #public_headers='pytalloc.h',
- #pc_files='pytalloc-util.pc'
- )
-
- bld.SAMBA_PYTHON('extra-pytalloc',
- 'pytalloc.c',
- deps='talloc ' + name,
- enabled=True,
- realname='talloc.so')
-
- bld.SAMBA_PYTHON('extra-test_pytalloc',
- 'test_pytalloc.c',
- deps='pytalloc',
- enabled=True,
- realname='_test_pytalloc.so',
- install=False)
-
- bld.all_envs['default'] = bak
+ for env in bld.gen_python_environments(['PKGCONFIGDIR']):
+ name = bld.pyembed_libname('pytalloc-util')
+
+ bld.SAMBA_LIBRARY(name,
+ source='pytalloc_util.c',
+ public_deps='talloc',
+ pyembed=True,
+ vnum=VERSION,
+ hide_symbols=True,
+ abi_directory='ABI',
+ abi_match='pytalloc_*',
+ private_library=private_library,
+ public_headers='pytalloc.h',
+ pc_files='pytalloc-util.pc'
+ )
+ bld.SAMBA_PYTHON('pytalloc',
+ 'pytalloc.c',
+ deps='talloc ' + name,
+ enabled=True,
+ realname='talloc.so')
+
+ bld.SAMBA_PYTHON('test_pytalloc',
+ 'test_pytalloc.c',
+ deps='pytalloc',
+ enabled=True,
+ realname='_test_pytalloc.so',
+ install=False)
def test(ctx):