Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ jobs:
needs: [dist]

env:
# Ubuntu packages to install so that the project's "setup.py sdist" can succeed
# Ubuntu packages to install so that building the sdist can succeed
DIST_PREREQ: libpari-dev pari-doc libbz2-dev bzip2
# Name of this project in the Sage distribution
SPKG: cypari
Expand Down
6 changes: 3 additions & 3 deletions .install-pari.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ if [ "$URLDIR" = "" ]; then
URLDIR=OLD/${PURE_VERSION%.*}
fi

PARI_URL="http://pari.math.u-bordeaux.fr/pub/pari/$URLDIR"
PARI_URL1="http://pari.math.u-bordeaux.fr/pub/pari/unix"
PARI_URL2="http://pari.math.u-bordeaux.fr/pub/pari/unstable"
PARI_URL="https://pari.math.u-bordeaux.fr/pub/pari/$URLDIR"
PARI_URL1="https://pari.math.u-bordeaux.fr/pub/pari/unix"
PARI_URL2="https://pari.math.u-bordeaux.fr/pub/pari/unstable"

# Download PARI sources
wget --no-verbose "$PARI_URL/$PARI_VERSION.tar.gz" -O pari.tgz || wget --no-verbose "$PARI_URL1/pari-$PARI_VERSION.tar.gz" -O pari.tgz || wget --no-verbose "$PARI_URL2/pari-$PARI_VERSION.tar.gz" -O pari.tgz
Expand Down
9 changes: 0 additions & 9 deletions MANIFEST.in

This file was deleted.

28 changes: 18 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CyPari 2
:target: https://cypari2.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status

A Python interface to the number theory library `PARI/GP <http://pari.math.u-bordeaux.fr/>`_.
A Python interface to the number theory library `PARI/GP <https://pari.math.u-bordeaux.fr/>`_.

Installation
------------
Expand Down Expand Up @@ -42,14 +42,10 @@ From source with pip

Requirements:

- PARI/GP >= 2.9.4 (header files and library); see
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.9
- pip
- `cysignals <https://pypi.python.org/pypi/cysignals/>`_ >= 1.11.3
- Cython >= 3.0

Install cypari2 via the Python Package Index (PyPI) via

Expand Down Expand Up @@ -136,13 +132,25 @@ same computations be done via
>>> pari.centerlift(pari.lift(fq))
[x - t, 1; x + (t^2 + t - 1), 1; x + (-t^2 - 1), 1]

The complete documentation of cypari2 is available at http://cypari2.readthedocs.io and
the PARI/GP documentation at http://pari.math.u-bordeaux.fr/doc.html
The complete documentation of cypari2 is available at https://cypari2.readthedocs.io and
the PARI/GP documentation at https://pari.math.u-bordeaux.fr/doc.html

Contributing
------------
Contributing & Development
--------------------------

CyPari 2 is maintained by the SageMath community.

Open issues or submit pull requests at https://github.com/sagemath/cypari2
and join https://groups.google.com/group/sage-devel to discuss.

To get started with development, you can set up an environment using Conda
as follows:

::
$ conda create -n cypari2-dev python cython pari=*=*_pthread ninja meson-python cysignals c-compiler
$ conda activate cypari2-dev

Afterwards, you can build and install the package in editable mode:

::
$ pip install -e . --no-build-isolation
2 changes: 0 additions & 2 deletions _custom_build_meta.py

This file was deleted.

2 changes: 1 addition & 1 deletion autogen/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# http://www.gnu.org/licenses/
# https://www.gnu.org/licenses/
#*****************************************************************************

from __future__ import unicode_literals
Expand Down
8 changes: 5 additions & 3 deletions autogen/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# http://www.gnu.org/licenses/
# https://www.gnu.org/licenses/
#*****************************************************************************

from __future__ import absolute_import, unicode_literals

import os, re, io
import io
import os
import re

from .args import pari_arg_types
from .ret import pari_ret_types
from .paths import pari_share
from .ret import pari_ret_types

