Skip to content

Commit ce182af

Browse files
committed
explicit Windows/conda path lookup
1 parent 16908b9 commit ce182af

1 file changed

Lines changed: 36 additions & 20 deletions

File tree

setup.py

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,27 @@ def get_gsl_config():
123123
rv['library_dirs'] += [lib]
124124
return rv
125125

126+
def get_gsl_config_win():
127+
'''Return dictionary with paths to GSL library, windwows version.
128+
This version is installed with conda.
129+
'''
130+
conda_prefix = os.environ['CONDA_PREFIX']
131+
inc = os.path.join(conda_prefix, 'Library', 'include')
132+
lib = os.path.join(conda_prefix, 'Library', 'lib')
133+
rv = {'include_dirs': [], 'library_dirs': []}
134+
rv['include_dirs'] += [inc]
135+
rv['library_dirs'] += [lib]
136+
return rv
137+
126138
# ----------------------------------------------------------------------------
127139

128140
# compile and link options
129141
define_macros = []
130-
gcfg = get_gsl_config()
142+
os_name = os.name
143+
if os_name == 'nt':
144+
gcfg = get_gsl_config_win()
145+
else:
146+
gcfg = get_gsl_config()
131147
include_dirs = [MYDIR] + gcfg['include_dirs']
132148
library_dirs = []
133149
libraries = []
@@ -147,25 +163,25 @@ def get_gsl_config():
147163
library_dirs += gcfg['library_dirs']
148164
# add optimization flags for other compilers if needed
149165

150-
print("INCLUDE DIR = {!r}".format(include_dirs))
151-
print("LIBRARY DIR = {!r}".format(library_dirs))
152-
import glob
153-
154-
pattern = 'gsl*.*'
155-
156-
library_dir = library_dirs[0]
157-
matching_files = glob.glob(library_dir + '/' + pattern)
158-
if len(matching_files) != 0:
159-
print("GSL LIBRARY FOUND in {!r}".format(matching_files[0]))
160-
161-
print("----- CONDA -----")
162-
library_dir = "C:\\Miniconda"
163-
matching_files = glob.glob(library_dir + '\\' + pattern)
164-
if len(matching_files) != 0:
165-
for f in matching_files:
166-
print(f)
167-
# print("GSL LIBRARY FOUND in {!r}".format(matching_files[0]))
168-
print("----- CONDA END -----")
166+
# print("INCLUDE DIR = {!r}".format(include_dirs))
167+
# print("LIBRARY DIR = {!r}".format(library_dirs))
168+
# import glob
169+
170+
# pattern = 'gsl*.*'
171+
172+
# library_dir = library_dirs[0]
173+
# matching_files = glob.glob(library_dir + '/' + pattern)
174+
# if len(matching_files) != 0:
175+
# print("GSL LIBRARY FOUND in {!r}".format(matching_files[0]))
176+
177+
# print("----- CONDA -----")
178+
# library_dir = "C:\\Miniconda"
179+
# matching_files = glob.glob(library_dir + '\\' + pattern)
180+
# if len(matching_files) != 0:
181+
# for f in matching_files:
182+
# print(f)
183+
# # print("GSL LIBRARY FOUND in {!r}".format(matching_files[0]))
184+
# print("----- CONDA END -----")
169185

170186
# define extension here
171187
pdffit2module = Extension('diffpy.pdffit2.pdffit2', [

0 commit comments

Comments
 (0)