Skip to content
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

pyximport: cd into common dir to prevent too-long filenames for windows #4630

Merged
merged 2 commits into from Jul 17, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 20 additions & 6 deletions pyximport/_pyximport2.py
Expand Up @@ -185,12 +185,26 @@ def build_module(name, pyxfilename, pyxbuild_dir=None, inplace=False, language_l
build_in_temp = sargs.pop('build_in_temp',build_in_temp)

from . import pyxbuild
so_path = pyxbuild.pyx_to_dll(pyxfilename, extension_mod,
build_in_temp=build_in_temp,
pyxbuild_dir=pyxbuild_dir,
setup_args=sargs,
inplace=inplace,
reload_support=pyxargs.reload_support)
olddir = os.getcwd()
common = ''
if pyxbuild_dir:
# Windows concantenates 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:
os.chdir(common)
pyxfilename = os.path.relpath(pyxfilename)
pyxbuild_dir = os.path.relpath(pyxbuild_dir)
scoder marked this conversation as resolved.
Show resolved Hide resolved
try:
so_path = pyxbuild.pyx_to_dll(pyxfilename, extension_mod,
build_in_temp=build_in_temp,
pyxbuild_dir=pyxbuild_dir,
setup_args=sargs,
inplace=inplace,
reload_support=pyxargs.reload_support)
finally:
os.chdir(olddir)
so_path = os.path.join(common, so_path)
assert os.path.exists(so_path), "Cannot find: %s" % so_path

junkpath = os.path.join(os.path.dirname(so_path), name+"_*") #very dangerous with --inplace ? yes, indeed, trying to eat my files ;)
Expand Down
26 changes: 20 additions & 6 deletions pyximport/_pyximport3.py
Expand Up @@ -183,12 +183,26 @@ def build_module(name, pyxfilename, pyxbuild_dir=None, inplace=False, language_l
build_in_temp = sargs.pop('build_in_temp',build_in_temp)

from . import pyxbuild
so_path = pyxbuild.pyx_to_dll(pyxfilename, extension_mod,
build_in_temp=build_in_temp,
pyxbuild_dir=pyxbuild_dir,
setup_args=sargs,
inplace=inplace,
reload_support=pyxargs.reload_support)
olddir = os.getcwd()
common = ''
if pyxbuild_dir:
# Windows concantenates 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:
os.chdir(common)
pyxfilename = os.path.relpath(pyxfilename)
pyxbuild_dir = os.path.relpath(pyxbuild_dir)
scoder marked this conversation as resolved.
Show resolved Hide resolved
try:
so_path = pyxbuild.pyx_to_dll(pyxfilename, extension_mod,
build_in_temp=build_in_temp,
pyxbuild_dir=pyxbuild_dir,
setup_args=sargs,
inplace=inplace,
reload_support=pyxargs.reload_support)
finally:
os.chdir(olddir)
so_path = os.path.join(common, so_path)
assert os.path.exists(so_path), "Cannot find: %s" % so_path

junkpath = os.path.join(os.path.dirname(so_path), name+"_*") #very dangerous with --inplace ? yes, indeed, trying to eat my files ;)
Expand Down