paren_re = re.compile(r"[(](.*)[)]")
argname_re = re.compile(r"[ {]*&?([A-Za-z_][A-Za-z0-9_]*)")
Expand Down
6 changes: 2 additions & 4 deletions autogen/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# http://www.gnu.org/licenses/
# https://www.gnu.org/licenses/
#*****************************************************************************

from __future__ import absolute_import, unicode_literals

import os
import shutil

from glob import glob


gppath = shutil.which("gp")

if gppath is None:
Expand All @@ -43,7 +41,7 @@ def pari_share():
"""
if "PARI_SHARE" in os.environ:
return os.environ["PARI_SHARE"]
from subprocess import Popen, PIPE
from subprocess import PIPE, Popen
if not gppath:
raise EnvironmentError("cannot find an installation of PARI/GP: make sure that the 'gp' program is in your $PATH")
# Ignore GP_DATA_DIR environment variable
Expand Down
3 changes: 2 additions & 1 deletion autogen/ret.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# http://www.gnu.org/licenses/
# https://www.gnu.org/licenses/
#*****************************************************************************

from __future__ import unicode_literals


class PariReturn(object):
"""
This class represents the return value of a PARI call.
Expand Down
2 changes: 1 addition & 1 deletion cypari2/convert.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ PARI integers are stored as an array of limbs of type ``pari_ulong``
(GMP or native), this array is stored little-endian or big-endian.
This is encapsulated in macros like ``int_W()``:
see section 4.5.1 of the
`PARI library manual <http://pari.math.u-bordeaux.fr/pub/pari/manuals/2.7.0/libpari.pdf>`_.
`PARI library manual <https://pari.math.u-bordeaux.fr/pub/pari/manuals/2.7.0/libpari.pdf>`_.

Python integers of type ``int`` are just C longs. Python integers of
type ``long`` are stored as a little-endian array of type ``digit``
Expand Down
4 changes: 1 addition & 3 deletions cypari2/custom_block.pyx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# distutils: libraries = gmp pari

#*****************************************************************************
# Distributed under the terms of the GNU General Public License (GPL)
# as published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
# http://www.gnu.org/licenses/
# https://www.gnu.org/licenses/
#*****************************************************************************

from cysignals.signals cimport add_custom_signals
Expand Down
6 changes: 3 additions & 3 deletions cypari2/gen.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1789,9 +1789,9 @@ cdef class Gen(Gen_base):
while sp[0] == c'0':
sp = sp + 1
sp -= 1
sp[0] = 'x'
sp[0] = c'x'
sp -= 1
sp[0] = '0'
sp[0] = c'0'
if signe(x) < 0:
sp -= 1
sp[0] = c'-'
Expand Down Expand Up @@ -3639,7 +3639,7 @@ cdef class Gen(Gen_base):
>>> G.galoissubfields(flag=2, v='z')[3]
[...^2 + 2, Mod(x^3 + x, x^4 + 1), [x^2 - z*x - 1, x^2 + z*x - 1]]

.. _galoissubfields: http://pari.math.u-bordeaux.fr/dochtml/html.stable/Functions_related_to_general_number_fields.html#galoissubfields
.. _galoissubfields: https://pari.math.u-bordeaux.fr/dochtml/html.stable/Functions_related_to_general_number_fields.html#galoissubfields
"""
sig_on()
return new_gen(galoissubfields(self.g, flag, get_var(v)))
Expand Down
43 changes: 43 additions & 0 deletions cypari2/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
py.install_sources(
'__init__.py',
'closure.pxd',
'convert.pxd',
'gen.pxd',
'handle_error.pxd',
'pari_instance.pxd',
'paridecl.pxd',
'paripriv.pxd',
'pycore_long.pxd',
'stack.pxd',
'string_utils.pxd',
'types.pxd',
'cypari.h',
'pycore_long.h',
'auto_paridecl.pxd',
'auto_gen.pxi',
'auto_instance.pxi',
subdir: 'cypari2'
)


extension_data = {
'closure': files('closure.pyx'),
'stack': files('stack.pyx'),
'custom_block': files('custom_block.pyx'),
'convert': files('convert.pyx'),
'string_utils': files('string_utils.pyx'),
'handle_error': files('handle_error.pyx'),
'gen': files('gen.pyx'),
'pari_instance': files('pari_instance.pyx')
}

foreach name, pyx : extension_data
py.extension_module(
name,
sources: pyx,
subdir: 'cypari2',
install: true,
dependencies: [cysignals, pari],
)
endforeach

1 change: 0 additions & 1 deletion cypari2/paridecl.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# distutils: libraries = gmp pari
"""
Declarations for non-inline functions from PARI.

