Created
March 30, 2020 17:34
Star
You must be signed in to star a gist
pyOptSparse SNOPT precompiled library setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# This is a modified version of pyoptsparse/pyoptsparse/pySNOPT/setup.py | |
# The modifications allow the user to use pyOpt with SNOPT precompiled libraries. | |
# | |
# Instructions: | |
# 1. Replace pyoptsparse/pyoptsparse/pySNOPT/setup.py with this file. | |
# 2. Modify line 39 so that snopt7_path is the actual path to the location of the | |
# precompiled SNOPT library (libsnopt7.*). | |
# 3. Make sure to add the location of the library to DYLD_LIBRARY_PATH (for macOS) | |
# or LD_LIBRARY_PATH (for Linux). | |
# 4. Build/install pyOptSparse as instructed. | |
# | |
# Elizabeth Wong (elwong@ucsd.edu) | |
# 30 March 2020 | |
# | |
import os,sys | |
def configuration(parent_package='',top_path=None): | |
from numpy.distutils.misc_util import Configuration | |
config = Configuration('pySNOPT', parent_package, top_path) | |
config.add_data_files('LICENSE','README') | |
# Since snopt has a bunch of source files, we will just check if | |
# snoptc.c exists. If so, we will assume all the rest of the files | |
# are present. | |
#snoptc = os.path.join('pyoptsparse/pySNOPT/source', 'snoptc.f') | |
#if os.path.exists(snoptc): | |
# config.add_library('snopt', sources=[os.path.join('source', '*.f')]) | |
# config.add_extension('snopt', sources=['source/f2py/snopt.pyf'], | |
# libraries=['snopt']) | |
# Edit SNOPT7 library path: | |
snopt7_path= '/path/to/SNOPT/library' | |
if os.path.exists(snopt7_path): | |
config.add_extension('snopt', | |
sources=['source/f2py/snopt.pyf', | |
os.path.join('source', '*.f')], | |
library_dirs=snopt7_path, | |
libraries=['snopt7']) | |
return config |
What environment in windows are you using? I think in theory, this will work if you're in mingw/cygwin (64-bit), it should work. I can investigate if you can give me more details on your environment.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Did you test it in Windows 10? I am trying to set up SNOPT ddl and lib in pyOptSparse by using this script but it fails the "python setup.py install" command. If you have suggestions on how to set up SNOPT dll in Windows for Python 3 they are more than welcome! Thanks!