-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build in package dir with default gfortran
doc
- Loading branch information
Showing
15 changed files
with
98 additions
and
139 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
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[flake8] | ||
max-line-length = 132 | ||
exclude = .git,__pycache__,.eggs/,doc/,docs/,build/,dist/,archive/ |
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
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
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
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 |
---|---|---|
@@ -1,20 +1,15 @@ | ||
if(CMAKE_BUILD_TYPE STREQUAL Debug) | ||
add_compile_options(-g -O0) | ||
else() | ||
add_compile_options(-O3) | ||
endif() | ||
|
||
if(CMAKE_Fortran_COMPILER_ID STREQUAL GNU) | ||
list(APPEND FFLAGS -mtune=native -Wall)#-Wextra -Wpedantic) | ||
if(CMAKE_BUILD_TYPE STREQUAL Debug) | ||
list(APPEND FFLAGS -ffpe-trap=invalid,zero,overflow) | ||
endif() | ||
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL Intel) | ||
list(APPEND FFLAGS -warn) | ||
|
||
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL PGI) | ||
|
||
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL Flang) | ||
list(APPEND FFLAGS -Mallocatable=03) | ||
|
||
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL NAG) | ||
|
||
endif() |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
project('msise00', 'fortran', | ||
default_options : ['default_library=static', 'buildtype=release']) | ||
|
||
subdir('src') |
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
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 |
---|---|---|
@@ -1,70 +1,28 @@ | ||
""" | ||
A generic, clean way to build C/C++/Fortran code from setup.py or manually | ||
Michael Hirsch, Ph.D. | ||
https://www.scivision.dev | ||
""" | ||
import subprocess | ||
import shutil | ||
from pathlib import Path | ||
import subprocess | ||
import os | ||
from typing import List | ||
|
||
R = Path(__file__).resolve().parents[1] | ||
BINDIR = R / 'build' | ||
SRCDIR = R / 'src' | ||
R = Path(__file__).parent | ||
RS = R.parent / 'src' | ||
|
||
SOURCES = list(map(str, [RS/'nrlmsise00_sub.for', RS/'msise00_driver.f90'])) | ||
EXE_OPT = ['-o', str(R/'msise00_driver')] | ||
|
||
def build(): | ||
""" | ||
attempts build with Meson or CMake | ||
""" | ||
try: | ||
meson_setup() | ||
except (FileNotFoundError, RuntimeError): | ||
cmake_setup() | ||
|
||
|
||
def cmake_setup(): | ||
def build(sources: List[str] = SOURCES, | ||
compiler: str = 'gfortran', | ||
exe_opt: List[str] = EXE_OPT): | ||
""" | ||
attempt to build using CMake >= 3 | ||
Attempt to compile code instead of using setup.py | ||
""" | ||
cmake_exe = shutil.which('cmake') | ||
if not cmake_exe: | ||
raise FileNotFoundError('CMake not available') | ||
|
||
wopts = ['-G', 'MinGW Makefiles', '-DCMAKE_SH="CMAKE_SH-NOTFOUND'] if os.name == 'nt' else [] | ||
|
||
subprocess.check_call([cmake_exe] + wopts + [str(SRCDIR)], | ||
cwd=BINDIR) | ||
|
||
ret = subprocess.run([cmake_exe, '--build', str(BINDIR)], | ||
stderr=subprocess.PIPE, | ||
universal_newlines=True) | ||
|
||
result(ret) | ||
|
||
|
||
def meson_setup(): | ||
""" | ||
attempt to build with Meson + Ninja | ||
""" | ||
meson_exe = shutil.which('meson') | ||
ninja_exe = shutil.which('ninja') | ||
|
||
if not meson_exe or not ninja_exe: | ||
raise FileNotFoundError('Meson or Ninja not available') | ||
|
||
if not (BINDIR / 'build.ninja').is_file(): | ||
subprocess.check_call([meson_exe, str(SRCDIR)], cwd=BINDIR) | ||
|
||
ret = subprocess.run(ninja_exe, cwd=BINDIR, stderr=subprocess.PIPE, | ||
universal_newlines=True) | ||
if isinstance(sources, (str, Path)): | ||
sources = [sources] | ||
|
||
result(ret) | ||
fc = shutil.which(compiler) | ||
if not fc: | ||
raise FileNotFoundError(fc) | ||
|
||
sources = list(map(str, sources)) | ||
|
||
def result(ret: subprocess.CompletedProcess): | ||
if not ret.returncode: | ||
print('\nBuild Complete!') | ||
else: | ||
raise RuntimeError(ret.stderr) | ||
subprocess.check_call([str(fc)] + sources + EXE_OPT) |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[mypy] | ||
ignore_missing_imports = True | ||
strict_optional = False | ||
allow_redefinition = True | ||
show_error_context = False | ||
show_column_numbers = True |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.