Skip to content

Commit

Permalink
Only patch _pari.c on Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
culler committed Sep 13, 2024
1 parent e78066f commit 35cf785
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,17 +279,19 @@ def run(self):
_pari_c = os.path.join('cypari', '_pari.c')
cythonize([_pari_pyx],
compiler_directives={'language_level':2})
with open('_pari.c', 'w') as outfile:
with open(_pari_c) as infile:
for line in infile.readlines():
if line.find('pycore') >= 0:
outfile.write(
' #undef long\n%s'
' #define long long long\n' %line)
else:
outfile.write(line)
os.unlink(_pari_c)
os.rename('_pari.c', _pari_c)
if sys.platform == 'win32':
# patch _pari.c to deal with #define long long long
with open('_pari.c', 'w') as outfile:
with open(_pari_c) as infile:
for line in infile.readlines():
if line.find('pycore') >= 0:
outfile.write(
' #undef long\n%s'
' #define long long long\n' %line)
else:
outfile.write(line)
os.unlink(_pari_c)
os.rename('_pari.c', _pari_c)
build_ext.run(self)

class CyPariSourceDist(sdist):
Expand Down

0 comments on commit 35cf785

Please sign in to comment.