[Python-checkins] distutils2: Parsing extension sections with interpret in setup.cfg
tarek.ziade
python-checkins at python.org
Wed Feb 16 22:23:55 CET 2011
tarek.ziade pushed 8813f2ecd580 to distutils2:
http://hg.python.org/distutils2/rev/8813f2ecd580
changeset: 987:8813f2ecd580
user: Andre Espaze <andre.espaze at logilab.fr>
date: Sun Jan 30 18:06:00 2011 +0100
summary:
Parsing extension sections with interpret in setup.cfg
files:
distutils2/config.py
distutils2/tests/test_config.py
diff --git a/distutils2/config.py b/distutils2/config.py
--- a/distutils2/config.py
+++ b/distutils2/config.py
@@ -14,13 +14,22 @@
from distutils2.util import check_environ, resolve_name, strtobool
from distutils2.compiler import set_compiler
from distutils2.command import set_command
+from distutils2.markers import interpret
def _pop_values(values_dct, key):
"""Remove values from the dictionary and convert them as a list"""
vals_str = values_dct.pop(key, '')
+ if not vals_str:
+ return
+ fields = []
+ for field in vals_str.split(os.linesep):
+ tmp_vals = field.split('--')
+ if (len(tmp_vals) == 2) and (not interpret(tmp_vals[1])):
+ continue
+ fields.append(tmp_vals[0])
# Get bash options like `gcc -print-file-name=libgcc.a`
- vals = split(vals_str)
+ vals = split(' '.join(fields))
if vals:
return vals
diff --git a/distutils2/tests/test_config.py b/distutils2/tests/test_config.py
--- a/distutils2/tests/test_config.py
+++ b/distutils2/tests/test_config.py
@@ -105,6 +105,8 @@
sources = c_src/speed_coconuts.c
extra_link_args = "`gcc -print-file-name=libgcc.a`" -shared
define_macros = HAVE_CAIRO HAVE_GTK2
+libraries = gecodeint gecodekernel -- sys.platform != 'win32'
+ GecodeInt GecodeKernel -- sys.platform == 'win32'
[extension=fast_taunt]
name = three.fast_taunt
@@ -113,6 +115,8 @@
include_dirs = /usr/include/gecode
/usr/include/blitz
extra_compile_args = -fPIC -O2
+ -DGECODE_VERSION=$(./gecode_version) -- sys.platform != 'win32'
+ /DGECODE_VERSION='win32' -- sys.platform == 'win32'
language = cxx
"""
@@ -284,6 +288,10 @@
ext = ext_modules.get('one.speed_coconuts')
self.assertEqual(ext.sources, ['c_src/speed_coconuts.c'])
self.assertEqual(ext.define_macros, ['HAVE_CAIRO', 'HAVE_GTK2'])
+ libs = ['gecodeint', 'gecodekernel']
+ if sys.platform == 'win32':
+ libs = ['GecodeInt', 'GecodeKernel']
+ self.assertEqual(ext.libraries, libs)
self.assertEqual(ext.extra_link_args,
['`gcc -print-file-name=libgcc.a`', '-shared'])
@@ -292,7 +300,12 @@
['cxx_src/utils_taunt.cxx', 'cxx_src/python_module.cxx'])
self.assertEqual(ext.include_dirs,
['/usr/include/gecode', '/usr/include/blitz'])
- self.assertEqual(ext.extra_compile_args, ['-fPIC', '-O2'])
+ cargs = ['-fPIC', '-O2']
+ if sys.platform == 'win32':
+ cargs.append("/DGECODE_VERSION='win32'")
+ else:
+ cargs.append('-DGECODE_VERSION=$(./gecode_version)')
+ self.assertEqual(ext.extra_compile_args, cargs)
self.assertEqual(ext.language, 'cxx')
--
Repository URL: http://hg.python.org/distutils2
More information about the Python-checkins
mailing list