Spaces:
Sleeping
Sleeping
| #!/usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| """ | |
| TSU-WAVE: Tsunami Spectral Understanding of Wave-Amplitude Variance and Energy | |
| A physics-based framework for real-time tsunami analysis and coastal inundation forecasting | |
| """ | |
| import os | |
| import sys | |
| from setuptools import setup, find_packages | |
| from setuptools.command.build_ext import build_ext | |
| import subprocess | |
| import numpy as np | |
| class FortranBuildExt(build_ext): | |
| """Custom build command to compile Fortran NSWE solver""" | |
| def run(self): | |
| # Compile Fortran code with f2py | |
| fortran_file = os.path.join('src', 'core', 'nswe_solver.f90') | |
| target_dir = os.path.join('src', 'tsuwave', 'core') | |
| os.makedirs(target_dir, exist_ok=True) | |
| # Run f2py to compile Fortran code | |
| cmd = [ | |
| 'f2py', '-c', fortran_file, | |
| '-m', 'nswe_solver', | |
| '--build-dir', target_dir | |
| ] | |
| try: | |
| subprocess.check_call(cmd) | |
| print("✓ NSWE solver compiled successfully") | |
| except subprocess.CalledProcessError as e: | |
| print(f"⚠ Warning: NSWE solver compilation failed: {e}") | |
| print("The package will install but Fortran components won't be available") | |
| except FileNotFoundError: | |
| print("⚠ Warning: f2py not found. Install numpy for Fortran support") | |
| # Continue with normal build | |
| super().run() | |
| # Read requirements | |
| with open('requirements.txt') as f: | |
| requirements = [line.strip() for line in f if line.strip() and not line.startswith('#')] | |
| # Read long description from README | |
| with open('README.md', encoding='utf-8') as f: | |
| long_description = f.read() | |
| setup( | |
| name='tsu-wave', | |
| version='1.0.0', | |
| description='TSU-WAVE: Real-time tsunami analysis and coastal inundation forecasting', | |
| long_description=long_description, | |
| long_description_content_type='text/markdown', | |
| author='Samir Baladi', | |
| author_email='gitdeeper@gmail.com', | |
| maintainer='Samir Baladi', | |
| maintainer_email='gitdeeper@gmail.com', | |
| url='https://gitlab.com/gitdeeper4/tsu-wave', | |
| project_urls={ | |
| 'Documentation': 'https://tsu-wave.netlify.app/documentation', | |
| 'Source': 'https://gitlab.com/gitdeeper4/tsu-wave', | |
| 'Tracker': 'https://gitlab.com/gitdeeper4/tsu-wave/-/issues', | |
| 'DOI': 'https://doi.org/10.5281/zenodo.XXXXXXXX', | |
| }, | |
| license='MIT', | |
| classifiers=[ | |
| 'Development Status :: 5 - Production/Stable', | |
| 'Intended Audience :: Science/Research', | |
| 'Intended Audience :: Education', | |
| 'License :: OSI Approved :: MIT License', | |
| 'Programming Language :: Python :: 3', | |
| 'Programming Language :: Python :: 3.10', | |
| 'Programming Language :: Python :: 3.11', | |
| 'Programming Language :: Fortran', | |
| 'Topic :: Scientific/Engineering', | |
| 'Topic :: Scientific/Engineering :: Physics', | |
| 'Topic :: Scientific/Engineering :: Oceanography', | |
| 'Natural Language :: English', | |
| 'Operating System :: OS Independent', | |
| ], | |
| keywords=[ | |
| 'tsunami', 'hydrodynamics', 'wave-propagation', 'coastal-inundation', | |
| 'early-warning', 'NSWE', 'bathymetry', 'spectral-analysis', | |
| 'vorticity', 'oceanography', 'geophysics', 'natural-hazards' | |
| ], | |
| python_requires='>=3.10', | |
| install_requires=requirements, | |
| extras_require={ | |
| 'dev': [ | |
| 'pytest>=7.4.0', | |
| 'pytest-asyncio>=0.21.0', | |
| 'pytest-cov>=4.1.0', | |
| 'httpx>=0.25.0', | |
| 'black>=23.11.0', | |
| 'isort>=5.12.0', | |
| 'flake8>=6.1.0', | |
| 'mypy>=1.7.0', | |
| 'mkdocs>=1.5.0', | |
| 'mkdocs-material>=9.4.0', | |
| 'jupyter>=1.0.0', | |
| ], | |
| 'docs': [ | |
| 'mkdocs>=1.5.0', | |
| 'mkdocs-material>=9.4.0', | |
| 'mkdocstrings>=0.24.0', | |
| ], | |
| }, | |
| packages=find_packages('src'), | |
| package_dir={'': 'src'}, | |
| include_package_data=True, | |
| package_data={ | |
| 'tsuwave': [ | |
| 'data/bathymetry/*.nc', | |
| 'data/becf_precomputed/*.json', | |
| 'data/validation_events/*/*', | |
| 'core/*.f90', | |
| ], | |
| }, | |
| entry_points={ | |
| 'console_scripts': [ | |
| 'tsu-wave=tsuwave.cli:main', | |
| 'tsu-wave-monitor=tsuwave.cli:monitor', | |
| 'tsu-wave-validate=tsuwave.cli:validate', | |
| 'tsu-wave-forecast=tsuwave.cli:forecast', | |
| ], | |
| }, | |
| cmdclass={ | |
| 'build_ext': FortranBuildExt, | |
| }, | |
| zip_safe=False, | |
| # Fortran extension metadata | |
| ext_modules=[ | |
| { | |
| 'name': 'nswe_solver', | |
| 'sources': ['src/core/nswe_solver.f90'], | |
| 'language': 'fortran', | |
| } | |
| ], | |
| # Include numpy headers for f2py | |
| include_dirs=[np.get_include()], | |
| # Metadata | |
| platforms=['any'], | |
| # Validation data | |
| data_files=[ | |
| ('share/tsu-wave/bathymetry', ['data/bathymetry/etopo1_pacific.nc']), | |
| ('share/tsu-wave/becf_maps', ['data/becf_precomputed/pacific_bays.json']), | |
| ], | |
| ) | |
| print("\n" + "="*50) | |
| print("TSU-WAVE v1.0.0 installation complete!") | |
| print("="*50) | |
| print("\nDocumentation: https://tsu-wave.netlify.app/documentation") | |
| print("Repository: https://gitlab.com/gitdeeper4/tsu-wave") | |
| print("\nTo verify installation:") | |
| print(" python -c \"import tsuwave; print(tsuwave.__version__)\"") | |
| print("="*50) | |