[issue7833] bdist_wininst installers fail to load extensions built with Issue4120 patch

2012-11-21 Thread Almar Klein

Almar Klein added the comment:

Just checking in to point out a possible problem with the code that strips the 
MSVCR dependency from the embedded manifest. The used regexpr is too greedy: 
the first bit can trigger on an earlier assemblyIdentity tag, so that after 
the removal the manifest is no longer valid XML. 

The key problem is that the assemblyIdentity and the name attribute are 
allowed to be on a separate lines. To fix this I removed the re.DOTALL flag and 
replaced the second occurrence of .*? to also allow newlines: 

  pattern = re.compile(
- rassemblyIdentity.*?name=(|')Microsoft\.\
- rVC\d{2}\.CRT(|').*?(/|/assemblyIdentity),
- re.DOTALL)
+ rassemblyIdentity.*?name=(|')Microsoft\.\
+ rVC\d{2}\.CRT(|')(.|\r|\r)*?(/|/assemblyIdentity))


It is well possible that the problem does not causes any problems for the 
intended usage of the code. I'm using the code to strip other DLL's and ran 
into this issue (with tk85.dll to be precise).

- Almar

--
nosy: +almar

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7833
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13765] Distutils does not put quotes around paths that contain spaces when compiling with MSVC

2012-01-13 Thread Almar Klein

Almar Klein almar.kl...@gmail.com added the comment:

Ok, I went to prepare a minimal example that does not use Cython nor Numpy. And 
then the problem was gone. Even more so, my fix would cause a problem, because 
somewhere quotes are placed around the entire command:

...link.exe /DLL /LIBPATH:C:\Program Files (x86)\python32\libs etc.

This somewhere is in spawn(), which calls nt_quote_args().

So I went on to search for the cause in Cython, and after that in Numpy. I have 
no traced it to Numpy, because it does NOT use the nt_quote_args() function of 
distutils.

So I think we can close the issue. I will open an issue at numpy.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13765
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13765] Distutils does not put quotes around paths that contain spaces when compiling with MSVC

2012-01-13 Thread Almar Klein

Almar Klein almar.kl...@gmail.com added the comment:

This issue is posted at http://projects.scipy.org/numpy/ticket/2018

--
resolution: invalid - 
status: closed - open

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13765
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13765] Distutils does not put quotes around paths that contain spaces when compiling with MSVC

2012-01-11 Thread Almar Klein

New submission from Almar Klein almar.kl...@gmail.com:

I found an easy to solve bug in distutils, which is causing problems with 
compiling Cython code on Windows. I have reproduced this on Python 2.6 and 
Python 3.2 (32 bit).

The problem occurs with the native msvc compiler. Using gcc (MinGW) works fine.

The problem is that the command to link the libraries does not put double 
quotes around paths that have spaces in them. Unfortunately, the path where I 
have Python installed has spaces in it (c:/program files/python26). Small 
example of part of a link command: 

/LIBPATH:C:\Program Files (x86)\python32\libs. 

Note that the include_dirs DO have double quotes around them.

The problem is easily solved (I confirmed this) by a small change in 
msvc9compiler.py and msvccompiler.py (see also the patch):

def library_dir_option(self, dir):  # OLD VERSION
 return /LIBPATH: + dir

def library_dir_option(self, dir): # FIXED VERSION
if ' ' in dir and not dir.startswith(''):
dir = '%s' % dir
return /LIBPATH: + dir

I tried to see if it would be nicer to apply a change elsewhere, e.g. where 
library_dir_option() is called. However, it is called nowhere from within the 
distutils package. In my case I suspect numpy.distutils or a part of Cython 
calls it. Anyway, in my opinion you should be able to pass this function a 
dirname that has a space in it, and get the right (partial) command. For the 
record, this change is quite safe because it checks whether quotes are already 
present. 


= Below follows a minimal Cython example and traceback =

= test_.pyx
def foo():
print('hello')


= setup.py
import os, sys
from Cython.Distutils import build_ext
from distutils.core import setup
from distutils.extension import Extension
from numpy.distutils.misc_util import get_numpy_include_dirs

# Ugly hack so I can run setup.py in my IDE
sys.argv = ['setup.py', 'build_ext', '--inplace']

# Init include dirs
include_dirs = ['.']
include_dirs.extend(get_numpy_include_dirs())

# Creat Extensions
ext_modules = [
 Extension('test_', ['test_.pyx'],
include_dirs=include_dirs,
),
 ]

# Compile
setup(
cmdclass = {'build_ext': build_ext},
ext_modules = ext_modules,
)

print('Successfully compiled cython file: test_')


= output when running setup.py
running build_ext
No module named msvccompiler in numpy.distutils; trying from distutils
cythoning test_.pyx to test_.c
building 'test_' extension
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox 
/MD /W3 /GS- /DNDEBUG -I. -IC:\Program Files 
(x86)\python32\lib\site-packages\numpy\core\include -IC:\Program Files 
(x86)\python32\include -IC:\Program Files (x86)\python32\PC /Tctest_.c 
/Fobuild\temp.win32-3.2\Release\test_.obj
Found executable C:\Program Files (x86)\Microsoft Visual Studio 
9.0\VC\BIN\cl.exe
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\link.exe /DLL /nologo 
/INCREMENTAL:NO /LIBPATH:C:\Program Files (x86)\python32\libs 
/LIBPATH:C:\Program Files (x86)\python32\PCbuild /EXPORT:PyInit_test_ 
build\temp.win32-3.2\Release\test_.obj 
/OUT:C:\almar\projects\py\cmu1394\test_.pyd 
/IMPLIB:build\temp.win32-3.2\Release\test_.lib 
/MANIFESTFILE:build\temp.win32-3.2\Release\test_.pyd.manifest
Found executable C:\Program Files (x86)\Microsoft Visual Studio 
9.0\VC\BIN\link.exe
LINK : fatal error LNK1181: cannot open input file 'Files.obj'

--
assignee: tarek
components: Distutils
files: distutils_spaces_in_libdir.patch
keywords: patch
messages: 151054
nosy: almar, eric.araujo, mhammond, tarek
priority: normal
severity: normal
status: open
title: Distutils does not put quotes around paths that contain spaces when 
compiling with MSVC
type: behavior
versions: Python 2.6, Python 3.2
Added file: http://bugs.python.org/file24201/distutils_spaces_in_libdir.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13765
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com