Expand Down
1 change: 0 additions & 1 deletion cypari2/paripriv.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# distutils: libraries = gmp pari
"""
Declarations for private functions from PARI

Expand Down
2 changes: 1 addition & 1 deletion cypari2/stack.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Memory management for Gens on the PARI stack or the heap
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# http://www.gnu.org/licenses/
# https://www.gnu.org/licenses/
# ****************************************************************************

cimport cython
Expand Down
53 changes: 53 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
project('cypari2',
['c', 'cython'],
version: files('VERSION'),
license: 'GPL v2+',
default_options: ['c_std=c17', 'python.install_env=auto'],
meson_version: '>=1.2',
)

# Python module
# https://mesonbuild.com/Python-module.html
py = import('python').find_installation(pure: false)

# Compilers
cc = meson.get_compiler('c')
cython = meson.get_compiler('cython')
# Workaround as described in https://cython.readthedocs.io/en/latest/src/userguide/special_methods.html#arithmetic-methods
add_project_arguments('-X c_api_binop_methods=True', language: 'cython')

# Dependencies
inc_cysignals = run_command(
py,
[
'-c',
'''
from os.path import relpath
import cysignals
path = cysignals.__file__.replace('__init__.py', '')
try:
print(relpath(path))
except Exception:
print(path)
'''.strip(),
],
check: true,
).stdout().strip()
cysignals = declare_dependency(include_directories: inc_cysignals)
# Cannot be found via pkg-config
pari = cc.find_library('pari', required: true)

# Run code generation step
code_gen_result = run_command(
py.full_path(), '-c',
'''
import sys
sys.path.insert(0, ".")
from autogen import rebuild
rebuild(force=True)
print("Code generation successful")
''',
check: true
)

subdir('cypari2')
29 changes: 8 additions & 21 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,36 +1,23 @@
[build-system]
requires = [
"setuptools",
"Cython>=3.0",
"cysignals>=1.11.3",
]
# 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 = ["."]
requires = ["meson-python>=0.18.0", "cython>=3.0", "cysignals>=1.11.3"]
build-backend = "mesonpy"

[project]
name = "cypari2"
description = "A Python interface to the number theory library PARI/GP"
authors = [
{name = "Luca De Feo, Vincent Delecroix, Jeroen Demeyer, Vincent Klein"},
{ name = "Luca De Feo, Vincent Delecroix, Jeroen Demeyer, Vincent Klein" },
]
maintainers = [
{name = "SageMath developers", email = "[email protected]"},
]
dependencies = [
"cysignals>=1.11.3",
{ name = "SageMath developers", email = "[email protected]" },
]
dependencies = ["cysignals>=1.11.3"]
requires-python = ">=3.9"
readme = "README.rst"
license = {text = "GNU General Public License, version 2 or later"}
license = "GPL-2.0-or-later"
license-files = ["LICENSE"]
keywords = ["PARI/GP number theory"]
dynamic = [
"version",
]
dynamic = ["version"]

[project.urls]
Homepage = "https://github.com/sagemath/cypari2"

[tool.setuptools.dynamic]
version = {file = "VERSION"}
Loading
Loading