diff --git a/Makefile b/Makefile deleted file mode 100644 index cc332ce..0000000 --- a/Makefile +++ /dev/null @@ -1,11 +0,0 @@ - -install-gfortran: - sudo apt-get update -y - sudo apt-get -y install gfortran - -install: - pip install coveralls numpy - pip install -e . - -test: - coverage run --source=. --module unittest discover --start-directory tests --verbose diff --git a/README.rst b/README.rst index d3b87ea..7a7173e 100644 --- a/README.rst +++ b/README.rst @@ -20,13 +20,13 @@ From Source Code Currently supports Python 3.10 under Ubuntu 20.04 (see Github Actions). -IMPORTANT: For support in other Python versions and/or OS, users are invited to work on the case and submmit a PR. Help making the project more generic! +IMPORTANT: For support in other Python versions and/or OS, users are invited to work on the case and submit a PR. Help making the project more generic! .. code-block:: bash $ git clone https://github.com/rilma/pyHWM14.git $ cd pyHWM14 - $ make install + $ pip install . --------- From PyPi diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..c6096dc --- /dev/null +++ b/meson.build @@ -0,0 +1,44 @@ +project('pyhwm14', 'c', + version : '0.1', + license: 'BSD-3', + meson_version: '>=0.64.0', + default_options : ['warning_level=2'], +) + +add_languages('fortran') + +py_mod = import('python') +py = py_mod.find_installation(pure: false) +py_dep = py.dependency() + +incdir_numpy = run_command(py, + ['-c', 'import os; os.chdir(".."); import numpy; print(numpy.get_include())'], + check : true +).stdout().strip() + +incdir_f2py = run_command(py, + ['-c', 'import os; os.chdir(".."); import numpy.f2py; print(numpy.f2py.get_include())'], + check : true +).stdout().strip() + +inc_np = include_directories(incdir_numpy, incdir_f2py) + +source_dir = 'source/' + +hwm14_source = custom_target('hwm14module.c', + input : [source_dir / 'hwm14.f90'], + output : ['hwm14module.c', 'hwm14-f2pywrappers.f', 'hwm14-f2pywrappers2.f90'], # mind the .f90 wrapper! + command : [py, '-m', 'numpy.f2py', '@INPUT@', '-m', 'hwm14'] +) + +py.extension_module('hwm14', + [source_dir / 'hwm14.f90', hwm14_source], + incdir_f2py / 'fortranobject.c', + include_directories: inc_np, + dependencies : py_dep, + install : true +) + +py_dir = 'pyhwm2014' + +subdir(py_dir) diff --git a/pyhwm2014/__init__.py b/pyhwm2014/__init__.py index f91dbb1..b41eff2 100644 --- a/pyhwm2014/__init__.py +++ b/pyhwm2014/__init__.py @@ -4,7 +4,7 @@ except (ImportError,AttributeError): # Python < 3.5 from pathlib2 import Path # -from . import hwm14 +import hwm14 import logging from numpy import append, arange, ceil, floor, meshgrid, ones,reshape try: diff --git a/pyhwm2014/meson.build b/pyhwm2014/meson.build new file mode 100644 index 0000000..65ec4b8 --- /dev/null +++ b/pyhwm2014/meson.build @@ -0,0 +1,23 @@ +# Install python sources + +python_sources = ['__init__.py'] + +py.install_sources( + python_sources, + subdir: 'pyhwm2014' +) + +# Install additional data sources + +data_dir = 'data/' +install_dir = py.get_install_dir() / 'pyhwm2014' + +data_sources = files( + data_dir / 'dwm07b104i.dat', + data_dir / 'gd2qd.dat', + data_dir / 'hwm123114.bin') + +install_data( + data_sources, + install_dir: install_dir / 'data' +) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..3184344 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,11 @@ +[build-system] +requires = ["meson", "meson-python", "numpy"] +build-backend = "mesonpy" + +[project] +name = "pyhwm2014" +version = "0.1.0" +description = "Python wrapper for HWM14." +readme = "README.rst" +requires-python = ">=3.12" +dependencies = ["numpy", "seaborn"] diff --git a/setup.py b/setup.py deleted file mode 100644 index 334721b..0000000 --- a/setup.py +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env python -req = ['nose','numpy','pathlib2', - 'timeutil'] -# %% -from setuptools import find_packages -from numpy.distutils.core import Extension, setup -from glob import glob -from os.path import join - -name = 'pyhwm2014' - -ext = Extension( extra_compile_args=['-w'], - extra_f90_compile_args=['-w'], - f2py_options=[ '--quiet' ], - name='hwm14', - sources=['source/hwm14.f90'] - ) - -hwmData1 = glob(join('data', '*.dat')) -hwmData2 = glob(join('data', '*.bin')) -hwmDataFiles = [(join(name, 'data'), hwmData1), - (join(name, 'data'), hwmData2)] - -setup( author=['Ronald Ilma'], - data_files=hwmDataFiles, - description='HWM14 neutral winds model', - ext_modules=[ ext ], - ext_package=name, - name=name, - packages=find_packages(), - url='https://github.com/rilma/pyHWM14', - version='1.1.0', - install_requires=req, - extras_requires={'plot':['matplotlib','seaborn']}, - dependency_links=[ - 'https://github.com/rilma/TimeUtilities/zipball/master#egg=timeutil-999.0'], - classifiers=[ - 'Intended Audience :: Science/Research', - 'Development Status :: 5 - Production/Stable', - 'License :: OSI Approved :: MIT License', - 'Topic :: Scientific/Engineering :: Atmospheric Science', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - ], - python_requires='>=3.10', -)