summaryrefslogtreecommitdiff
path: root/src/distutils2
diff options
context:
space:
mode:
authortarek <devnull@localhost>2010-02-22 00:15:39 -0500
committertarek <devnull@localhost>2010-02-22 00:15:39 -0500
commit21f60adf286f489f9959647236879db09f7e58ea (patch)
tree8654cb2852e485dd492dae31695346bdfbae4641 /src/distutils2
parentd3d883d7f595ac5d49009eaff3c00329dbc249b8 (diff)
downloaddisutils2-21f60adf286f489f9959647236879db09f7e58ea.tar.gz
refactoring of the name ... done
Diffstat (limited to 'src/distutils2')
-rw-r--r--src/distutils2/ccompiler.py2
-rw-r--r--src/distutils2/extension.py108
-rw-r--r--src/distutils2/tests/__init__.py2
-rwxr-xr-xsrc/distutils2/tests/test_extension.py57
4 files changed, 9 insertions, 160 deletions
diff --git a/src/distutils2/ccompiler.py b/src/distutils2/ccompiler.py
index 08fe152..dd57d29 100644
--- a/src/distutils2/ccompiler.py
+++ b/src/distutils2/ccompiler.py
@@ -1041,7 +1041,7 @@ def new_compiler(plat=None, compiler=None, verbose=0, dry_run=0, force=0):
raise DistutilsPlatformError, msg
try:
- module_name = "distutils." + module_name
+ module_name = "distutils2." + module_name
__import__ (module_name)
module = sys.modules[module_name]
klass = vars(module)[class_name]
diff --git a/src/distutils2/extension.py b/src/distutils2/extension.py
index 8acb98d..3d30668 100644
--- a/src/distutils2/extension.py
+++ b/src/distutils2/extension.py
@@ -8,6 +8,11 @@ __revision__ = "$Id: extension.py 77704 2010-01-23 09:23:15Z tarek.ziade $"
import os
import warnings
+try:
+ import sysconfig
+except ImportError:
+ from distutils2._backport import sysconfig
+
# This class is really only used by the "build_ext" command, so it might
# make sense to put it in distutils.command.build_ext. However, that
# module is already big enough, and I want to make this class a bit more
@@ -132,106 +137,3 @@ class Extension:
msg = "Unknown Extension options: %s" % options
warnings.warn(msg)
-def read_setup_file(filename):
- """Reads a Setup file and returns Extension instances."""
- warnings.warn('distutils.extensions.read_setup_file is deprecated. '
- 'It will be removed in the next Python release.')
- _sysconfig = __import__('sysconfig')
- from distutils2.sysconfig import (expand_makefile_vars,
- _variable_rx)
-
- from distutils2.text_file import TextFile
- from distutils2.util import split_quoted
-
- # First pass over the file to gather "VAR = VALUE" assignments.
- vars = _sysconfig._parse_makefile(filename)
-
- # Second pass to gobble up the real content: lines of the form
- # <module> ... [<sourcefile> ...] [<cpparg> ...] [<library> ...]
- file = TextFile(filename,
- strip_comments=1, skip_blanks=1, join_lines=1,
- lstrip_ws=1, rstrip_ws=1)
- extensions = []
-
- while 1:
- line = file.readline()
- if line is None: # eof
- break
- if _variable_rx.match(line): # VAR=VALUE, handled in first pass
- continue
-
- if line[0] == line[-1] == "*":
- file.warn("'%s' lines not handled yet" % line)
- continue
-
- with warnings.catch_warnings():
- warnings.simplefilter("ignore")
- line = expand_makefile_vars(line, vars)
-
- words = split_quoted(line)
-
- # NB. this parses a slightly different syntax than the old
- # makesetup script: here, there must be exactly one extension per
- # line, and it must be the first word of the line. I have no idea
- # why the old syntax supported multiple extensions per line, as
- # they all wind up being the same.
-
- module = words[0]
- ext = Extension(module, [])
- append_next_word = None
-
- for word in words[1:]:
- if append_next_word is not None:
- append_next_word.append(word)
- append_next_word = None
- continue
-
- suffix = os.path.splitext(word)[1]
- switch = word[0:2] ; value = word[2:]
-
- if suffix in (".c", ".cc", ".cpp", ".cxx", ".c++", ".m", ".mm"):
- # hmm, should we do something about C vs. C++ sources?
- # or leave it up to the CCompiler implementation to
- # worry about?
- ext.sources.append(word)
- elif switch == "-I":
- ext.include_dirs.append(value)
- elif switch == "-D":
- equals = value.find("=")
- if equals == -1: # bare "-DFOO" -- no value
- ext.define_macros.append((value, None))
- else: # "-DFOO=blah"
- ext.define_macros.append((value[0:equals],
- value[equals+2:]))
- elif switch == "-U":
- ext.undef_macros.append(value)
- elif switch == "-C": # only here 'cause makesetup has it!
- ext.extra_compile_args.append(word)
- elif switch == "-l":
- ext.libraries.append(value)
- elif switch == "-L":
- ext.library_dirs.append(value)
- elif switch == "-R":
- ext.runtime_library_dirs.append(value)
- elif word == "-rpath":
- append_next_word = ext.runtime_library_dirs
- elif word == "-Xlinker":
- append_next_word = ext.extra_link_args
- elif word == "-Xcompiler":
- append_next_word = ext.extra_compile_args
- elif switch == "-u":
- ext.extra_link_args.append(word)
- if not value:
- append_next_word = ext.extra_link_args
- elif suffix in (".a", ".so", ".sl", ".o", ".dylib"):
- # NB. a really faithful emulation of makesetup would
- # append a .o file to extra_objects only if it
- # had a slash in it; otherwise, it would s/.o/.c/
- # and append it to sources. Hmmmm.
- ext.extra_objects.append(word)
- else:
- file.warn("unrecognized argument '%s'" % word)
-
- extensions.append(ext)
-
- return extensions
diff --git a/src/distutils2/tests/__init__.py b/src/distutils2/tests/__init__.py
index 1b83d1f..61c9b98 100644
--- a/src/distutils2/tests/__init__.py
+++ b/src/distutils2/tests/__init__.py
@@ -24,7 +24,7 @@ def test_suite():
suite = unittest2.TestSuite()
for fn in os.listdir(here):
if fn.startswith("test") and fn.endswith(".py"):
- modname = "distutils.tests." + fn[:-3]
+ modname = "distutils2.tests." + fn[:-3]
__import__(modname)
module = sys.modules[modname]
suite.addTest(module.test_suite())
diff --git a/src/distutils2/tests/test_extension.py b/src/distutils2/tests/test_extension.py
index c2cfd07..bd83829 100755
--- a/src/distutils2/tests/test_extension.py
+++ b/src/distutils2/tests/test_extension.py
@@ -4,65 +4,12 @@ import os
import warnings
from test.test_support import check_warnings
-from distutils2.extension import read_setup_file, Extension
+from distutils2.extension import Extension
from distutils2.tests.support import capture_warnings
class ExtensionTestCase(unittest2.TestCase):
- @capture_warnings
- def test_read_setup_file(self):
- # trying to read a Setup file
- # (sample extracted from the PyGame project)
- setup = os.path.join(os.path.dirname(__file__), 'Setup.sample')
-
- exts = read_setup_file(setup)
- names = [ext.name for ext in exts]
- names.sort()
-
- # here are the extensions read_setup_file should have created
- # out of the file
- wanted = ['_arraysurfarray', '_camera', '_numericsndarray',
- '_numericsurfarray', 'base', 'bufferproxy', 'cdrom',
- 'color', 'constants', 'display', 'draw', 'event',
- 'fastevent', 'font', 'gfxdraw', 'image', 'imageext',
- 'joystick', 'key', 'mask', 'mixer', 'mixer_music',
- 'mouse', 'movie', 'overlay', 'pixelarray', 'pypm',
- 'rect', 'rwobject', 'scrap', 'surface', 'surflock',
- 'time', 'transform']
-
- self.assertEquals(names, wanted)
-
- def test_extension_init(self):
- # the first argument, which is the name, must be a string
- self.assertRaises(AssertionError, Extension, 1, [])
- ext = Extension('name', [])
- self.assertEquals(ext.name, 'name')
-
- # the second argument, which is the list of files, must
- # be a list of strings
- self.assertRaises(AssertionError, Extension, 'name', 'file')
- self.assertRaises(AssertionError, Extension, 'name', ['file', 1])
- ext = Extension('name', ['file1', 'file2'])
- self.assertEquals(ext.sources, ['file1', 'file2'])
-
- # others arguments have defaults
- for attr in ('include_dirs', 'define_macros', 'undef_macros',
- 'library_dirs', 'libraries', 'runtime_library_dirs',
- 'extra_objects', 'extra_compile_args', 'extra_link_args',
- 'export_symbols', 'swig_opts', 'depends'):
- self.assertEquals(getattr(ext, attr), [])
-
- self.assertEquals(ext.language, None)
- self.assertEquals(ext.optional, None)
-
- # if there are unknown keyword options, warn about them
- with check_warnings() as w:
- warnings.simplefilter('always')
- ext = Extension('name', ['file1', 'file2'], chic=True)
-
- self.assertEquals(len(w.warnings), 1)
- self.assertEquals(str(w.warnings[0].message),
- "Unknown Extension options: 'chic'")
+ pass
def test_suite():
return unittest2.makeSuite(ExtensionTestCase)