Skip to content

Commit 621fe24

Browse files
authored
Merge pull request #56 from skirpichev/misc
v0.1.2
2 parents 529f9e4 + c19d422 commit 621fe24

File tree

8 files changed

+157
-6
lines changed

8 files changed

+157
-6
lines changed

.github/workflows/publish.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,37 @@ jobs:
3232
name: python-gmp
3333
path: dist/
3434
- uses: pypa/gh-action-pypi-publish@release/v1
35+
github-release:
36+
name: >-
37+
Sign the Python distribution with Sigstore
38+
and upload them to GitHub Release
39+
needs:
40+
- publish-to-pypi
41+
runs-on: ubuntu-22.04
42+
permissions:
43+
contents: write
44+
id-token: write
45+
steps:
46+
- uses: actions/download-artifact@v4
47+
with:
48+
name: python-gmp
49+
path: dist/
50+
- uses: sigstore/[email protected]
51+
with:
52+
inputs: >-
53+
./dist/*.tar.gz
54+
- name: Create GitHub Release
55+
env:
56+
GITHUB_TOKEN: ${{ github.token }}
57+
run: >-
58+
gh release create '${{ github.ref_name }}'
59+
--repo '${{ github.repository }}'
60+
--prerelease
61+
--generate-notes
62+
- name: Upload artifact signatures to GitHub Release
63+
env:
64+
GITHUB_TOKEN: ${{ github.token }}
65+
run: >-
66+
gh release upload
67+
'${{ github.ref_name }}' dist/**
68+
--repo '${{ github.repository }}'

.github/workflows/test.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,25 @@ jobs:
1818
allow-prereleases: true
1919
- run: sudo apt-get update
2020
- run: sudo apt-get install libgmp-dev
21+
- run: sudo apt-get install texlive texlive-latex-extra latexmk
22+
if: matrix.python-version == 3.13
2123
- run: pip install --upgrade pip
2224
- run: pip --verbose install --editable .[develop]
25+
if: matrix.python-version != 3.13
26+
- run: pip --verbose install --editable .[develop,docs]
27+
if: matrix.python-version == 3.13
2328
- run: ruff check
2429
- run: pytest
30+
- name: Building docs
31+
if: matrix.python-version == 3.13
32+
run: |
33+
sphinx-build --color -W --keep-going -b html docs build/sphinx/html
34+
sphinx-build --color -W --keep-going -b latex docs build/sphinx/latex
35+
make -C build/sphinx/latex all-pdf
36+
- name: Archive build artifacts
37+
uses: actions/upload-artifact@v4
38+
if: matrix.python-version == 3.13
39+
with:
40+
path: |
41+
build/sphinx/html/
42+
build/sphinx/latex/python-gmp.pdf

.readthedocs.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: 2
2+
formats:
3+
- htmlzip
4+
- pdf
5+
build:
6+
os: ubuntu-22.04
7+
apt_packages:
8+
- libmpc-dev
9+
- gcc
10+
tools:
11+
python: "3"
12+
python:
13+
install:
14+
- method: pip
15+
path: .
16+
extra_requirements:
17+
- docs
18+
sphinx:
19+
fail_on_warning: true

MANIFEST.in

Lines changed: 0 additions & 2 deletions
This file was deleted.

docs/conf.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
"""
2+
python-gmp documentation build configuration file.
3+
4+
This file is execfile()d with the current directory set to its containing dir.
5+
6+
The contents of this file are pickled, so don't put values in the namespace
7+
that aren't pickleable (module imports are okay, they're removed
8+
automatically).
9+
"""
10+
11+
import packaging.version
12+
13+
import gmp
14+
15+
# Add any Sphinx extension module names here, as strings. They can be extensions
16+
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
17+
extensions = ['sphinx.ext.autodoc']
18+
19+
# The name of a reST role (builtin or Sphinx extension) to use as the
20+
# default role, that is, for text marked up `like this`.
21+
default_role = 'py:obj'
22+
23+
# Sphinx will warn about all references where the target cannot be found.
24+
nitpicky = True
25+
26+
# This value selects if automatically documented members are sorted
27+
# alphabetical (value 'alphabetical'), by member type (value 'groupwise')
28+
# or by source order (value 'bysource').
29+
autodoc_member_order = 'groupwise'
30+
31+
# The default options for autodoc directives. They are applied to all
32+
# autodoc directives automatically.
33+
autodoc_default_options = {'members': True}
34+
35+
# General information about the project.
36+
project = gmp.__package__
37+
copyright = '2024, Sergey B Kirpichev'
38+
39+
gmp_version = packaging.version.parse(gmp.__version__)
40+
41+
# The version info for the project you're documenting, acts as replacement for
42+
# |version| and |release|, also used in various other places throughout the
43+
# built documents.
44+
#
45+
# The short X.Y version.
46+
version = f"{gmp_version.major}.{gmp_version.minor}"
47+
# The full version, including alpha/beta/rc tags.
48+
release = gmp.__version__
49+
50+
# Grouping the document tree into LaTeX files. List of tuples
51+
# (source start file, target name, title, author, documentclass [howto/manual]).
52+
latex_documents = [('index', 'python-gmp.tex', 'python-gmp Documentation',
53+
'Sergey B Kirpichev', 'manual')]

docs/index.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Documentation for python-gmp
2+
============================
3+
4+
.. automodule:: gmp
5+
:members:

main.c

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <gmp.h>
88

99

10-
static const char python_gmp_version[] = "0.1.1";
10+
static const char python_gmp_version[] = "0.1.2";
1111

1212

1313
static jmp_buf gmp_env;
@@ -1663,6 +1663,21 @@ static PyMethodDef methods[] = {
16631663
};
16641664

16651665

1666+
PyDoc_STRVAR(mpz_doc,
1667+
"mpz(x, /)\n\
1668+
mpz(x, /, base=10)\n\
1669+
\n\
1670+
Convert a number or string to an integer, or return 0 if no arguments\n\
1671+
are given. If x is a number, return x.__int__(). For floating-point\n\
1672+
numbers, this truncates towards zero.\n\
1673+
\n\
1674+
If x is not a number or if base is given, then x must be a string,\n\
1675+
bytes, or bytearray instance representing an integer literal in the\n\
1676+
given base. The literal can be preceded by '+' or '-' and be surrounded\n\
1677+
by whitespace. The base defaults to 10. Valid bases are 0 and 2-36.\n\
1678+
Base 0 means to interpret the base from the string as an integer literal.");
1679+
1680+
16661681
PyTypeObject MPZ_Type = {
16671682
PyVarObject_HEAD_INIT(NULL, 0)
16681683
.tp_name = "gmp.mpz",
@@ -1676,6 +1691,7 @@ PyTypeObject MPZ_Type = {
16761691
.tp_hash = (hashfunc) hash,
16771692
.tp_getset = getsetters,
16781693
.tp_methods = methods,
1694+
.tp_doc = mpz_doc,
16791695
};
16801696

16811697

@@ -1856,9 +1872,12 @@ gmp_isqrt(PyObject *self, PyObject *other)
18561872

18571873
static PyMethodDef functions [] =
18581874
{
1859-
{"gcd", (PyCFunction)gmp_gcd, METH_FASTCALL, "Greatest Common Divisor."},
1875+
{"gcd", (PyCFunction)gmp_gcd, METH_FASTCALL,
1876+
("gcd($module, /, *integers)\n--\n\n"
1877+
"Greatest Common Divisor.")},
18601878
{"isqrt", gmp_isqrt, METH_O,
1861-
"Return the integer part of the square root of the input."},
1879+
("isqrt($module, n, /)\n--\n\n"
1880+
"Return the integer part of the square root of the input.")},
18621881
{NULL} /* sentinel */
18631882
};
18641883

