python-gmp 0.4.0b2__tar.gz → 0.4.0b3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. python_gmp-0.4.0b2/.github/workflows/test.yml → python_gmp-0.4.0b3/.github/workflows/ci.yml +13 -34
  2. {python_gmp-0.4.0b2 → python_gmp-0.4.0b3}/.github/workflows/coverage.yml +15 -6
  3. {python_gmp-0.4.0b2 → python_gmp-0.4.0b3}/.github/workflows/os.yml +9 -19
  4. {python_gmp-0.4.0b2 → python_gmp-0.4.0b3}/.github/workflows/publish.yml +2 -1
  5. {python_gmp-0.4.0b2 → python_gmp-0.4.0b3}/.github/workflows/wheels.yml +1 -1
  6. {python_gmp-0.4.0b2 → python_gmp-0.4.0b3}/PKG-INFO +7 -8
  7. {python_gmp-0.4.0b2 → python_gmp-0.4.0b3}/README.rst +6 -7
  8. {python_gmp-0.4.0b2 → python_gmp-0.4.0b3}/fmt.c +14 -6
  9. {python_gmp-0.4.0b2 → python_gmp-0.4.0b3}/main.c +188 -316
  10. {python_gmp-0.4.0b2 → python_gmp-0.4.0b3}/mpz.h +1 -0
  11. {python_gmp-0.4.0b2 → python_gmp-0.4.0b3}/pyproject.toml +11 -9
  12. {python_gmp-0.4.0b2 → python_gmp-0.4.0b3}/tests/test_api.py +42 -3
  13. {python_gmp-0.4.0b2 → python_gmp-0.4.0b3}/tests/test_functions.py +47 -39
  14. {python_gmp-0.4.0b2 → python_gmp-0.4.0b3}/tests/test_mpz.py +96 -123
  15. python_gmp-0.4.0b3/tests/test_utils.py +126 -0
  16. {python_gmp-0.4.0b2 → python_gmp-0.4.0b3}/zz.c +244 -92
  17. {python_gmp-0.4.0b2 → python_gmp-0.4.0b3}/zz.h +14 -2
  18. python_gmp-0.4.0b2/scripts/cibw_repair_wheel_command.sh +0 -12
  19. {python_gmp-0.4.0b2 → python_gmp-0.4.0b3}/.clang-format +0 -0
  20. {python_gmp-0.4.0b2 → python_gmp-0.4.0b3}/.github/dependabot.yml +0 -0
  21. {python_gmp-0.4.0b2 → python_gmp-0.4.0b3}/.github/workflows/linter.yml +0 -0
  22. {python_gmp-0.4.0b2 → python_gmp-0.4.0b3}/.gitignore +0 -0
  23. {python_gmp-0.4.0b2 → python_gmp-0.4.0b3}/.pre-commit-config.yaml +0 -0
  24. {python_gmp-0.4.0b2 → python_gmp-0.4.0b3}/.readthedocs.yaml +0 -0
  25. {python_gmp-0.4.0b2 → python_gmp-0.4.0b3}/LICENSE +0 -0
  26. {python_gmp-0.4.0b2 → python_gmp-0.4.0b3}/docs/conf.py +0 -0
  27. {python_gmp-0.4.0b2 → python_gmp-0.4.0b3}/docs/index.rst +0 -0
  28. {python_gmp-0.4.0b2 → python_gmp-0.4.0b3}/meson.build +0 -0
  29. {python_gmp-0.4.0b2 → python_gmp-0.4.0b3}/pythoncapi_compat.h +0 -0
  30. {python_gmp-0.4.0b2 → python_gmp-0.4.0b3}/scripts/cibw_before_all.sh +0 -0
  31. {python_gmp-0.4.0b2 → python_gmp-0.4.0b3}/scripts/dll-importexport.diff +0 -0
  32. {python_gmp-0.4.0b2 → python_gmp-0.4.0b3}/scripts/fat_build_fix.diff +0 -0
  33. {python_gmp-0.4.0b2 → python_gmp-0.4.0b3}/tests/conftest.py +0 -0
  34. /python_gmp-0.4.0b2/tests/test_outofmem.py → /python_gmp-0.4.0b3/tests/test_memory.py +0 -0
