Skip to content

Commit

Permalink
Add pyproject.toml, update installation instructions for modern Pytho…
Browse files Browse the repository at this point in the history
…n packaging, fix docbuild, update CI scripts, add Cython 3 support (#139)

* Add pyproject.toml

* drop tests with python-3.6 and pari-2.9.5

* force Cython < 3

* add the downstream (Sage) patch for Cython 3+

* Revert "force Cython < 3"

This reverts commit c473052.

* install setuptools for the CI

* trying a separate pip install

* upgrade to version 68

* does "pip install" have any effect?

* trying with -U

* try in a venv

* try -I

* trying no-build-isolation

* seems that wheel is needed

* fix docbuild

* Get rid of 'make build', direct use of 'setup.py'

* Makefile: Don't use --no-index

* Remove uses of practices predating PEP 517/518

* README.rst: Link to Sage reference manual for the PARI system package list

* Makefile (install): Remove --no-build-isolation

* Makefile (dist): Use pypa/build instead of using setup.py directly

* .github/workflows/main.yml: Get rid of venv

* .github/workflows/main.yml: Get rid of ccache

---------

Co-authored-by: Vincent Delecroix <[email protected]>
Co-authored-by: Dima Pasechnik <[email protected]>
  • Loading branch information
3 people authored Oct 6, 2023
1 parent 3660f17 commit 7386a9f
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 43 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ['3.6', '3.10', '3.11']
pari-version: ['pari-2.9.5', 'pari-2.11.4', 'pari-2.13.0', 'pari-2.15.1']
python-version: ['3.10', '3.11']
pari-version: ['pari-2.11.4', 'pari-2.13.0', 'pari-2.15.4']
env:
LC_ALL: C
PARI_VERSION: ${{ matrix.pari-version }}
Expand All @@ -28,13 +28,10 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install pari
run: |
ccache -M 256M && ccache -s
export PATH="/usr/lib/ccache:$PATH"
bash -x .install-pari.sh
- name: Local build
run: |
pip install sphinx cython cysignals
make build
make install
make check
pip install sphinx
(cd docs && make html)
10 changes: 4 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ PYTHON = python
PIP = $(PYTHON) -m pip -v


build:
$(PYTHON) setup.py build

install:
$(PIP) install --no-index --upgrade .
$(PIP) install --upgrade .

check:
ulimit -s 8192; $(PYTHON) -u tests/rundoctest.py
Expand All @@ -19,7 +16,8 @@ check:

dist:
chmod go+rX-w -R .
umask 0022 && $(PYTHON) setup.py sdist --formats=gztar
$(PIP) install build
umask 0022 && $(PYTHON) -m build --sdist


.PHONY: build install check dist
.PHONY: install check dist
34 changes: 16 additions & 18 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,23 @@ A Python interface to the number theory library `PARI/GP <http://pari.math.u-bor
Installation
------------

GNU/Linux
^^^^^^^^^
From a distribution package (GNU/Linux, conda-forge)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

A package `python-cypari2` or `python2-cypari2` or `python3-cypari2` might be
available in your package manager.
A package might be available in your package manager, see
https://repology.org/project/python:cypari2/versions

Using pip
^^^^^^^^^
From source with pip
^^^^^^^^^^^^^^^^^^^^

Requirements:

- PARI/GP >= 2.9.4 (header files and library)
- PARI/GP >= 2.9.4 (header files and library); see
https://doc.sagemath.org/html/en/reference/spkg/pari#spkg-pari
for availability in distributions (GNU/Linux, conda-forge, Homebrew, FreeBSD),
or install from source.
- Python >= 3.6
- pip
- `cysignals <https://pypi.python.org/pypi/cysignals/>`_ >= 1.7
- Cython >= 0.29

Install cypari2 via the Python Package Index (PyPI) via

Expand All @@ -34,10 +35,13 @@ Install cypari2 via the Python Package Index (PyPI) via
$ pip install cypari2 [--user]

(the optional option *--user* allows to install cypari2 for a single user
and avoids using pip with administrator rights). Depending on your operating
system the pip command might also be called pip3.
and avoids using pip with administrator rights).

