forked from WISDEM/WEIS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert setup.py to exclude ROSCO build, etc.
- Loading branch information
Showing
1 changed file
with
23 additions
and
92 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,19 +20,9 @@ | |
import io | ||
import os | ||
import sys | ||
from shutil import rmtree, copy | ||
import glob | ||
import platform | ||
from setuptools import find_packages, setup, Command | ||
from numpy.distutils.command.build_ext import build_ext | ||
from numpy.distutils.core import setup, Extension | ||
from shutil import rmtree | ||
|
||
import multiprocessing as mp | ||
from distutils.core import run_setup | ||
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 | ||
from setuptools import find_packages, setup, Command | ||
|
||
# Package meta-data. | ||
NAME = 'rosco-toolbox' | ||
|
@@ -41,7 +31,7 @@ | |
EMAIL = '[email protected]' | ||
AUTHOR = 'NREL National Wind Technology Center' | ||
REQUIRES_PYTHON = '>=3.4' | ||
VERSION = '3.0.0' | ||
VERSION = '2.1.4' | ||
|
||
# These packages are required for all of the code to be executed. | ||
# - Maybe you can get away with older versions... | ||
|
@@ -62,64 +52,6 @@ | |
} | ||
} | ||
|
||
|
||
# For the CMake Extensions | ||
this_directory = os.path.abspath(os.path.dirname(__file__)) | ||
ncpus = mp.cpu_count() | ||
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') | ||
|
||
# Refresh build directory | ||
localdir = os.path.join(this_directory, 'ROSCO','install') | ||
os.makedirs(localdir, exist_ok=True) | ||
|
||
cmake_args = ['-DBUILD_SHARED_LIBS=OFF'] | ||
cmake_args += ['-DCMAKE_Fortran_FLAGS=-ffree-line-length-0'] | ||
|
||
if platform.system() == 'Windows': | ||
cmake_args += ['-DCMAKE_INSTALL_PREFIX={}'.format(localdir)] | ||
if self.compiler.compiler_type == 'msvc': | ||
cmake_args += ['-DCMAKE_GENERATOR_PLATFORM=x64'] | ||
else: | ||
cmake_args += ['-G', 'MinGW Makefiles'] | ||
cmake_args += ['-D', 'CMAKE_Fortran_COMPILER=gfortran'] | ||
|
||
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, '--target', 'install', '--config', 'Release']) | ||
|
||
else: | ||
super().build_extension(ext) | ||
|
||
|
||
# All of the extensions | ||
roscoExt = CMakeExtension('rosco','ROSCO') | ||
|
||
# The rest you shouldn't have to touch too much :) | ||
# ------------------------------------------------ | ||
# Except, perhaps the License and Trove Classifiers! | ||
|
@@ -181,25 +113,24 @@ def run(self): | |
sys.exit() | ||
|
||
|
||
|
||
metadata = dict( | ||
name = NAME, | ||
version = about['__version__'], | ||
description = DESCRIPTION, | ||
long_description = long_description, | ||
long_description_content_type = 'text/markdown', | ||
author = AUTHOR, | ||
author_email = EMAIL, | ||
url = URL, | ||
install_requires = REQUIRED, | ||
python_requires = REQUIRES_PYTHON, | ||
extras_require = EXTRAS, | ||
include_package_date = True, | ||
packages = find_packages(exclude=["tests", "*.tests", "*.tests.*", "tests.*"]), | ||
license = 'Apache License, Version 2.0', | ||
ext_modules = [roscoExt], | ||
cmdclass = {'build_ext': CMakeBuildExt, 'upload': UploadCommand}, | ||
zip_safe = False, | ||
# Where the magic happens: | ||
setup( | ||
name=NAME, | ||
version=about['__version__'], | ||
description=DESCRIPTION, | ||
long_description=long_description, | ||
long_description_content_type='text/markdown', | ||
author=AUTHOR, | ||
author_email=EMAIL, | ||
python_requires=REQUIRES_PYTHON, | ||
url=URL, | ||
packages=find_packages(exclude=["tests", "*.tests", "*.tests.*", "tests.*"]), | ||
install_requires=REQUIRED, | ||
extras_require=EXTRAS, | ||
include_package_data=True, | ||
license='Apache License, Version 2.0', | ||
|
||
cmdclass={ | ||
'upload': UploadCommand, | ||
}, | ||
) | ||
|
||
setup(**metadata) |