Skip to content

Commit 4b2c224

Browse files
authored
Merge pull request #55 from skirpichev/v0.1.1
v0.1.1
2 parents 064e141 + 6c5817a commit 4b2c224

File tree

5 files changed

+43
-7
lines changed

5 files changed

+43
-7
lines changed

.github/workflows/publish.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Publish on PyPI
2+
on: push
3+
jobs:
4+
build:
5+
name: Build distribution
6+
runs-on: ubuntu-22.04
7+
steps:
8+
- uses: actions/checkout@v4
9+
- uses: actions/setup-python@v5
10+
with:
11+
python-version: 3.13
12+
- run: pip install build
13+
- run: python -m build -s
14+
- uses: actions/upload-artifact@v4
15+
with:
16+
name: python-gmp
17+
path: dist/
18+
publish-to-pypi:
19+
name: Publish distribution to PyPI
20+
if: startsWith(github.ref, 'refs/tags/')
21+
needs:
22+
- build
23+
runs-on: ubuntu-22.04
24+
environment:
25+
name: pypi
26+
url: https://pypi.org/p/python-gmp
27+
permissions:
28+
id-token: write
29+
steps:
30+
- uses: actions/download-artifact@v4
31+
with:
32+
name: python-gmp
33+
path: dist/
34+
- uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/basic.yml renamed to .github/workflows/test.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: basic
1+
name: test
22
on: [push, pull_request]
33
jobs:
44
linux:
@@ -19,5 +19,6 @@ jobs:
1919
- run: sudo apt-get update
2020
- run: sudo apt-get install libgmp-dev
2121
- run: pip install --upgrade pip
22-
- run: pip --verbose install --editable .[tests]
22+
- run: pip --verbose install --editable .[develop]
23+
- run: ruff check
2324
- run: pytest

README.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ shouldn't crash the interpreter!
77
Can be used as a gmpy2/python-flint replacement to provide CPython-compatible
88
integer and rational types:
99

10-
* mpz — like builtin int int type
11-
* mpq — like stdlib's Fraction type
10+
* mpz — like builtin int type
11+
* mpq — like stdlib's Fraction type (not ready yet)
1212

1313
Module includes also few functions:
1414

1515
* gcd — greatest common division, just like math.gcd
1616
* isqrt — integer square root, just like math.isqrt
17+
* factorial — just like math.factorial (not ready yet)

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ ext-modules = [{name = "gmp", sources = ["main.c"], libraries = ["gmp"]}]
4949
[project.optional-dependencies]
5050
tests = ["pytest", "hypothesis",
5151
"gmpy2; platform_python_implementation!='PyPy'"]
52+
develop = ["python-gmp[tests]", "ruff"]
5253

5354
[tool.pytest.ini_options]
5455
addopts = "--durations=7"

tests/test_mpz.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,13 @@ def test_mpz_from_to_str(x):
3535
def test_mpz_from_to_int(x):
3636
sx = str(x)
3737
mx = mpz(x)
38-
assert mpz(mx) == mx == x
38+
assert mpz(sx) == mpz(mx) == mx == x
3939
assert int(mx) == x
4040

4141

4242
@given(integers())
4343
def test_repr(x):
4444
mx = mpz(x)
45-
sx = str(x)
4645
assert repr(mx) == f"mpz({x!s})"
4746

4847

@@ -224,7 +223,7 @@ def test_to_bytes(x, length, byteorder, signed):
224223
try:
225224
rx = x.to_bytes(length, byteorder, signed=signed)
226225
except OverflowError:
227-
with raises(OverflowError):
226+
with pytest.raises(OverflowError):
228227
mpz(x).to_bytes(length, byteorder, signed=signed)
229228
else:
230229
assert rx == mpz(x).to_bytes(length, byteorder, signed=signed)

0 commit comments

Comments
 (0)