If you want to try the development version use
`pip` builds the package using build isolation. All Python build dependencies
of the package, declared in pyproject.toml, are automatically installed in
a temporary virtual environment.

If you want to try the development version, use

::

Expand All @@ -51,12 +55,6 @@ already installed, try to reinstall cysignals and cypari2
$ pip install cysignals --upgrade [--user]
$ pip install cypari2 --upgrade [--user]

Other
^^^^^

Any other way to install cypari2 is not supported. In particular, ``python
setup.py install`` will produce an error.

Usage
-----

Expand Down
2 changes: 2 additions & 0 deletions _custom_build_meta.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# See https://setuptools.pypa.io/en/latest/build_meta.html#dynamic-build-dependencies-and-other-build-meta-tweaks
from setuptools.build_meta import *
2 changes: 1 addition & 1 deletion cypari2/gen.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ cdef class Gen(Gen_base):
>>> pari = Pari()
>>> L = pari("vector(10,i,i^2)")
>>> L.__iter__()
<generator object at ...>
<...generator object at ...>
>>> [x for x in L]
[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
>>> list(L)
Expand Down
23 changes: 12 additions & 11 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
master_doc = 'index'

# General information about the project.
project = u'CyPari2'
copyright = u'2017, Many people'
author = u'Many people'
project = 'CyPari2'
copyright = '2017, Many people'
author = 'Many people'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand All @@ -68,7 +68,7 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
#language = None

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand Down Expand Up @@ -160,13 +160,14 @@

# Links to external resources (copied from Sage)
extlinks = {
'trac': ('https://trac.sagemath.org/%s', 'Sage ticket #'),
'wikipedia': ('https://en.wikipedia.org/wiki/%s', 'Wikipedia article '),
'arxiv': ('http://arxiv.org/abs/%s', 'Arxiv '),
'oeis': ('https://oeis.org/%s', 'OEIS sequence '),
'doi': ('https://dx.doi.org/%s', 'doi:'),
'pari': ('http://pari.math.u-bordeaux.fr/dochtml/help/%s', 'pari:'),
'mathscinet': ('http://www.ams.org/mathscinet-getitem?mr=%s', 'MathSciNet ')
'trac': ('https://github.com/sagemath/sage/issues/%s', 'github issue #%s'), # support :trac: for backward compatibility
'issue': ('https://github.com/sagemath/sage/issues/%s', 'github issue #%s'),
'wikipedia': ('https://en.wikipedia.org/wiki/%s', 'Wikipedia article %s'),
'arxiv': ('https://arxiv.org/abs/%s', 'arXiv %s'),
'oeis': ('https://oeis.org/%s', 'OEIS sequence %s'),
'doi': ('https://dx.doi.org/%s', 'doi:%s'),
'pari': ('https://pari.math.u-bordeaux.fr/dochtml/help/%s', 'pari:%s'),
'mathscinet': ('https://www.ams.org/mathscinet-getitem?mr=%s', 'MathSciNet %s')
}


Expand Down
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",
"Cython>=0.29",
"cysignals>=1.7"]
# We need access to the autogen package at build time.
# Hence we declare a custom build backend.
build-backend = "_custom_build_meta" # just re-exports setuptools.build_meta definitions
backend-path = ["."]
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ def finalize_options(self):
"binding": True,
"cdivision": True,
"language_level": 2,
"legacy_implicit_noexcept": True,
"c_api_binop_methods": True,
}

_build_ext.finalize_options(self)
Expand Down Expand Up @@ -66,7 +68,6 @@ def run(self):
setup(
name='cypari2',
version=VERSION,
setup_requires=['Cython>=0.29'],
install_requires=['cysignals>=1.7'],
description="A Python interface to the number theory library PARI/GP",
long_description=README,
Expand Down

0 comments on commit 7386a9f

Please sign in to comment.