@@ -1,4 +1,4 @@
1
- name: CI tests
1
+ name: Run CI tests
2
2
  on: [push, pull_request]
3
3
  jobs:
4
4
  linter:
@@ -12,12 +12,13 @@ jobs:
12
12
  strategy:
13
13
  fail-fast: true
14
14
  matrix:
15
+ os: [ubuntu-24.04]
15
16
  python-version: [3.9, '3.10', pypy3.11, graalpy-24.2,
16
17
  3.11, 3.12, 3.13, 3.13t, 3.14, 3.14t]
17
- runs-on: ubuntu-24.04
18
+ runs-on: ${{ matrix.os }}
18
19
  env:
19
20
  PYTEST_ADDOPTS: --verbose
20
- CFLAGS: -Wall -Wpedantic -Werror -std=c17
21
+ CFLAGS: -Wall -Wpedantic -Werror -std=c17 -Wconversion
21
22
  steps:
22
23
  - uses: actions/checkout@v4
23
24
  with:
@@ -26,44 +27,22 @@ jobs:
26
27
  with:
27
28
  python-version: ${{ matrix.python-version }}
28
29
  allow-prereleases: true
30
+ - name: Cache GNU GMP builds
31
+ id: cache-gmp
32
+ uses: actions/cache@v4
33
+ with:
34
+ path: .local
35
+ key: ${{ matrix.os }}-${{ hashFiles('scripts/*') }}
29
36
  - run: bash scripts/cibw_before_all.sh
37
+ if: steps.cache-gmp.outputs.cache-hit != 'true'
30
38
  - run: pip install --upgrade pip
31
39
  - run: pip --verbose install .[tests] -Csetup-args=-Dbuildtype=debug
32
40
  env:
33
- PKG_CONFIG_PATH: .local/lib/pkgconfig
41
+ PKG_CONFIG_PATH: ${{ github.workspace }}/.local/lib/pkgconfig
34
42
  - run: pytest
35
43
  env:
36
- LD_LIBRARY_PATH: .local/lib
44
+ LD_LIBRARY_PATH: ${{ github.workspace }}/.local/lib
37
45
  os:
38
46
  uses: ./.github/workflows/os.yml
39
47
  needs:
40
48
  - tests
41
- windows:
42
- needs:
43
- - tests
44
- runs-on: windows-2022
45
- env:
46
- PYTEST_ADDOPTS: --verbose
47
- CFLAGS: -Wall -Wpedantic -Werror -std=c17
48
- defaults:
49
- run:
50
- shell: msys2 {0}
51
- steps:
52
- - uses: actions/checkout@v4
53
- with:
54
- fetch-depth: 0
55
- - uses: msys2/setup-msys2@v2
56
- with:
57
- update: true
58
- install: >-
59
- git
60
- gmp-devel
61
- python-pip
62
- mingw-w64-x86_64-meson
63
- mingw-w64-x86_64-gcc
64
- - run: |
65
- python -m venv .test-venv
66
- source .test-venv/bin/activate
67
- python -m pip install --upgrade pip
68
- pip --verbose install .[tests] -Csetup-args=-Dbuildtype=debug
69
- pytest
@@ -3,13 +3,14 @@ on:
3
3
  workflow_call:
4
4
  jobs:
5
5
  coverage:
6
- runs-on: ubuntu-24.04
6
+ runs-on: ${{ matrix.os }}
7
7
  env:
8
8
  PYTEST_ADDOPTS: --verbose
9
- CFLAGS: -Wall -Wpedantic -Werror -std=c17
9
+ CFLAGS: -Wall -Wpedantic -Werror -std=c17 -Wconversion
10
10
  strategy:
11
11
  fail-fast: true
12
12
  matrix:
13
+ os: [ubuntu-24.04]
13
14
  python-version: [pypy3.11, "3.x", 3.14]
14
15
  steps:
15
16
  - uses: actions/checkout@v4
@@ -25,21 +26,29 @@ jobs:
25
26
  run: |
26
27
  sudo locale-gen ru_RU.UTF-8
27
28
  sudo locale-gen ps_AF.UTF-8