pyproject.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
55
[project]
66
name = "python-gmp"
77
#dynamic = ["version"]
8-
version = "0.1.1"
8+
version = "0.1.2"
99
description = "Safe bindings to the GNU GMP library"
1010
keywords = ['gmp', 'multiple-precision', 'arbitrary-precision', 'bignum']
1111
license = {text = "MIT"}
@@ -39,17 +39,22 @@ content-type = 'text/x-rst'
3939
Homepage = 'https://github.com/diofant/python-gmp'
4040
'Source Code' = 'https://github.com/diofant/python-gmp'
4141
'Bug Tracker' = 'https://github.com/diofant/python-gmp/issues'
42+
Documentation = 'https://python-gmp.readthedocs.io/'
4243

4344
[tool.setuptools]
4445
ext-modules = [{name = "gmp", sources = ["main.c"], libraries = ["gmp"]}]
4546

4647
#[tool.setuptools.dynamic]
4748
#version = {attr = "gmp.__version__"}
4849

50+
[tool.setuptools.package-data]
51+
"*" = ["*.h"]
52+
4953
[project.optional-dependencies]
5054
tests = ["pytest", "hypothesis",
5155
"gmpy2; platform_python_implementation!='PyPy'"]
5256
develop = ["python-gmp[tests]", "ruff"]
57+
docs = ['sphinx']
5358

5459
[tool.pytest.ini_options]
5560
addopts = "--durations=7"

0 commit comments

Comments
 (0)