New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Distutils fails to build extension in path with spaces #61111
Comments
I noticed this issue, while trying to compile Cython extension, when source file is in path with spaces. Extension wouldn't compile because LIBDIR is passed to MinGW g++ (though not to gcc) or MSVC compilers unquoted. I tracked the problem to "distutils/build_ext.py" in get_ext_fullpath() function. I patched it, this way: ======================================== --- build_ext.bak
+++ build_ext.py
@@ -647,6 +647,11 @@
package = '.'.join(modpath[0:-1])
build_py = self.get_finalized_command('build_py')
package_dir = os.path.abspath(build_py.get_package_dir(package))
+ try:
+ from win32api import GetShortPathName
+ package_dir = GetShortPathName(package_dir)
+ except:
+ pass
# returning
# package_dir/filename
return os.path.join(package_dir, filename) ======================================== which is just one way to do it. |
Can you fix the bare except? |
======================================== |
get_ext_fullpath() has no relations to this bug. The bug is probably in spawn() functions, perhaps in _nt_quote_args() or something like. It looks as Windows specific bug (Posix passes command arguments as a list, not joining it into string). |
klo.uo: can you kindly provide a working (or, rather, failing) example? A trivial "hello-world" kind of package could do, along with a report what path you unpacked it in, and what error you get. Your patch is not applicable to Python, since it requires the win32 extensions, which we cannot assume to be present. |
I think this is a duplicate report; could you please search for an existing open report for the same bug? |
As mentioned in opening thread, this doesn't happen with Cython's I noticed this issue while using Numpy with Cython. Here is simple example: C:\Documents and Settings\klo\My Documents\code\python\misc\test.pyx: def sum(x):
cdef numpy.ndarray[int, ndim=1] arr = x
cdef int i, s = 0
for i in range(arr.shape[0]):
s += arr[i]
return s ======================================== C:\Documents and Settings\klo\My Documents\code\python\misc\setup.py: from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
from numpy.distutils.misc_util import get_numpy_include_dirs setup( command line: MinGW result: Similar result if I use MSVC compiler: MSVC result: So issue is with unquoted path for output file, and not for LIBDIR as I wrote
Yes, I provided patch that worked for me temporarily, as I'm not |
I found two similar issues:
with patches for unix compiler and cygwin compiler
with some patch for MSVC Problem seems to be deeper than provided patches, as evident also from my report |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: