Skip to content

Commit

Permalink
Merge pull request #479 from skirpichev/fix-ci
Browse files Browse the repository at this point in the history
Fix CI on gmpy2-2.1.6 branch
  • Loading branch information
casevh authored Apr 28, 2024
2 parents e72d48b + 4cecd73 commit dd793ae
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04, macos-latest]
os: [ubuntu-20.04, macos-12]
python-version: ['3.7']

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_wheels_legacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04, macos-10.15]
os: [ubuntu-20.04, macos-12]
python-version: ["3.7"]

steps:
Expand Down
23 changes: 3 additions & 20 deletions .github/workflows/pip_install_gmpy2.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,14 @@
name: pip_install_gmpy2
on:
pull_request:
branches:
- master
paths:
- 'src/**'
- 'test/**'
- 'test_cython/**'
- '**.py'

push:
branches:
- master
paths:
- 'src/**'
- 'test/**'
- 'test_cython/**'
- '**.py'
- '.github/workflows/**.yml'
on: [push, pull_request]

jobs:
osx:
strategy:
fail-fast: false
matrix:
python-version: [3.7]
runs-on: macos-latest
runs-on: macos-12
steps:
- uses: actions/checkout@master
- uses: actions/setup-python@master
Expand All @@ -40,7 +23,7 @@ jobs:
fail-fast: false
matrix:
python-version: [3.7]
os: [ubuntu-18.04]
os: [ubuntu-20.04]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@master
Expand Down
2 changes: 1 addition & 1 deletion scripts/before_ci_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if [ ! -f finish_before_ci_build ]; then
if [[ "$OSTYPE" == "linux-gnu" ]]; then
yum install -y xz
fi
curl -O https://gmplib.org/download/gmp/gmp-${GMP_VERSION}.tar.xz
curl -O -k https://ftp.gnu.org/gnu/gmp/gmp-${GMP_VERSION}.tar.xz
tar -xvf gmp-${GMP_VERSION}.tar.xz
# need to set host to the oldest triple to avoid building binaries
# that use build machine micro-architecure. configfsf.guess is the one that
Expand Down
2 changes: 1 addition & 1 deletion scripts/before_ci_build_apple_silicon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ EXTRA="--build=x86_64-apple-darwin --host=aarch64-apple-darwin --target=aarch64-
if [ ! -f finish_before_ci_build ]; then
if [[ "$OSTYPE" == "linux-gnu" || "$OSTYPE" == "linux-musl" || "$OSTYPE" == "darwin"* ]]; then
echo $PWD
curl -O https://gmplib.org/download/gmp/gmp-${GMP_VERSION}.tar.xz
curl -O -k https://ftp.gnu.org/gnu/gmp/gmp-${GMP_VERSION}.tar.xz
tar -xf gmp-${GMP_VERSION}.tar.xz
cd gmp-${GMP_VERSION}
patch -N -Z -p0 < ../scripts/patch-arm64.diff
Expand Down
36 changes: 13 additions & 23 deletions src/gmpy2_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -537,19 +537,17 @@ GMPy_MPFR_New(mpfr_prec_t bits, CTXT_Object *context)

if (global.in_gmpympfrcache) {
result = global.gmpympfrcache[--(global.in_gmpympfrcache)];
/* Py_INCREF does not set the debugging pointers, so need to use
_Py_NewReference instead. */
_Py_NewReference((PyObject*)result);
mpfr_set_prec(result->f, bits);
Py_INCREF((PyObject*)result);
}
else {
if (!(result = PyObject_New(MPFR_Object, &MPFR_Type))) {
result = PyObject_New(MPFR_Object, &MPFR_Type);
if (result == NULL) {
/* LCOV_EXCL_START */
return NULL;
/* LCOV_EXCL_STOP */
}
mpfr_init2(result->f, bits);
}
mpfr_init2(result->f, bits);
result->hash_cache = -1;
result->rc = 0;
return result;
Expand Down Expand Up @@ -704,7 +702,7 @@ set_gmpympccache(void)
static MPC_Object *
GMPy_MPC_New(mpfr_prec_t rprec, mpfr_prec_t iprec, CTXT_Object *context)
{
MPC_Object *self;
MPC_Object *result;

if (rprec < 2) {
CHECK_CONTEXT(context);
Expand All @@ -722,29 +720,21 @@ GMPy_MPC_New(mpfr_prec_t rprec, mpfr_prec_t iprec, CTXT_Object *context)
return NULL;
}
if (global.in_gmpympccache) {
self = global.gmpympccache[--(global.in_gmpympccache)];
/* Py_INCREF does not set the debugging pointers, so need to use
_Py_NewReference instead. */
_Py_NewReference((PyObject*)self);
if (rprec == iprec) {
mpc_set_prec(self->c, rprec);
}
else {
mpc_clear(self->c);
mpc_init3(self->c, rprec, iprec);
}
result = global.gmpympccache[--(global.in_gmpympccache)];
Py_INCREF((PyObject*)result);
}
else {
if (!(self = PyObject_New(MPC_Object, &MPC_Type))) {
result = PyObject_New(MPC_Object, &MPC_Type);
if (result == NULL) {
/* LCOV_EXCL_START */
return NULL;
/* LCOV_EXCL_STOP */
}
mpc_init3(self->c, rprec, iprec);
}
self->hash_cache = -1;
self->rc = 0;
return self;
mpc_init3(result->c, rprec, iprec);
result->hash_cache = -1;
result->rc = 0;
return result;
}

static PyObject *
Expand Down
2 changes: 2 additions & 0 deletions src/gmpy2_format.c
Original file line number Diff line number Diff line change
Expand Up @@ -592,12 +592,14 @@ GMPy_MPC_Format(PyObject *self, PyObject *args)
if (mpcstyle)
strcat(tempbuf, " ");
else {
#if MPFR_VERSION < MPFR_VERSION_NUM(4,2,1)
/* Need to insert + if imag is nan or +inf. */
if (mpfr_nan_p(mpc_imagref(MPC(self))) ||
(mpfr_inf_p(mpc_imagref(MPC(self))) &&
mpfr_sgn(mpc_imagref(MPC(self))) > 0)) {
strcat(tempbuf, "+");
}
#endif
}
strcat(tempbuf, imagbuf);
if (strlen(imagbuf) < 50 &&
Expand Down

0 comments on commit dd793ae

Please sign in to comment.