diff --git a/openmc/__init__.py b/openmc/__init__.py index 17b0abe2f69..eaaf9ed027a 100644 --- a/openmc/__init__.py +++ b/openmc/__init__.py @@ -1,3 +1,4 @@ +import importlib.metadata from openmc.arithmetic import * from openmc.bounding_box import * from openmc.cell import * @@ -39,4 +40,5 @@ from openmc.model import Model -__version__ = '0.14.1-dev' + +__version__ = importlib.metadata.version("openmc") diff --git a/pyproject.toml b/pyproject.toml index d5970617a74..556ee62ee3c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,2 +1,75 @@ [build-system] requires = ["setuptools", "wheel", "numpy", "cython"] + +[project] +name = "openmc" +authors = [ + {name = "The OpenMC Development Team", email = "openmc@anl.gov"}, +] +description = "OpenMC" +version = "0.14.1-dev" +requires-python = ">=3.8" +license = {file = "LICENSE"} +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "Intended Audience :: End Users/Desktop", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: MIT License", + "Natural Language :: English", + "Topic :: Scientific/Engineering", + "Programming Language :: C++", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", +] +dependencies = [ + "numpy>=1.9", + "h5py", + "scipy", + "ipython", + "matplotlib", + "pandas", + "lxml", + "uncertainties", +] + +[project.optional-dependencies] +depletion-mpi = ["mpi4py"] +docs = [ + "sphinx", + "sphinxcontrib-katex", + "sphinx-numfig", + "jupyter", + "sphinxcontrib-svg2pdfconverter", + "sphinx-rtd-theme" +] +test = ["pytest", "pytest-cov", "colorama"] +vtk = ["vtk"] + +[project.urls] +Homepage = "https://openmc.org" +Documentation = "https://docs.openmc.org" +Repository = "https://github.com/openmc-dev/openmc" +Issues = "https://github.com/openmc-dev/openmc/issues" + +[tool.setuptools.packages.find] +include = ['openmc*', 'scripts*'] +exclude = ['tests*'] + +[tool.setuptools.package-data] +"openmc.data.effective_dose" = ["*.csv"] +"openmc.data" = ["*.txt", "*.DAT", "*.json", "*.h5"] + +[project.scripts] +openmc-ace-to-hdf5 = "scripts.openmc_ace_to_hdf5:main" +openmc-plot-mesh-tally = "scripts.openmc_plot_mesh_tally:main" +openmc-track-combine = "scripts.openmc_track_combine:main" +openmc-track-to-vtk = "scripts.openmc_track_to_vtk:main" +openmc-update-inputs = "scripts.openmc_update_inputs:main" +openmc-update-mgxs = "scripts.openmc_update_mgxs:main" +openmc-voxel-to-vtk = "scripts.openmc_voxel_to_vtk:main" diff --git a/scripts/openmc-ace-to-hdf5 b/scripts/openmc_ace_to_hdf5.py similarity index 73% rename from scripts/openmc-ace-to-hdf5 rename to scripts/openmc_ace_to_hdf5.py index 66ae7e2a948..3b76b73b2ac 100755 --- a/scripts/openmc-ace-to-hdf5 +++ b/scripts/openmc_ace_to_hdf5.py @@ -28,7 +28,52 @@ from openmc.data.ace import TableType -def ace_to_hdf5(destination, xsdir, xsdata, libraries, metastable, libver): +class CustomFormatter( + argparse.ArgumentDefaultsHelpFormatter, argparse.RawDescriptionHelpFormatter +): + pass + +parser = argparse.ArgumentParser( + description=__doc__, formatter_class=CustomFormatter +) +parser.add_argument("libraries", nargs="*", help="ACE libraries to convert to HDF5") +parser.add_argument( + "-d", + "--destination", + type=Path, + default=Path.cwd(), + help="Directory to create new library in", +) +parser.add_argument( + "-m", + "--metastable", + choices=["mcnp", "nndc"], + default="nndc", + help="How to interpret ZAIDs for metastable nuclides", +) +parser.add_argument("--xsdir", help="MCNP xsdir file that lists " "ACE libraries") +parser.add_argument( + "--xsdata", help="Serpent xsdata file that lists " "ACE libraries" +) +parser.add_argument( + "--libver", + choices=["earliest", "latest"], + default="earliest", + help="Output HDF5 versioning. Use " + "'earliest' for backwards compatibility or 'latest' " + "for performance", +) +args = parser.parse_args() + + +def main(): + + destination=args.destination + xsdir=args.xsdir + xsdata=args.xsdata + libraries=args.libraries + metastable=args.metastable + libver=args.libver if not destination.is_dir(): destination.mkdir(parents=True, exist_ok=True) @@ -109,48 +154,4 @@ def ace_to_hdf5(destination, xsdir, xsdata, libraries, metastable, libver): if __name__ == "__main__": - class CustomFormatter( - argparse.ArgumentDefaultsHelpFormatter, argparse.RawDescriptionHelpFormatter - ): - pass - - parser = argparse.ArgumentParser( - description=__doc__, formatter_class=CustomFormatter - ) - parser.add_argument("libraries", nargs="*", help="ACE libraries to convert to HDF5") - parser.add_argument( - "-d", - "--destination", - type=Path, - default=Path.cwd(), - help="Directory to create new library in", - ) - parser.add_argument( - "-m", - "--metastable", - choices=["mcnp", "nndc"], - default="nndc", - help="How to interpret ZAIDs for metastable nuclides", - ) - parser.add_argument("--xsdir", help="MCNP xsdir file that lists " "ACE libraries") - parser.add_argument( - "--xsdata", help="Serpent xsdata file that lists " "ACE libraries" - ) - parser.add_argument( - "--libver", - choices=["earliest", "latest"], - default="earliest", - help="Output HDF5 versioning. Use " - "'earliest' for backwards compatibility or 'latest' " - "for performance", - ) - args = parser.parse_args() - - ace_to_hdf5( - destination=args.destination, - xsdir=args.xsdir, - xsdata=args.xsdata, - libraries=args.libraries, - metastable=args.metastable, - libver=args.libver, - ) + main() diff --git a/scripts/openmc-plot-mesh-tally b/scripts/openmc_pot_mesh_tally.py similarity index 99% rename from scripts/openmc-plot-mesh-tally rename to scripts/openmc_pot_mesh_tally.py index 2a4fcd74341..185f1b184a0 100755 --- a/scripts/openmc-plot-mesh-tally +++ b/scripts/openmc_pot_mesh_tally.py @@ -316,7 +316,7 @@ def get_file_data(self, filename): sys.exit(1) -if __name__ == '__main__': +def main(): parser = argparse.ArgumentParser() parser.add_argument('statepoint', nargs='?', help='Statepoint file') args = parser.parse_args() @@ -342,3 +342,6 @@ def get_file_data(self, filename): app = MeshPlotter(root, filename) root.deiconify() root.mainloop() + +if __name__ == '__main__': + main() diff --git a/scripts/openmc-track-combine b/scripts/openmc_track_combine.py similarity index 100% rename from scripts/openmc-track-combine rename to scripts/openmc_track_combine.py diff --git a/scripts/openmc-track-to-vtk b/scripts/openmc_track_to_vtk.py similarity index 100% rename from scripts/openmc-track-to-vtk rename to scripts/openmc_track_to_vtk.py diff --git a/scripts/openmc-update-inputs b/scripts/openmc_update_inputs.py similarity index 99% rename from scripts/openmc-update-inputs rename to scripts/openmc_update_inputs.py index 2d49c0626e2..41234473ab4 100755 --- a/scripts/openmc-update-inputs +++ b/scripts/openmc_update_inputs.py @@ -277,8 +277,7 @@ def update_materials(root): return was_updated - -if __name__ == '__main__': +def main(): args = parse_args() for fname in args.input: # Parse the XML data. @@ -297,3 +296,6 @@ def update_materials(root): # Write a new geometry file. tree.write(fname, xml_declaration=True) + +if __name__ == '__main__': + main() diff --git a/scripts/openmc-update-mgxs b/scripts/openmc_update_mgxs.py similarity index 100% rename from scripts/openmc-update-mgxs rename to scripts/openmc_update_mgxs.py diff --git a/scripts/openmc-voxel-to-vtk b/scripts/openmc_voxel_to_vtk.py similarity index 96% rename from scripts/openmc-voxel-to-vtk rename to scripts/openmc_voxel_to_vtk.py index 3f59ffd4262..c1911973f8a 100755 --- a/scripts/openmc-voxel-to-vtk +++ b/scripts/openmc_voxel_to_vtk.py @@ -4,8 +4,7 @@ import openmc - -if __name__ == "__main__": +def main(): # Process command line arguments parser = ArgumentParser('Converts a voxel HDF5 file to a VTK file') parser.add_argument("voxel_file", help="Path to voxel h5 file") @@ -20,3 +19,6 @@ print("Reading and translating data...") openmc.voxel_to_vtk(args.voxel_file, args.output) print(f"Written VTK file {args.output}...") + +if __name__ == "__main__": + main() diff --git a/setup.py b/setup.py index 29c129d7b28..1f37a21b1c2 100755 --- a/setup.py +++ b/setup.py @@ -1,10 +1,9 @@ #!/usr/bin/env python -import glob import sys import numpy as np -from setuptools import setup, find_packages +from setuptools import setup from Cython.Build import cythonize @@ -16,65 +15,11 @@ # Get version information from __init__.py. This is ugly, but more reliable than # using an import. -with open('openmc/__init__.py', 'r') as f: - version = f.readlines()[-1].split()[-1].strip("'") +# with open('openmc/__init__.py', 'r') as f: +# version = f.readlines()[-1].split()[-1].strip("'") kwargs = { - 'name': 'openmc', - 'version': version, - 'packages': find_packages(exclude=['tests*']), - 'scripts': glob.glob('scripts/openmc-*'), - - # Data files and libraries - 'package_data': { - 'openmc.lib': ['libopenmc.{}'.format(suffix)], - 'openmc.data': ['mass_1.mas20.txt', 'BREMX.DAT', 'half_life.json', '*.h5'], - 'openmc.data.effective_dose': ['*.txt'] - }, - - # Metadata - 'author': 'The OpenMC Development Team', - 'author_email': 'openmc@anl.gov', - 'description': 'OpenMC', - 'url': 'https://openmc.org', - 'download_url': 'https://github.com/openmc-dev/openmc/releases', - 'project_urls': { - 'Issue Tracker': 'https://github.com/openmc-dev/openmc/issues', - 'Documentation': 'https://docs.openmc.org', - 'Source Code': 'https://github.com/openmc-dev/openmc', - }, - 'classifiers': [ - 'Development Status :: 4 - Beta', - 'Intended Audience :: Developers', - 'Intended Audience :: End Users/Desktop', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: MIT License', - 'Natural Language :: English', - 'Topic :: Scientific/Engineering' - 'Programming Language :: C++', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - ], - - # Dependencies - 'python_requires': '>=3.7', - 'install_requires': [ - 'numpy>=1.9', 'h5py', 'scipy', 'ipython', 'matplotlib', - 'pandas', 'lxml', 'uncertainties' - ], - 'extras_require': { - 'depletion-mpi': ['mpi4py'], - 'docs': ['sphinx', 'sphinxcontrib-katex', 'sphinx-numfig', 'jupyter', - 'sphinxcontrib-svg2pdfconverter', 'sphinx-rtd-theme'], - 'test': ['pytest', 'pytest-cov', 'colorama'], - 'vtk': ['vtk'], - }, - # Cython is used to add resonance reconstruction and fast float_endf + # 'version': version, 'ext_modules': cythonize('openmc/data/*.pyx'), 'include_dirs': [np.get_include()] }