Skip to content

Commit

Permalink
add gmpy2 and dependencies (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv authored Aug 4, 2022
1 parent 4ce768a commit f97994d
Show file tree
Hide file tree
Showing 8 changed files with 237 additions and 0 deletions.
9 changes: 9 additions & 0 deletions recipes/recipes_emscripten/gmp/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
emconfigure ./configure \
CFLAGS="$CFLAGS -fPIC" \
--prefix=${PREFIX} \
--host=none \
--enable-cxx
# --enable-fat

emmake make -j${CPU_COUNT}
emmake make install
48 changes: 48 additions & 0 deletions recipes/recipes_emscripten/gmp/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
context:
version: "6.2.1"

package:
name: gmp
version: "{{ version }}"

source:
url: https://gmplib.org/download/gmp/gmp-{{ version }}.tar.bz2
sha256: eae9326beb4158c386e39a356818031bd28f3124cf915f8c5b1dc4c7a36b4d7c

build:
number: 0
# run_exports:
# - {{ pin_subpackage("gmp") }}

requirements:
build:
- gnuconfig # [unix]
- "{{ compiler('c') }}"
- "{{ compiler('cxx') }}"
- m4
- make

# test:
# requires:
# - {{ compiler('c') }}

# files:
# - test.c

# commands:
# - test -f ${PREFIX}/lib/libgmp.a # [unix]
# - test -f ${PREFIX}/lib/libgmp.dylib # [osx]
# - test -f ${PREFIX}/lib/libgmp.so # [linux]
# - test -f ${PREFIX}/lib/libgmpxx.a # [unix]
# - test -f ${PREFIX}/lib/libgmpxx.dylib # [osx]
# - test -f ${PREFIX}/lib/libgmpxx.so # [linux]

about:
home: http://gmplib.org/
license: GPL-2.0-or-later AND LGPL-3.0-or-later
license_file: COPYING.LESSERv3
summary: The GNU multiprecision library.

extra:
recipe-maintainers:
- wolfv
52 changes: 52 additions & 0 deletions recipes/recipes_emscripten/gmpy2/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
context:
version: "2.1.2"

package:
name: gmpy2
version: "{{ version }}"

source:
url: https://pypi.io/packages/source/g/gmpy2/gmpy2-{{ version }}.tar.gz
sha256: da75140bca128ece795895477e53b43773e3748aa90ba6170eae7ca2c74b82d1

build:
number: 0
script:
- python -m pip install . -vvv

requirements:
build:
- sel(build_platform != target_platform): python
- sel(build_platform != target_platform): cross-python_{{ target_platform }}
- "{{ compiler('c') }}"
host:
- gmp # [unix]
# - mpir # [win]
# - mpfr
- mpc
- python
- pip
run:
- gmp # [unix]
# - mpir # [win]
# - mpfr
- mpc
- python

# test:
# imports:
# - gmpy2

about:
home: https://pypi.python.org/pypi/gmpy2
license: LGPL-3.0-or-later
license_file: COPYING.LESSER
summary: GMP/MPIR, MPFR, and MPC interface to Python 2.6+ and 3.x

extra:
recipe-maintainers:
- wolfv
emscripten_tests:
python:
pytest_files:
- test_gmpy2.py
9 changes: 9 additions & 0 deletions recipes/recipes_emscripten/gmpy2/test_gmpy2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
def test_gmpy2():
import gmpy2
from gmpy2 import mpc, mpfr, mpq, mpz, sqrt

assert mpz(99) * 43 == mpz(4257)
assert mpq(3, 7) / 7 == mpq(3, 49)

gmpy2.get_context().allow_complex = True
assert sqrt(mpfr(-2)) == mpc("0.0+1.4142135623730951j")
9 changes: 9 additions & 0 deletions recipes/recipes_emscripten/mpc/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
emconfigure ./configure \
CFLAGS="$CFLAGS -fPIC" \
--with-gmp="${PREFIX}" \
--with-mpfr="${PREFIX}" \
--prefix=${PREFIX}


emmake make -j${CPU_COUNT}
emmake make install
49 changes: 49 additions & 0 deletions recipes/recipes_emscripten/mpc/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
context:
version: "1.2.1"

package:
name: mpc
version: "{{ version }}"

source:
url: https://ftp.gnu.org/gnu/mpc/mpc-{{ version }}.tar.gz
sha256: 17503d2c395dfcf106b622dc142683c1199431d095367c6aacba6eec30340459

build:
number: 0
# run_exports:
# - {{ pin_subpackage("mpc") }}

requirements:
build:
- gnuconfig
- "{{ compiler('c') }}"
# - autotools_clang_conda # [win]
- make
host:
- gmp # [unix]
# - mpir # [win]
- mpfr
run:
- gmp # [unix]
# - mpir # [win]
- mpfr

# test:
# commands:
# - if not exist %LIBRARY_INC%\\mpc.h exit 1 # [win]
# - if not exist %LIBRARY_LIB%\\mpc.lib exit 1 # [win]
# - if not exist %LIBRARY_BIN%\\mpc.dll exit 1 # [win]
# - test -f ${PREFIX}/include/mpc.h # [unix]
# - test -f ${PREFIX}/lib/libmpc.dylib # [osx]
# - test -f ${PREFIX}/lib/libmpc.so # [linux]

about:
home: http://www.multiprecision.org/
license: LGPL-3.0-or-later
license_file: COPYING.LESSER
summary: A C library for the arithmetic of complex numbers with arbitrarily high precision.

extra:
recipe-maintainers:
- wolfv
12 changes: 12 additions & 0 deletions recipes/recipes_emscripten/mpfr/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

# Get an updated config.sub and config.guess
cp $BUILD_PREFIX/share/gnuconfig/config.* . || true

emconfigure ./configure \
CFLAGS="$CFLAGS -fPIC" \
--prefix=$PREFIX \
--with-gmp=$PREFIX

make -j${CPU_COUNT}
make install
49 changes: 49 additions & 0 deletions recipes/recipes_emscripten/mpfr/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
context:
version: "4.1.0"

package:
name: mpfr
version: "{{ version }}"

source:
url: http://ftp.gnu.org/gnu/mpfr/mpfr-{{ version }}.tar.gz
sha256: 3127fe813218f3a1f0adf4e8899de23df33b4cf4b4b3831a5314f78e65ffa2d6

build:
number: 0
# run_exports:
# - {{ pin_subpackage("mpfr") }}

requirements:
build:
- libtool
- m4
- make
- gnuconfig
- "{{ compiler('c') }}"
# - autotools_clang_conda # [win]
host:
- gmp # [unix]
# - mpir # [win]

# test:
# requires:
# - {{ compiler('c') }}
# - libtool # [unix]
# - m4 # [unix]

# commands:
# - if not exist %LIBRARY_INC%\\mpfr.h exit 1 # [win]
# - if not exist %LIBRARY_LIB%\\mpfr.lib exit 1 # [win]
# - if not exist %LIBRARY_BIN%\\mpfr.dll exit 1 # [win]
# - test -f ${PREFIX}/lib/libmpfr${SHLIB_EXT} # [unix]

about:
home: http://www.mpfr.org/
license: LGPL-3.0-only
license_file: COPYING.LESSER
summary: The MPFR library is a C library for multiple-precision floating-point computations with correct rounding.

extra:
recipe-maintainers:
- wolfv

0 comments on commit f97994d

Please sign in to comment.