numscons and Python 2.7 problems
Dear NumPy developers, I was trying to build numpy 2.0.dev and scipy 0.9.dev using numscons 0.12.dev and Python 2.7b2 (32 bit) on Windows 7 64 bit and ran into two problems. First, Python 2.7's UserDict is now a new-style class (http://docs.python.org/dev/whatsnew/2.7.html). Apparently scons 1.2, which is part of numscons, is not compatible with this change and an AttributeError is thrown: AttributeError: NumpyEnvironment instance has no attribute 'SubstInFile': File "D:\numpy-trunk\numpy\core\SConstruct", line 2: GetInitEnvironment(ARGUMENTS).DistutilsSConscript('SConscript') File "C:\Python27\lib\site-packages\numscons\core\numpyenv.py", line 135: build_dir = '$build_dir', src_dir = '$src_dir') File "C:\Python27\lib\site-packages\numscons\scons-local\scons-local-1.2.0\SCons\Script\SConscript.py", line 553: return apply(_SConscript, [self.fs,] + files, subst_kw) File "C:\Python27\lib\site-packages\numscons\scons-local\scons-local-1.2.0\SCons\Script\SConscript.py", line 262: exec _file_ in call_stack[-1].globals File "D:\numpy-trunk\build\scons\numpy\core\SConscript", line 353: target = env.SubstInFile(pjoin(include_dir, '_numpyconfig.h'), Turns out that the env['BUILDERS'] dictionary is empty after the config.Finish() call in SConscript. A workaround is to copy the UserDict.py file from Python27\Lib to numscons\scons-local\scons-local-1.2.0\SCons and change UserDict back to an old-style class: @@ -1,6 +1,6 @@ """A more or less complete user-defined wrapper around dictionary objects.""" -class UserDict(object): +class UserDict: def __init__(self, dict=None, **kwargs): self.data = {} if dict is not None: @@ -80,10 +80,7 @@ def __iter__(self): return iter(self.data) -import _abcoll -_abcoll.MutableMapping.register(IterableUserDict) - class DictMixin: # Mixin defining all dictionary methods for classes that already have # a minimum dictionary interface including getitem, setitem, delitem, Second, when Python 2.7 is run on a 64 bit host, sys.platform.machine() is 'AMD64' even if Python is 32 bit (http://bugs.python.org/issue7860). Hence numscons always uses the win64 configuration on Python 2.7. This can be fixed by using "if '64 bit' in sys.version" or "platform.architecture()[0] == '64bit'" instead of "platform.machine() == 'AMD64'": diff --git a/numscons/checkers/config.py b/numscons/checkers/config.py index 4ca1079..198ccdb 100644 --- a/numscons/checkers/config.py +++ b/numscons/checkers/config.py @@ -18,7 +18,7 @@ def _get_win32_config_files(): import platform files = [pjoin(_CONFDIR, 'win32', 'perflib.cfg')] - if platform.machine() == 'AMD64': + if platform.architecture()[0] == '64bit': files.append(pjoin(_CONFDIR, 'win64', 'perflib.cfg')) return files diff --git a/numscons/core/compiler_config.py b/numscons/core/compiler_config.py index d6a79d9..606963e 100644 --- a/numscons/core/compiler_config.py +++ b/numscons/core/compiler_config.py @@ -29,7 +29,7 @@ def _get_win32_config_files(filename): import platform files = [pjoin(_CONFDIR, 'win32', filename)] - if platform.machine() == 'AMD64': + if platform.architecture()[0] == '64bit': files.append(pjoin(_CONFDIR, 'win64', filename)) return files diff --git a/numscons/core/misc.py b/numscons/core/misc.py index a546122..42836b9 100644 --- a/numscons/core/misc.py +++ b/numscons/core/misc.py @@ -59,7 +59,7 @@ def built_with_ifort(env): def is_python_win64(): # XXX: import it here because it takes some time import platform - return sys.platform == "win32" and platform.machine() == "AMD64" + return sys.platform == "win32" and platform.architecture()[0] == '64bit' def get_pythonlib_name(debug = 0): """Return the name of python library (necessary to link on NT with -- Christoph
On Mon, Jun 7, 2010 at 2:07 PM, Christoph Gohlke <cgohlke@uci.edu> wrote:
Dear NumPy developers,
I was trying to build numpy 2.0.dev and scipy 0.9.dev using numscons 0.12.dev and Python 2.7b2 (32 bit) on Windows 7 64 bit and ran into two problems.
First, Python 2.7's UserDict is now a new-style class (http://docs.python.org/dev/whatsnew/2.7.html). Apparently scons 1.2, which is part of numscons, is not compatible with this change and an AttributeError is thrown:
I wonder sometimes if it is worth supporting python versions 2.x > 2.6. The developers seem intent on breaking the API as much as possible and support could become a burden. At least 3.x has a policy of keeping the API intact. I'm only half joking here,. <snip> Chuck
On Tue, Jun 8, 2010 at 4:58 AM, Charles R Harris <charlesr.harris@gmail.com>wrote:
On Mon, Jun 7, 2010 at 2:07 PM, Christoph Gohlke <cgohlke@uci.edu> wrote:
Dear NumPy developers,
I was trying to build numpy 2.0.dev and scipy 0.9.dev using numscons 0.12.dev and Python 2.7b2 (32 bit) on Windows 7 64 bit and ran into two problems.
First, Python 2.7's UserDict is now a new-style class (http://docs.python.org/dev/whatsnew/2.7.html). Apparently scons 1.2, which is part of numscons, is not compatible with this change and an AttributeError is thrown:
I wonder sometimes if it is worth supporting python versions 2.x > 2.6. The developers seem intent on breaking the API as much as possible and support could become a burden. At least 3.x has a policy of keeping the API intact. I'm only half joking here,.
Is it really that much worse than for earlier versions? The support burden
is probably more because of having too many Python versions at the same time. It's now 2.4-2.6, soon it may be 2.4-2.7 + 3.1-3.2. Cheers, Ralf
On 06/08/2010 11:37 AM, Ralf Gommers wrote:
Is it really that much worse than for earlier versions? The support burden is probably more because of having too many Python versions at the same time. It's now 2.4-2.6, soon it may be 2.4-2.7 + 3.1-3.2.
I don't think scons issues should affect our policy here - it is not officially part of numpy. I would not be surprised if the issue were solved already, and if it isn't, it should be easy to fix. 2.7 is also likely to be the long-term supported version from the 2.x branch, so supporting it is important IMHO. David
On 6/7/2010 1:58 PM, Charles R Harris wrote:
On Mon, Jun 7, 2010 at 2:07 PM, Christoph Gohlke <cgohlke@uci.edu <mailto:cgohlke@uci.edu>> wrote:
Dear NumPy developers,
I was trying to build numpy 2.0.dev and scipy 0.9.dev using numscons 0.12.dev and Python 2.7b2 (32 bit) on Windows 7 64 bit and ran into two problems.
First, Python 2.7's UserDict is now a new-style class (http://docs.python.org/dev/whatsnew/2.7.html). Apparently scons 1.2, which is part of numscons, is not compatible with this change and an AttributeError is thrown:
I wonder sometimes if it is worth supporting python versions 2.x > 2.6. The developers seem intent on breaking the API as much as possible and support could become a burden. At least 3.x has a policy of keeping the API intact. I'm only half joking here,.
Good news: Python's 2.7 UserDict has been reverted to an old-style class after release candidate 2. See discussion at <http://mail.python.org/pipermail/python-dev/2010-June/thread.html#100885> Christoph
On Fri, Jun 25, 2010 at 12:05 PM, Christoph Gohlke <cgohlke@uci.edu> wrote:>
On 6/7/2010 1:58 PM, Charles R Harris wrote:
On Mon, Jun 7, 2010 at 2:07 PM, Christoph Gohlke <cgohlke@uci.edu <mailto:cgohlke@uci.edu>> wrote:
Dear NumPy developers,
I was trying to build numpy 2.0.dev and scipy 0.9.dev using numscons 0.12.dev and Python 2.7b2 (32 bit) on Windows 7 64 bit and ran into two problems.
First, Python 2.7's UserDict is now a new-style class (http://docs.python.org/dev/whatsnew/2.7.html). Apparently scons 1.2, which is part of numscons, is not compatible with this change and an AttributeError is thrown:
I wonder sometimes if it is worth supporting python versions 2.x > 2.6. The developers seem intent on breaking the API as much as possible and support could become a burden. At least 3.x has a policy of keeping the API intact. I'm only half joking here,.
Good news: Python's 2.7 UserDict has been reverted to an old-style class after release candidate 2. See discussion at <http://mail.python.org/pipermail/python-dev/2010-June/thread.html#100885>
I just successfully built from source numpy on todays 2.7 snapshot with the following command. LDFLAGS="-arch x86_64" FFLAGS="-arch x86_64" py27 setupscons.py scons Vincent
Christoph _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
participants (5)
-
Charles R Harris
-
Christoph Gohlke
-
David
-
Ralf Gommers
-
Vincent Davis