diff --git a/pyximport/pyximport.py b/pyximport/pyximport.py index 629325933ec..96a727961d9 100644 --- a/pyximport/pyximport.py +++ b/pyximport/pyximport.py @@ -185,13 +185,13 @@ def build_module(name, pyxfilename, pyxbuild_dir=None, inplace=False, language_l from . import pyxbuild olddir = os.getcwd() common = '' - if pyxbuild_dir: + if pyxbuild_dir and sys.platform == 'win32': # Windows concatenates the pyxbuild_dir to the pyxfilename when # compiling, and then complains that the filename is too long common = os.path.commonprefix([pyxbuild_dir, pyxfilename]) if len(common) > 30: - pyxfilename = os.path.relpath(pyxfilename) - pyxbuild_dir = os.path.relpath(pyxbuild_dir) + pyxfilename = os.path.relpath(pyxfilename, common) + pyxbuild_dir = os.path.relpath(pyxbuild_dir, common) os.chdir(common) try: so_path = pyxbuild.pyx_to_dll(pyxfilename, extension_mod,