Skip to content

Commit

Permalink
working setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
gbarter committed Aug 21, 2020
1 parent c86d62a commit 089bd84
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 34 deletions.
12 changes: 0 additions & 12 deletions install.py

This file was deleted.

129 changes: 107 additions & 22 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,92 @@
from setuptools import setup, find_packages
from distutils import util

from os import path
import os
import sys
import platform
import glob
import multiprocessing
from setuptools import find_packages
from numpy.distutils.command.build_ext import build_ext
from numpy.distutils.core import setup, Extension
from io import open

this_directory = path.abspath(path.dirname(__file__))
with open(path.join(this_directory, "README.md"), encoding="utf-8") as f:
# Global constants
ncpus = multiprocessing.cpu_count()
os.environ['NPY_DISTUTILS_APPEND_FLAGS'] = '1'
this_directory = os.path.abspath(os.path.dirname(__file__))

# For the CMake Extensions
class CMakeExtension(Extension):

def __init__(self, name, sourcedir='', **kwa):
Extension.__init__(self, name, sources=[], **kwa)
self.sourcedir = os.path.abspath(sourcedir)

class CMakeBuildExt(build_ext):

def copy_extensions_to_source(self):
newext = []
for ext in self.extensions:
if isinstance(ext, CMakeExtension): continue
newext.append( ext )
self.extensions = newext
super().copy_extensions_to_source()

def build_extension(self, ext):
if isinstance(ext, CMakeExtension):
# Ensure that CMake is present and working
try:
self.spawn(['cmake', '--version'])
except OSError:
raise RuntimeError('Cannot find CMake executable')

localdir = os.path.join(this_directory, 'local')

cmake_args = ['-DBUILD_SHARED_LIBS=ON',
'-DCMAKE_INSTALL_PREFIX=' + localdir]

self.build_temp += '_'+ext.name
os.makedirs(localdir, exist_ok=True)
# Need fresh build directory for CMake
os.makedirs(self.build_temp, exist_ok=True)

self.spawn(['cmake', '-S', ext.sourcedir, '-B', self.build_temp] + cmake_args)
self.spawn(['cmake', '--build', self.build_temp, '-j', str(ncpus), '--target', 'install', '--config', 'Release'])

else:
super().build_extension(ext)


# All of the extensions
fastExt = CMakeExtension('openfast','OpenFAST')
roscoExt = CMakeExtension('rosco','ROSCO')
bemExt = Extension('wisdem.ccblade._bem',
sources=[os.path.join('WISDEM','wisdem','ccblade','src','bem.f90')],
extra_compile_args=['-O2','-fPIC'])
pyframeExt = Extension('wisdem.pyframe3dd._pyframe3dd',
sources=glob.glob(os.path.join('WISDEM','wisdem','pyframe3dd','src','*.c')) )
precompExt = Extension('wisdem.rotorse._precomp',
sources=[os.path.join('WISDEM','wisdem','rotorse','PreCompPy.f90')],
extra_compile_args=['-O2','-fPIC'])

if platform.system() == 'Windows': # For Anaconda
pymapArgs = ['-O1', '-m64', '-fPIC', '-std=c99','-DCMINPACK_NO_DLL']
elif sys.platform == 'cygwin':
pymapArgs = ['-O1', '-m64', '-fPIC', '-std=c99']
elif platform.system() == 'Darwin':
pymapArgs = ['-O1', '-m64', '-fno-omit-frame-pointer', '-fPIC']
else:
pymapArgs = ['-O1', '-m64', '-fPIC', '-std=c99']

pymapExt = Extension('wisdem.pymap._libmap',
sources = (glob.glob(os.path.join('WISDEM','wisdem','pymap','**','*.c'), recursive=True) +
glob.glob(os.path.join('WISDEM','wisdem','pymap','**','*.cc'), recursive=True)),
extra_compile_args=pymapArgs,
include_dirs=[os.path.join('WISDEM','wisdem','include','lapack')])

# Setup content
with open(os.path.join(this_directory, 'README.md'), encoding='utf-8') as f:
long_description = f.read()

CLASSIFIERS = """
CLASSIFIERS = '''
Development Status :: 1 - Planning
Intended Audience :: Science/Research
Intended Audience :: Developers
Expand All @@ -19,22 +97,29 @@
Operating System :: Microsoft :: Windows
Operating System :: Unix
Operating System :: MacOS
"""
'''

weis_pkgs = find_packages()
wisdem_pkgs = find_packages(where='WISDEM',exclude=['docs', 'tests', 'ext'])
roscotools_pkgs = find_packages(where='ROSCO_Toolbox')

metadata = dict(
name="WEIS",
version="0.0.1",
description="Wind Energy with Integrated Servo-control",
long_description=long_description,
long_description_content_type="text/markdown",
author="NREL",
classifiers=[_f for _f in CLASSIFIERS.split("\n") if _f],
package_dir = {
"weis" : "weis",
},
packages=["weis"],
python_requires=">=3.6",
zip_safe=True,
name = 'WEIS',
version = '0.0.1',
description = 'Wind Energy with Integrated Servo-control',
long_description = long_description,
long_description_content_type = 'text/markdown',
author = 'NREL',
url = 'https://github.com/WISDEM/WEIS',
install_requires = ['openmdao>=3.0','numpy','scipy','pandas','simpy','marmot-agents'],
classifiers = [_f for _f in CLASSIFIERS.split('\n') if _f],
package_dir = {'wisdem':'WISDEM/wisdem','rosco_toolbox':'ROSCO_toolbox/ROSCO_toolbox'},
packages = weis_pkgs + wisdem_pkgs + roscotools_pkgs,
python_requires = '>=3.6',
license = 'Apache License, Version 2.0',
ext_modules = [bemExt, pyframeExt, precompExt, pymapExt, roscoExt, fastExt],
cmdclass = {'build_ext': CMakeBuildExt},
zip_safe = False,
)

setup(**metadata)
setup(**metadata)

0 comments on commit 089bd84

Please sign in to comment.