Skip to content

Commit

Permalink
Modernization of CI system + Support of Python 3.13
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanDunfield committed Sep 13, 2024
1 parent f5e2512 commit 7c9966c
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 90 deletions.
37 changes: 0 additions & 37 deletions .github/workflows/linux.yml

This file was deleted.

36 changes: 0 additions & 36 deletions .github/workflows/macos.yml

This file was deleted.

23 changes: 23 additions & 0 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Wheels

on: [push, pull_request]

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-12, macos-14]

steps:
- uses: actions/checkout@v4

- name: Build wheels
uses: pypa/[email protected]

- uses: actions/upload-artifact@v4
with:
name: cypari_${{ matrix.os }}_wheels
path: ./wheelhouse/*.whl
12 changes: 3 additions & 9 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
- uses: actions/setup-python@v4
name: Install a Python to use for building
with:
python-version: '3.12'
Expand All @@ -39,21 +39,15 @@ jobs:
- name: Install cibuildwheel
run: |
python3 -m pip install cibuildwheel
python -m pip install cibuildwheel==2.20.0
- name: Build gmp and pari
run: |
bash build_pari.sh pari64 gmp64
- name: Build many wheels
run: |
python3 -m cibuildwheel --output-dir wheelhouse
env:
CIBW_ARCHS: AMD64
CIBW_BUILD: cp38* cp39* cp310* cp311* cp312*
CIBW_BEFORE_BUILD: |
pip install Cython>=3.0.0
CIBW_TEST_COMMAND: python -m cypari.test
python -m cibuildwheel --output-dir wheelhouse
- uses: actions/upload-artifact@v4
name: Save the wheels as artifacts
Expand Down
14 changes: 12 additions & 2 deletions cypari/_pari.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ from cpython.object cimport Py_EQ, Py_NE, Py_LE, Py_GE, Py_LT, Py_GT

from .paridecl cimport *
from .paripriv cimport *

# cdef extern from *:
# """
# /* Undo the damage caused by PARI's ridiculous
# * #define long long long
# */
# #if defined long
# #undef long
# #endif
# """
# pass

cimport libc.stdlib
from libc.stdio cimport *

Expand Down Expand Up @@ -116,5 +128,3 @@ include "convert.pyx"
include "handle_error.pyx"
include "closure.pyx"
include "gen.pyx"


2 changes: 0 additions & 2 deletions cypari/cypari.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,3 @@
#define set_gcoeff(x, i, j, z) (gcoeff((x), (i), (j)) = (z))
#define set_uel(x, n, z) (uel((x), (n)) = (z))

/* Undo the damage caused by Pari's ridiculous hack for 64 bit windows.*/
#undef long
2 changes: 1 addition & 1 deletion cypari/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ class Version(namedtuple('Version', ['major', 'minor', 'micro', 'tag'])):
def __str__(self):
return '%s.%s.%s%s'%self

version_info = Version(2, 5, 4, '')
version_info = Version(2, 5, 5, '')
__version__ = str(version_info)

8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[build-system]
requires = ["setuptools", "wheel", "cython"]

[tool.cibuildwheel]
build = "cp39* cp310* cp311* cp312* cp313*"
archs = "auto64"
test-command = "python -m cypari.test"

21 changes: 18 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
r'C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22000.0\um\x64\Uuid.lib',
r'C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22000.0\um\x64\kernel32.lib',
r'C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22000.0\ucrt\x64\ucrt.lib',
r'C:\msys64\ucrt64\lib\gcc\x86_64-w64-mingw32\13.2.0\libgcc.a'
r'C:\msys64\ucrt64\lib\gcc\x86_64-w64-mingw32\14.2.0\libgcc.a'
]
else:
ext_compiler = ''
Expand Down Expand Up @@ -275,8 +275,23 @@ def run(self):
# if not os.path.exists(os.path.join('cypari', '_pari.c')):
# sys.exit(no_cython_message)
from Cython.Build import cythonize
cythonize([os.path.join('cypari', '_pari.pyx')],
compiler_directives={'language_level':2})
_pari_pyx = os.path.join('cypari', '_pari.pyx')
_pari_c = os.path.join('cypari', '_pari.c')
cythonize([_pari_pyx],
compiler_directives={'language_level':2})
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 7c9966c

Please sign in to comment.