Skip to content

Commit

Permalink
Fix ROSCO compiling bugs on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhar-abbas committed Nov 13, 2020
1 parent 0f5a8df commit 45ceb01
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
from numpy.distutils.command.build_ext import build_ext
from numpy.distutils.core import setup, Extension

import multiprocessing
from distutils.core import run_setup
from setuptools import find_packages
from numpy.distutils.command.build_ext import build_ext
Expand Down Expand Up @@ -65,7 +64,6 @@

# For the CMake Extensions
this_directory = os.path.abspath(os.path.dirname(__file__))

class CMakeExtension(Extension):

def __init__(self, name, sourcedir='', **kwa):
Expand All @@ -91,29 +89,27 @@ def build_extension(self, ext):
raise RuntimeError('Cannot find CMake executable')

# Refresh build directory
localdir = os.path.join(this_directory, 'ROSCO','build')
localdir = os.path.join(this_directory, 'ROSCO','install')
os.makedirs(localdir, exist_ok=True)

# Build
self.spawn(['cmake', '-S', ext.sourcedir, '-B', localdir])
self.spawn(['cmake', '--build', localdir])

cmake_args = ['-DBUILD_SHARED_LIBS=OFF']
cmake_args += ['-DCMAKE_Fortran_FLAGS=-ffree-line-length-0']

if platform.system() == 'Windows':
cmake_args += ['-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE']

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, '-j', str(ncpus), '--target', 'install', '--config', 'Release'])
self.spawn(['cmake', '--build', self.build_temp, '--target', 'install', '--config', 'Release'])

else:
super().build_extension(ext)
Expand Down Expand Up @@ -185,7 +181,7 @@ def run(self):


metadata = dict(
name = 'NAME',
name = NAME,
version = about['__version__'],
description = DESCRIPTION,
long_description = long_description,
Expand Down

0 comments on commit 45ceb01

Please sign in to comment.