gmpy
gmpy copied to clipboard
Windows build comments
@skirpichev @oscarbenjamin
Some comments on separating GMP, MPFR, and MPC files from gmpy2. This is based on the current code and has only been tested on Windows.
Current state has the [gmp,mpfr,mpc] .h and .lib files installed in gmpy2/gmpy2 and the DLLs are installed in gmpy2.libs. I tried to create a new gmpy2*.pyd file using those installed libraries. It is much easier if the .h and .lib files are installed in gmpy2.libs.
I moved the .h and .lib files on an installed installation and I copied the src/* to a different location in the filesystem. The setup file below is sufficient to compile a new gmpy2*.pyd file. Since my immediate need is to quickly compile and test, I just replaced the previously installed gmpy2*.pyd file with the new one and it worked.
Here is the modified setup.py file. I cut it down to the bare minimum.
from setuptools import Extension, setup
import sys
import os
import platform
import gmpy2
gmpy2_packagedir = os.path.dirname(gmpy2.__file__) + '.libs'
gmpy_ext = [
Extension("gmpy2.gmpy2",
sources=["gmpy2.c"],
include_dirs=sys.path + [gmpy2_packagedir],
library_dirs=sys.path + [gmpy2_packagedir],
libraries=['mpc','mpfr','gmp'],
extra_compile_args= ["/DSHARED=1"],
)
]
setup (
ext_modules = gmpy_ext
)
And the contents of gmpy2.libs are:
gmp.h
gmp.lib
libgmp-10.dll
mpfr.h
mpfr.lib
libmpfr-6.dll
mpc.h
mpc.lib
libmpc-3.dll
libgcc_s_seh-1.dll
libwinpthread-1.dll
Would the following strategy work for bundling the GMP, MPFR, MPC libraries? Names can easily changed.
- Create "gmpy2libs_vN" for each version of the set of libraries. N is incremented for each new version.
- gmpy2libs_vN contains the libraries and just enough C code to allow "import gmpy2libs_vN".
- Users would need to import gmpy2libs_vN before loading their extension.
- gmpy2libs_vN could contain support functions to assist detecting versions etc.
I don't understand Python packaging requirements to know if this would work or not.