From ae09c20720dd242b1c2756839b0503bcf541becb Mon Sep 17 00:00:00 2001 From: "Michael Hirsch, Ph.D" Date: Wed, 3 Jul 2019 00:11:57 -0400 Subject: [PATCH] use setup.cfg for metadata, build sami2py.x without Make future print_function py27 no shutil.which() --- .flake8 | 3 +++ .gitignore | 2 ++ mypy.ini | 6 ++++++ setup.cfg | 37 ++++++++++++++++++++++++++++++++++++ setup.py | 55 ++++++++++++++++++++---------------------------------- 5 files changed, 68 insertions(+), 35 deletions(-) create mode 100644 .flake8 create mode 100644 mypy.ini create mode 100644 setup.cfg diff --git a/.flake8 b/.flake8 new file mode 100644 index 00000000..aab5c9ec --- /dev/null +++ b/.flake8 @@ -0,0 +1,3 @@ +[flake8] +max-line-length = 132 +exclude = .git,__pycache__,.eggs/,doc/,docs/,build/,dist/,archive/ diff --git a/.gitignore b/.gitignore index c1342a80..f50f546d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +.mypy_cache/ + # Fortran modules and executables *.o *.x diff --git a/mypy.ini b/mypy.ini new file mode 100644 index 00000000..5457c7e7 --- /dev/null +++ b/mypy.ini @@ -0,0 +1,6 @@ +[mypy] +ignore_missing_imports = True +strict_optional = False +allow_redefinition = True +show_error_context = False +show_column_numbers = True \ No newline at end of file diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..cacffd51 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,37 @@ +[metadata] +name = sami2py +version = 0.1.2 +url = https://github.com/jklenzing/sami2py +author = Jeff Klenzing +author_email = jeffrey.klenzing@nasa.gov +description = Generate, read, and plot SAMI2 model runs +keywords = + SAMI2 + ionosphere +classifiers = + Development Status :: 3 - Alpha + Topic :: Scientific/Engineering :: Physics + Intended Audience :: Science/Research + License :: BSD + Natural Language :: English + Programming Language :: Python :: 2.7 + Programming Language :: Python :: 3.4 + Programming Language :: Python :: 3.5 + Programming Language :: Python :: 3.6 + Programming Language :: Python :: 3.7 + Operating System :: OS Independent +license_file = License.md +long_description = file: README.md +long_description_content_type = text/markdown + +[options] +python_requires = >= 2.7 +setup_requires = + setuptools >= 38.6 + pip >= 10 +include_package_data = True +zip_safe = False +packages = find: +install_requires = + numpy +scripts = diff --git a/setup.py b/setup.py index f2ec3bb5..d7e927bc 100644 --- a/setup.py +++ b/setup.py @@ -4,15 +4,11 @@ # Full license can be found in License.md # ----------------------------------------------------------------------------- +from __future__ import print_function import sys from os import path, mkdir -from setuptools import setup, find_packages - - -# Define a read function for using README for long_description -def read(fname): - return open(path.join(path.dirname(__file__), fname)).read() - +from setuptools import setup +import subprocess # generate path for fortran model files here = path.abspath(path.dirname(__file__)) @@ -20,9 +16,22 @@ def read(fname): test_data_path = path.join(here, 'sami2py', 'tests', 'test_data') file_path = path.join(sys.prefix, '.sami2py') -if not path.isfile(fortran_path + '/sami2py.x'): - print('\n'.join(['\nYou will need to compile the fortran files. Try', - '$ make -C sami2py/fortran compile\n'])) +# %% build + + +if not path.isfile(path.join(fortran_path, 'sami2py.x')): + try: # py27 does not have shutil.which() + cmd = ['gfortran', '-fno-range-check', '-fno-automatic', '-ffixed-line-length-none', + '-o', 'sami2py.x'] + src = ['nrlmsise00_modified.f', 'grid-1.00.f', 'sami2py-1.00.f', 'hwm93.f', 'hwm07e_modified.f90', + 'apexcord.f90', 'hwm14.f90'] + subprocess.call(cmd + src, cwd=fortran_path) + except OSError: + pass + +if not path.isfile(path.join(fortran_path, 'sami2py.x')): + print('\nYou will need to compile the fortran files. Try\n' + '$ make -C sami2py/fortran compile\n', file=sys.stderr) if not path.isdir(file_path): mkdir(file_path) @@ -46,28 +55,4 @@ def read(fname): # Run setup -setup(name='sami2py', - version='0.1.2', - url='github.com/jklenzing/sami2py', - author='Jeff Klenzing', - author_email='jeffrey.klenzing@nasa.gov', - description='Generate, read, and plot sami2 model runs', - long_description=read('README.md'), - packages=find_packages(), - classifiers=[ - "Development Status :: 3 - Alpha", - "Topic :: Scientific/Engineering :: Physics", - "Intended Audience :: Science/Research", - "License :: BSD", - "Natural Language :: English", - "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3.4", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Operating System :: MacOS :: MacOS X", - ], - include_package_data=True, - zip_safe=False, - test_suite='setup.sami2py_test_suite', - ) +setup(test_suite='setup.sami2py_test_suite')