[Numpy-discussion] Is there a known problem compiling numpy with VC7? Success

Tim Hochberg tim.hochberg at cox.net
Thu Feb 9 17:07:21 EST 2006


Tim Hochberg wrote:

> Pearu Peterson wrote:
>
>>
>>
>> On Thu, 9 Feb 2006, Tim Hochberg wrote:
>>
>>> I had this fantasy that default_lib_dirs would get picked up 
>>> automagically; however that does not happen. I still ended up putting:
>>>
>>>           from  numpy.distutils import system_info
>>>           library_dirs = system_info.default_lib_dirs
>>>           result = 
>>> config_cmd.try_run(tc,include_dirs=[python_include], 
>>> library_dirs=library_dirs)
>>>
>>> into setup.py. Is that acceptable? It's not very elegant.
>>
>>
>>
>> No, don't use system_info.default_lib_dirs.
>>
>> Use distutils.sysconfig.get_python_lib() to get the directory that 
>> contains Python library.
>
>
> That's the wrong library. Get_python_lib gives you the location of the 
> python standard library, not the location of python24.lib. The former 
> being python24/Lib (or python24/Lib/site-packages depending what 
> options you feed get_python_lib) 'and the latter being python24/libs 
> on my box.

To follow up on this a little bit, I investigated how distutils itself 
finds python24.lib. It turns out that it is in build_ext.py, near line 
168. The relevant code is:

        # also Python's library directory must be appended to library_dirs
        if os.name == 'nt':
            self.library_dirs.append(os.path.join(sys.exec_prefix, 'libs'))

Unfortunately, there's no obvious, clean way to extract the library 
information from there. You can grab it using the following magic formula:

            from distutils.core import Distribution
            from distutils.command import build_ext
            be = build_ext.build_ext(Distribution())
            be.finalize_options()
            librarys_dirs = be.library_dirs

However, that seems worse than what we're doing now. I haven't actually 
tried this in the code either -- for all I know instantiating an extra 
Distribution may have some horrible side effect that I don't know about. 
If someone can come up with a cleaner way to get to this info, that'd be 
great, otherwise I'd say we might as well just keep things as they are 
for the time being.

Regards,

-tim






More information about the NumPy-Discussion mailing list