29
+ - name: Cache GNU GMP builds
30
+ id: cache-gmp
31
+ uses: actions/cache@v4
32
+ with:
33
+ path: .local
34
+ key: ${{ matrix.os }}-${{ hashFiles('scripts/*') }}
28
35
  - run: bash scripts/cibw_before_all.sh
36
+ if: steps.cache-gmp.outputs.cache-hit != 'true'
29
37
  - run: pip install --upgrade pip
30
38
  - run: |
31
39
  pip install --verbose .[tests] -Cbuild-dir=build \
32
- -Csetup-args=-Dbuildtype=debug -Csetup-args=-Db_coverage=true
40
+ -Csetup-args=-Dbuildtype=debug \
41
+ -Csetup-args=-Db_coverage=true
33
42
  env:
34
- PKG_CONFIG_PATH: .local/lib/pkgconfig
43
+ PKG_CONFIG_PATH: ${{ github.workspace }}/.local/lib/pkgconfig
35
44
  - run: pytest --hypothesis-profile=default
36
45
  env:
37
- LD_LIBRARY_PATH: .local/lib
46
+ LD_LIBRARY_PATH: ${{ github.workspace }}/.local/lib
38
47
  - name: Get coverage data
39
48
  run: |
40
49
  lcov --capture --directory build/ --output-file coverage.info
41
50
  lcov --remove coverage.info "*.h" --ignore-errors unused \
42
- --output-file coverage.info
51
+ --output-file coverage.info
43
52
  cp coverage.info build/coverage-${{ matrix.python-version }}.info
44
53
  - uses: actions/upload-artifact@v4
45
54
  with:
@@ -8,16 +8,9 @@ jobs:
8
8
  fail-fast: false
9
9
  matrix:
10
10
  os: [ubuntu-24.04, ubuntu-24.04-arm, macos-14]
11
- shell: [bash]
12
- # include:
13
- # - os: windows-2022
14
- # shell: 'msys2 {0}'
15
- defaults:
16
- run:
17
- shell: ${{ matrix.shell }}
18
11
  env:
19
12
  PYTEST_ADDOPTS: --verbose
20
- CFLAGS: -Wpedantic -Werror -std=c17
13
+ CFLAGS: -Wall -Wpedantic -Werror -std=c17 -Wconversion
21
14
  steps:
22
15
  - uses: actions/checkout@v4
23
16
  with:
@@ -25,21 +18,18 @@ jobs:
25
18
  - uses: actions/setup-python@v5
26
19
  with:
27
20
  python-version: "3.x"
28
- - uses: msys2/setup-msys2@v2.27.0
21
+ - name: Cache GNU GMP builds
22
+ id: cache-gmp
23
+ uses: actions/cache@v4
29
24
  with:
30
- install: >-
31
- mingw-w64-ucrt-x86_64-pkg-config
32
- mingw-w64-ucrt-x86_64-gcc
33
- autotools
34
- patch
35
- msystem: ucrt64
36
- path-type: inherit
37
- if: ${{ startsWith(matrix.os, 'windows') }}
25
+ path: .local
26
+ key: ${{ matrix.os }}-${{ hashFiles('scripts/*') }}
38
27
  - run: bash scripts/cibw_before_all.sh
28
+ if: steps.cache-gmp.outputs.cache-hit != 'true'
39
29
  - run: pip install --upgrade pip
40
30
  - run: pip --verbose install .[tests] -Csetup-args=-Dbuildtype=debug
41
31
  env:
42
- PKG_CONFIG_PATH: .local/lib/pkgconfig
32
+ PKG_CONFIG_PATH: ${{ github.workspace }}/.local/lib/pkgconfig
43
33
  - run: pytest --hypothesis-profile=default
44
34
  env:
45
- LD_LIBRARY_PATH: .local/lib
35
+ LD_LIBRARY_PATH: ${{ github.workspace }}/.local/lib
@@ -3,6 +3,7 @@ on: push
3
3
  jobs:
4
4
  build:
5
5
  name: Build distribution
6
+ if: startsWith(github.ref, 'refs/tags/')
6
7
  runs-on: ubuntu-24.04
7
8
  steps:
8
9
  - uses: actions/checkout@v4
