How to use gmpy2 in Heroku?

225 Views Asked by At

I'm trying to use gmpy2 as part of my Python packages in Heroku but I'm having issues with the building process.

I'm using two different buildpacks: the standard Python buildpack and APT (heroku-buildpack-apt) so I can install the dependencies for:

  • libmpfr-dev
  • libmpc-dev
  • libgmp-dev
  • libgmp3-dev

This is the error from the build log:

Failed to build gmpy2
       Installing collected packages: base58, six, ecdsa, phe, mypy-extensions, eth-typing, toolz, cytoolz, eth-hash, eth-utils, py-ecc, pycparser, cffi, secp256k1, pybtc, gmpy2, dj-database-url, whitenoise, psycopg2, sqlparse, pytz, asgiref, Django, django-heroku, gunicorn, marshmallow, pyjwt, python-http-client, sendgrid
           Running setup.py install for gmpy2: started
           Running setup.py install for gmpy2: finished with status 'error'
           ERROR: Command errored out with exit status 1:
            command: /app/.heroku/python/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-wq_i37ub/gmpy2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-wq_i37ub/gmpy2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-10c0m8d_/install-record.txt --single-version-externally-managed --compile --install-headers /app/.heroku/python/include/python3.7m/gmpy2
                cwd: /tmp/pip-install-wq_i37ub/gmpy2/
           Complete output (36 lines):
           running install
           running build
           running build_py
           creating build
           creating build/lib.linux-x86_64-3.7
           creating build/lib.linux-x86_64-3.7/gmpy2
           copying gmpy2/__init__.py -> build/lib.linux-x86_64-3.7/gmpy2
           running egg_info
           writing gmpy2.egg-info/PKG-INFO
           writing dependency_links to gmpy2.egg-info/dependency_links.txt
           writing top-level names to gmpy2.egg-info/top_level.txt
           reading manifest file 'gmpy2.egg-info/SOURCES.txt'
           reading manifest template 'MANIFEST.in'
           writing manifest file 'gmpy2.egg-info/SOURCES.txt'
           copying gmpy2/__init__.pxd -> build/lib.linux-x86_64-3.7/gmpy2
           copying gmpy2/gmpy2.h -> build/lib.linux-x86_64-3.7/gmpy2
           copying gmpy2/gmpy2.pxd -> build/lib.linux-x86_64-3.7/gmpy2
           running build_ext
           building 'gmpy2.gmpy2' extension
           creating build/temp.linux-x86_64-3.7
           creating build/temp.linux-x86_64-3.7/src
           gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I./src -I/app/.heroku/python/include/python3.7m -c src/gmpy2.c -o build/temp.linux-x86_64-3.7/src/gmpy2.o -DSHARED=1
           gcc -pthread -shared build/temp.linux-x86_64-3.7/src/gmpy2.o -lmpc -lmpfr -lgmp -o build/lib.linux-x86_64-3.7/gmpy2/gmpy2.cpython-37m-x86_64-linux-gnu.so
           /usr/bin/ld: /tmp/build_6b1253f8d045f13d59ea51c89e3a8be6/.apt/usr/lib/x86_64-linux-gnu/libmpfr.a(exceptions.o): relocation R_X86_64_TPOFF32 against symbol `__gmpfr_emin' can not be used when making a shared object; recompile with -fPIC
           /usr/bin/ld: /tmp/build_6b1253f8d045f13d59ea51c89e3a8be6/.apt/usr/lib/x86_64-linux-gnu/libmpfr.a(exp.o): relocation R_X86_64_TPOFF32 against `previous_emax' can not be used when making a shared object; recompile with -fPIC
           /usr/bin/ld: /tmp/build_6b1253f8d045f13d59ea51c89e3a8be6/.apt/usr/lib/x86_64-linux-gnu/libmpfr.a(const_log2.o): relocation R_X86_64_TPOFF32 against symbol `__gmpfr_cache_const_log2' can not be used when making a shared object; recompile with -fPIC
           /usr/bin/ld: /tmp/build_6b1253f8d045f13d59ea51c89e3a8be6/.apt/usr/lib/x86_64-linux-gnu/libmpfr.a(const_pi.o): relocation R_X86_64_TPOFF32 against symbol `__gmpfr_cache_const_pi' can not be used when making a shared object; recompile with -fPIC
           /usr/bin/ld: /tmp/build_6b1253f8d045f13d59ea51c89e3a8be6/.apt/usr/lib/x86_64-linux-gnu/libmpfr.a(set_dfl_prec.o): relocation R_X86_64_TPOFF32 against symbol `__gmpfr_default_fp_bit_precision' can not be used when making a shared object; recompile with -fPIC
           /usr/bin/ld: /tmp/build_6b1253f8d045f13d59ea51c89e3a8be6/.apt/usr/lib/x86_64-linux-gnu/libmpfr.a(set_rnd.o): relocation R_X86_64_TPOFF32 against symbol `__gmpfr_default_rounding_mode' can not be used when making a shared object; recompile with -fPIC
           /usr/bin/ld: /tmp/build_6b1253f8d045f13d59ea51c89e3a8be6/.apt/usr/lib/x86_64-linux-gnu/libmpfr.a(const_euler.o): relocation R_X86_64_TPOFF32 against symbol `__gmpfr_cache_const_euler' can not be used when making a shared object; recompile with -fPIC
           /usr/bin/ld: /tmp/build_6b1253f8d045f13d59ea51c89e3a8be6/.apt/usr/lib/x86_64-linux-gnu/libmpfr.a(const_catalan.o): relocation R_X86_64_TPOFF32 against symbol `__gmpfr_cache_const_catalan' can not be used when making a shared object; recompile with -fPIC
           /usr/bin/ld: /tmp/build_6b1253f8d045f13d59ea51c89e3a8be6/.apt/usr/lib/x86_64-linux-gnu/libmpfr.a(bernoulli.o): relocation R_X86_64_TPOFF32 against `bernoulli_size' can not be used when making a shared object; recompile with -fPIC
           /usr/bin/ld: /tmp/build_6b1253f8d045f13d59ea51c89e3a8be6/.apt/usr/lib/x86_64-linux-gnu/libmpfr.a(pool.o): relocation R_X86_64_TPOFF32 against `n_alloc' can not be used when making a shared object; recompile with -fPIC
           /usr/bin/ld: final link failed: Nonrepresentable section on output
           collect2: error: ld returned 1 exit status
           error: command 'gcc' failed with exit status 1
           ----------------------------------------
       ERROR: Command errored out with exit status 1: /app/.heroku/python/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-wq_i37ub/gmpy2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-wq_i37ub/gmpy2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-10c0m8d_/install-record.txt --single-version-externally-managed --compile --install-headers /app/.heroku/python/include/python3.7m/gmpy2 Check the logs for full command output.
 !     Push rejected, failed to compile Python app.
 !     Push failed

What should I be looking at? Can I use flags for the gcc command with this buildpack?

0

There are 0 best solutions below