Skip to content

Commit

Permalink
Make setup.py (more) compatible with windows; basic C code in Windows…
Browse files Browse the repository at this point in the history
… should now compile
  • Loading branch information
jobovy committed Feb 24, 2018
1 parent a01a305 commit 6cbfe7f
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from setuptools import setup
from distutils.core import Extension
import sys
import sysconfig
import distutils.sysconfig as sysconfig
import os, os.path
import platform
import subprocess
import glob
PY3= sys.version > '3'
WIN32= platform.system() == 'Windows'

long_description= ''
previous_line= ''
Expand Down Expand Up @@ -95,6 +97,8 @@
gsl_version= subprocess.check_output(cmd,shell=sys.platform.startswith('win'))
except (OSError,subprocess.CalledProcessError):
gsl_version= ['0','0']
if WIN32: # BOVY: Hack for now!
gsl_version= ['2','3']
else:
if PY3:
gsl_version= gsl_version.decode('utf-8')
Expand All @@ -114,6 +118,11 @@
if float(gsl_version[0]) >= 1.:
orbit_libraries.extend(['gsl','gslcblas'])

# On Windows it's unnecessary and erroneous to include m
if WIN32:
orbit_libraries.remove('m')
pot_libraries.remove('m')

orbit_include_dirs= ['galpy/util',
'galpy/util/interp_2d',
'galpy/potential_src/potential_c_ext']
Expand Down Expand Up @@ -150,8 +159,9 @@

if single_ext: #add the code and libraries for the other extensions
#src
orbit_int_c_src.extend(glob.glob('galpy/actionAngle_src/actionAngle_c_ext/*.c'))
orbit_int_c_src.extend(glob.glob('galpy/potential_src/interppotential_c_ext/*.c'))
if not WIN32: # Necessary bc windows build for these does not work now
orbit_int_c_src.extend(glob.glob('galpy/actionAngle_src/actionAngle_c_ext/*.c'))
orbit_int_c_src.extend(glob.glob('galpy/potential_src/interppotential_c_ext/*.c'))
if os.path.exists('galpy/actionAngle_src/actionAngleTorus_c_ext/torus/src'):
# Add Torus code
orbit_int_c_src.extend(actionAngleTorus_c_src)
Expand All @@ -173,7 +183,7 @@
# Add Torus code
orbit_include_dirs.extend(actionAngleTorus_include_dirs)
orbit_include_dirs= list(set(orbit_include_dirs))

orbit_int_c= Extension('galpy_integrate_c',
sources=orbit_int_c_src,
libraries=orbit_libraries,
Expand Down Expand Up @@ -207,7 +217,7 @@
include_dirs=actionAngle_include_dirs,
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args)
if float(gsl_version[0]) >= 1. \
if not WIN32 and float(gsl_version[0]) >= 1. \
and (float(gsl_version[0]) >= 2. or float(gsl_version[1]) >= 14.) and \
not orbit_ext and not interppotential_ext and not single_ext:
actionAngle_c_incl= True
Expand Down Expand Up @@ -236,7 +246,7 @@
include_dirs=interppotential_include_dirs,
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args)
if float(gsl_version[0]) >= 1. \
if not WIN32 and float(gsl_version[0]) >= 1. \
and (float(gsl_version[0]) >= 2. or float(gsl_version[1]) >= 14.) \
and not orbit_ext and not actionAngle_ext and not single_ext:
interppotential_c_incl= True
Expand Down

0 comments on commit 6cbfe7f

Please sign in to comment.