@@ -19,9 +20,9 @@ jobs:
19
20
  path: dist/
20
21
  wheels:
21
22
  uses: ./.github/workflows/wheels.yml
23
+ if: startsWith(github.ref, 'refs/tags/')
22
24
  publish-to-pypi:
23
25
  name: Publish distribution to PyPI
24
- if: startsWith(github.ref, 'refs/tags/')
25
26
  needs:
26
27
  - build
27
28
  - wheels
@@ -30,7 +30,7 @@ jobs:
30
30
  - run: echo "PKG_CONFIG_PATH=${{ github.workspace }}/.local/lib/pkgconfig" >> $env:GITHUB_ENV
31
31
  if: ${{ startsWith( matrix.os , 'windows' ) }}
32
32
  - name: Build wheels
33
- uses: pypa/cibuildwheel@v3.0.0
33
+ uses: pypa/cibuildwheel@v3.1.2
34
34
  - uses: actions/upload-artifact@v4
35
35
  with:
36
36
  name: wheels-${{ matrix.os }}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-gmp
3
- Version: 0.4.0b2
3
+ Version: 0.4.0b3
4
4
  Summary: Safe bindings to the GNU GMP library
5
5
  Keywords: gmp,multiple-precision,arbitrary-precision,bignum
6
6
  Author-Email: Sergey B Kirpichev <skirpichev@gmail.com>
@@ -97,27 +97,26 @@ than any other bignum library for all operand sizes.
97
97
  But such extension modules usually rely on default GMP's memory allocation
98
98
  functions and can't recover from errors such as out of memory. So, it's easy
99
99
  to crash the Python interpreter during the interactive session. Following
100
- example with the gmpy2 should work on most Unix systems:
100
+ example with the gmpy2 will work if you set address space limit for the Python
101
+ interpreter (e.g. by ``prlimit`` command on Linux):
101
102
 
102
103
  .. code:: pycon
103
104
 
104
- >>> import gmpy2, resource
105
+ >>> import gmpy2
105
106
  >>> gmpy2.__version__
106
107
  '2.2.1'
107
- >>> resource.setrlimit(resource.RLIMIT_AS, (1024*32*1024, -1))
108
108
  >>> z = gmpy2.mpz(29925959575501)
109
109
  >>> while True: # this loop will crash interpter
110
110
  ... z = z*z
111
111
  ...
112
- GNU MP: Cannot allocate memory (size=2949160)
112
+ GNU MP: Cannot allocate memory (size=46956584)
113
113
  Aborted
114
114
 
115
115
  The gmp module handles such errors correctly:
116
116
 
117
117
  .. code:: pycon
118
118
 
119
- >>> import gmp, resource
120
- >>> resource.setrlimit(resource.RLIMIT_AS, (1024*32*1024, -1))
119
+ >>> import gmp
121
120
  >>> z = gmp.mpz(29925959575501)
122
121
  >>> while True:
123
122
  ... z = z*z
@@ -130,4 +129,4 @@ The gmp module handles such errors correctly:
130
129
  >>> # interpreter still works, all variables in
131
130
  >>> # the current scope are available,
132
131
  >>> z.bit_length() # including pre-failure value of z
133
- mpz(5867630)
132
+ 93882077
@@ -47,27 +47,26 @@ than any other bignum library for all operand sizes.
47
47
  But such extension modules usually rely on default GMP's memory allocation
48
48
  functions and can't recover from errors such as out of memory. So, it's easy
49
49
  to crash the Python interpreter during the interactive session. Following
50
- example with the gmpy2 should work on most Unix systems:
50
+ example with the gmpy2 will work if you set address space limit for the Python
51
+ interpreter (e.g. by ``prlimit`` command on Linux):
51
52
 
52
53
  .. code:: pycon
53
54
 
54
- >>> import gmpy2, resource
55
+ >>> import gmpy2
55
56
  >>> gmpy2.__version__
56
57
  '2.2.1'
57
- >>> resource.setrlimit(resource.RLIMIT_AS, (1024*32*1024, -1))
58
58
  >>> z = gmpy2.mpz(29925959575501)
59
59
  >>> while True: # this loop will crash interpter
