gurobipy: Use buildPythonPackage on Darwin.

This commit is contained in:
Shea Levy 2017-12-18 13:07:41 -05:00
parent 03e10f8535
commit c6c05dd255
No known key found for this signature in database
GPG Key ID: 7E813B1AF14772EB
2 changed files with 30 additions and 12 deletions

View File

@ -1,26 +1,24 @@
{ stdenv, fetchurl, python, xar, cpio, cctools, insert_dylib }:
{ fetchurl, python, xar, cpio, cctools, insert_dylib }:
assert python.pkgs.isPy27 && python.ucsEncoding == 2;
stdenv.mkDerivation
python.pkgs.buildPythonPackage
{ name = "gurobipy-7.0.2";
src = fetchurl
{ url = "http://packages.gurobi.com/7.0/gurobi7.0.2_mac64.pkg";
sha256 = "14dpxas6gx02kfb28i0fh68p1z4sbjmwg8hp8h5ch6c701h260mg";
};
buildInputs = [ xar cpio cctools insert_dylib ];
buildCommand =
unpackPhase =
''
# Unpack
xar -xf $src
zcat gurobi*mac64tar.pkg/Payload | cpio -i
tar xf gurobi*_mac64.tar.gz
# Install
cd gurobi*/mac64
mkdir -p $out/lib/python2.7/site-packages
mv lib/python2.7/gurobipy $out/lib/python2.7/site-packages
mv lib/lib*.so $out/lib
# Fixup
sourceRoot=$(echo gurobi*/*64)
runHook postUnpack
'';
patches = [ ./no-darwin-fixup.patch ];
postInstall = "mv lib/lib*.so $out/lib";
postFixup =
''
install_name_tool -change \
/System/Library/Frameworks/Python.framework/Versions/2.7/Python \
${python}/lib/libpython2.7.dylib \

View File

@ -0,0 +1,20 @@
diff -Naur a/setup.py b/setup.py
--- a/setup.py 2017-12-18 12:48:02.000000000 -0500
+++ b/setup.py 2017-12-18 12:48:43.000000000 -0500
@@ -54,16 +54,3 @@
package_dir={'gurobipy' : srcpath },
package_data = {'gurobipy' : [srcfile] }
)
-
-if sys.platform == 'darwin':
- from distutils.sysconfig import get_python_lib
- import subprocess
- import os.path
- sitelib = get_python_lib() + '/gurobipy/gurobipy.so'
- subprocess.call(('install_name_tool', '-change', 'libgurobi70.so', '/Library/gurobi702/mac64/lib/libgurobi70.so', sitelib)) # version for change
- default = '/System/Library/Frameworks/Python.framework/Versions/2.7/Python'
- modified = sys.prefix + '/Python'
- if default != modified:
- if not os.path.isfile(modified):
- modified = sys.prefix + '/lib/libpython2.7.dylib' # For Anaconda
- subprocess.call(('install_name_tool', '-change', default, modified, sitelib))