Skip to content

Commit

Permalink
when building, cd into tmpdir to shorten builddir name on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
mattip committed Oct 18, 2024
1 parent 3600539 commit da2b49f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/cffi/verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,20 @@ def _write_source(self, file=None):

def _compile_module(self):
# compile this C source
# Note: compilation will create artifacts in tmpdir + sourcefilename
# This can exceed the windows MAXPATH quite easily. To make it shorter,
# cd into tmpdir and make the sourcefilename relative to tmdir
tmpdir = os.path.dirname(self.sourcefilename)
outputfilename = ffiplatform.compile(tmpdir, self.get_extension())
olddir = os.getcwd()
os.chdir(tmpdir)
self.sourcefilename_orig = self.sourcefilename
try:
self.sourcefilename = os.path.relpath(self.sourcefilename)
output_rel_filename = ffiplatform.compile(tmpdir, self.get_extension())
outputfilename = os.path.join(tmpdir, output_rel_filename)
finally:
os.chdir(olddir)
self.sourcefilename = self.sourcefilename_orig
try:
same = ffiplatform.samefile(outputfilename, self.modulefilename)
except OSError:
Expand Down

0 comments on commit da2b49f

Please sign in to comment.