60
60
  ... z = z*z
61
61
  ...
62
- GNU MP: Cannot allocate memory (size=2949160)
62
+ GNU MP: Cannot allocate memory (size=46956584)
63
63
  Aborted
64
64
 
65
65
  The gmp module handles such errors correctly:
66
66
 
67
67
  .. code:: pycon
68
68
 
69
- >>> import gmp, resource
70
- >>> resource.setrlimit(resource.RLIMIT_AS, (1024*32*1024, -1))
69
+ >>> import gmp
71
70
  >>> z = gmp.mpz(29925959575501)
72
71
  >>> while True:
73
72
  ... z = z*z
@@ -80,4 +79,4 @@ The gmp module handles such errors correctly:
80
79
  >>> # interpreter still works, all variables in
81
80
  >>> # the current scope are available,
82
81
  >>> z.bit_length() # including pre-failure value of z
83
- mpz(5867630)
82
+ 93882077
@@ -2,12 +2,19 @@
2
2
  # pragma GCC diagnostic push
3
3
  # pragma GCC diagnostic ignored "-Wnewline-eof"
4
4
  #endif
5
+ #if defined(__GNUC__) || defined(__clang__)
6
+ # pragma GCC diagnostic push
7
+ # pragma GCC diagnostic ignored "-Wsign-conversion"
8
+ #endif
5
9
 
6
10
  #include "pythoncapi_compat.h"
7
11
 
8
12
  #define PY_SSIZE_T_CLEAN
9
13
  #include <Python.h>
10
14
 
15
+ #if defined(__GNUC__) || defined(__clang__)
16
+ # pragma GCC diagnostic pop
17
+ #endif
11
18
  #if defined(__clang__)
12
19
  # pragma GCC diagnostic pop
13
20
  #endif
@@ -40,7 +47,7 @@ unknown_presentation_type(Py_UCS4 presentation_type,
40
47
  }
41
48
 
42
49
  static void
43
- invalid_thousands_separator_type(char specifier, Py_UCS4 presentation_type)
50
+ invalid_thousands_separator_type(int specifier, Py_UCS4 presentation_type)
44
51
  {
45
52
  assert(specifier == ',' || specifier == '_');
46
53
  if (presentation_type > 32 && presentation_type < 128) {
@@ -162,8 +169,8 @@ parse_internal_render_format_spec(PyObject *obj,
162
169
  PyObject *format_spec,
163
170
  Py_ssize_t start, Py_ssize_t end,
164
171
  InternalFormatSpec *format,
165
- char default_type,
166
- char default_align)
172
+ Py_UCS4 default_type,
173
+ Py_UCS4 default_align)
167
174
  {
168
175
  Py_ssize_t pos = start;
169
176
  int kind = PyUnicode_KIND(format_spec);
@@ -353,7 +360,8 @@ parse_internal_render_format_spec(PyObject *obj,
353
360
  break;
354
361
  }
355
362
  default:
356
- invalid_thousands_separator_type(format->thousands_separators, format->type);
363
+ invalid_thousands_separator_type((int)format->thousands_separators,
364
+ format->type);
357
365
  return 0;
358
366
  }
359
367
  }
@@ -361,7 +369,7 @@ parse_internal_render_format_spec(PyObject *obj,
361
369
  if (format->type == 'n'
362
370
  && format->frac_thousands_separator != LT_NO_LOCALE)
363
371
  {
364
- invalid_thousands_separator_type(format->frac_thousands_separator,
372
+ invalid_thousands_separator_type((int)format->frac_thousands_separator,
365
373
  format->type);
366
374
  return 0;
367
375
  }
@@ -733,7 +741,7 @@ fill_number(PyUnicodeWriter *writer, const NumberFieldWidths *spec,
733
741
  }
734
742
  }
735
743
  if (spec->n_sign == 1) {
736
- PyUnicodeWriter_WriteChar(writer, spec->sign);
744
+ PyUnicodeWriter_WriteChar(writer, (Py_UCS4)spec->sign);
737
745
  }
738
746
  if (spec->n_prefix) {
739
747
  PyUnicodeWriter_WriteSubstring(writer, prefix, p_start, spec->n_prefix + p_start);