From 9bb0ba8f78b57001685b1a1041744d03485bd89f Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Thu, 19 Jan 2023 16:15:57 +0000 Subject: [PATCH 1/2] src folder and pyproject packaging --- openmc_plotter/__init__.py | 2 - pyproject.toml | 57 +++++++++++++++++- setup.py | 55 ----------------- src/_version.py | 4 ++ src/openmc_plotter/__init__.py | 14 +++++ .../openmc_plotter}/__main__.py | 0 .../openmc_plotter}/assets/openmc_logo.png | Bin .../openmc_plotter}/assets/splash.png | Bin .../openmc_plotter}/custom_widgets.py | 0 .../openmc_plotter}/docks.py | 0 .../openmc_plotter}/main_window.py | 0 .../openmc_plotter}/overlays.py | 0 .../openmc_plotter}/plot_colors.py | 0 .../openmc_plotter}/plotgui.py | 0 .../openmc_plotter}/plotmodel.py | 0 .../openmc_plotter}/scientific_spin_box.py | 0 .../openmc_plotter}/statepointmodel.py | 0 .../openmc_plotter}/tools.py | 0 18 files changed, 74 insertions(+), 58 deletions(-) delete mode 100644 openmc_plotter/__init__.py delete mode 100644 setup.py create mode 100644 src/_version.py create mode 100644 src/openmc_plotter/__init__.py rename {openmc_plotter => src/openmc_plotter}/__main__.py (100%) rename {openmc_plotter => src/openmc_plotter}/assets/openmc_logo.png (100%) rename {openmc_plotter => src/openmc_plotter}/assets/splash.png (100%) rename {openmc_plotter => src/openmc_plotter}/custom_widgets.py (100%) rename {openmc_plotter => src/openmc_plotter}/docks.py (100%) rename {openmc_plotter => src/openmc_plotter}/main_window.py (100%) rename {openmc_plotter => src/openmc_plotter}/overlays.py (100%) rename {openmc_plotter => src/openmc_plotter}/plot_colors.py (100%) rename {openmc_plotter => src/openmc_plotter}/plotgui.py (100%) rename {openmc_plotter => src/openmc_plotter}/plotmodel.py (100%) rename {openmc_plotter => src/openmc_plotter}/scientific_spin_box.py (100%) rename {openmc_plotter => src/openmc_plotter}/statepointmodel.py (100%) rename {openmc_plotter => src/openmc_plotter}/tools.py (100%) diff --git a/openmc_plotter/__init__.py b/openmc_plotter/__init__.py deleted file mode 100644 index cd57cb1..0000000 --- a/openmc_plotter/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ - -__version__ = '0.2.0' diff --git a/pyproject.toml b/pyproject.toml index c953815..ef96797 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,2 +1,57 @@ [build-system] -requires = ["setuptools", "wheel"] \ No newline at end of file +requires = ["setuptools >= 65.4.0", "setuptools_scm[toml]>=7.0.5"] +build-backend = "setuptools.build_meta" + +[project] +name = "openmc_plotter" +authors = [ + { name="OpenMC Development Team", email="openmc@anl.gov" }, +] + +license = {file = "LICENSE"} +description = "Native plotting GUI for model design and verification" +readme = "README.md" +requires-python = ">=3.6" +keywords = ["openmc", "plotter"] +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", +] +dependencies = [ + "numpy", + "matplotlib", + "PySide2", +] +dynamic = ["version"] + +[tool.setuptools.package-data] +myModule = ["assets/*.png"] + +[tool.setuptools_scm] +write_to = "src/_version.py" + + +[project.optional-dependencies] +tests = [ + "pytest", + "pytest-qt" +] +vtk = [ + "vtk" +] + +[project.urls] +"Homepage" = "https://github.com/openmc-dev/plotter" +"Bug Tracker" = "https://github.com/openmc-dev/plotter/issues" + +[tool.setuptools] +package-dir = {"" = "src"} + +[project.scripts] +openmc_geometry_plot = "openmc_plotter.__main__:main" \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index 788a1b5..0000000 --- a/setup.py +++ /dev/null @@ -1,55 +0,0 @@ -from setuptools import setup - -# Get version information from __init__.py. This is ugly, but more reliable than -# using an import. -with open('openmc_plotter/__init__.py', 'r') as f: - version = f.readlines()[-1].split()[-1].strip("'") - -kwargs = { - 'name': 'openmc-plotter', - 'version': version, - 'packages': ['openmc_plotter'], - 'package_data': {'openmc_plotter' : ['assets/*.png']}, - 'entry_points': { - 'console_scripts': [ - 'openmc-plotter=openmc_plotter.__main__:main' - ] - }, - - # Metadata - 'author': 'OpenMC Development Team', - 'author_email': 'openmc@anl.gov', - 'description': 'Plotting tool for OpenMC models and tally data', - 'url': 'https://github.com/openmc-dev/plotter', - 'download_url': 'https://github.com/openmc-dev/plotter', - 'project_urls': { - 'Issue Tracker': 'https://github.com/openmc-dev/plotter/issues', - 'Source Code': 'https://github.com/openmc-dev/plotter', - }, - 'classifiers': [ - 'Development Status :: 4 - Beta', - 'Intended Audience :: Developers', - 'Intended Audience :: End Users/Desktop', - 'Intended Audience :: Science/Research', - 'Natural Language :: English', - 'Topic :: Scientific/Engineering', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - ], - - # Dependencies - 'python_requires': '>=3.6', - 'install_requires': [ - 'openmc>0.12.2', 'numpy', 'matplotlib', 'PySide2' - ], - 'extras_require': { - 'test' : ['pytest', 'pytest-qt'], - 'vtk' : ['vtk'] - }, -} - -setup(**kwargs) diff --git a/src/_version.py b/src/_version.py new file mode 100644 index 0000000..97c6290 --- /dev/null +++ b/src/_version.py @@ -0,0 +1,4 @@ +# file generated by setuptools_scm +# don't change, don't track in version control +__version__ = version = '0.12.1.dev156+g4f353cc.d20230119' +__version_tuple__ = version_tuple = (0, 12, 1, 'dev156', 'g4f353cc.d20230119') diff --git a/src/openmc_plotter/__init__.py b/src/openmc_plotter/__init__.py new file mode 100644 index 0000000..7894475 --- /dev/null +++ b/src/openmc_plotter/__init__.py @@ -0,0 +1,14 @@ +try: + # this works for python 3.8 and higher + from importlib.metadata import version, PackageNotFoundError +except (ModuleNotFoundError, ImportError): + # this works for python 3.7 and lower + from importlib_metadata import version, PackageNotFoundError +try: + __version__ = version("openmc_plotter") +except PackageNotFoundError: + from setuptools_scm import get_version + + __version__ = get_version(root="..", relative_to=__file__) + +__all__ = ["__version__"] diff --git a/openmc_plotter/__main__.py b/src/openmc_plotter/__main__.py similarity index 100% rename from openmc_plotter/__main__.py rename to src/openmc_plotter/__main__.py diff --git a/openmc_plotter/assets/openmc_logo.png b/src/openmc_plotter/assets/openmc_logo.png similarity index 100% rename from openmc_plotter/assets/openmc_logo.png rename to src/openmc_plotter/assets/openmc_logo.png diff --git a/openmc_plotter/assets/splash.png b/src/openmc_plotter/assets/splash.png similarity index 100% rename from openmc_plotter/assets/splash.png rename to src/openmc_plotter/assets/splash.png diff --git a/openmc_plotter/custom_widgets.py b/src/openmc_plotter/custom_widgets.py similarity index 100% rename from openmc_plotter/custom_widgets.py rename to src/openmc_plotter/custom_widgets.py diff --git a/openmc_plotter/docks.py b/src/openmc_plotter/docks.py similarity index 100% rename from openmc_plotter/docks.py rename to src/openmc_plotter/docks.py diff --git a/openmc_plotter/main_window.py b/src/openmc_plotter/main_window.py similarity index 100% rename from openmc_plotter/main_window.py rename to src/openmc_plotter/main_window.py diff --git a/openmc_plotter/overlays.py b/src/openmc_plotter/overlays.py similarity index 100% rename from openmc_plotter/overlays.py rename to src/openmc_plotter/overlays.py diff --git a/openmc_plotter/plot_colors.py b/src/openmc_plotter/plot_colors.py similarity index 100% rename from openmc_plotter/plot_colors.py rename to src/openmc_plotter/plot_colors.py diff --git a/openmc_plotter/plotgui.py b/src/openmc_plotter/plotgui.py similarity index 100% rename from openmc_plotter/plotgui.py rename to src/openmc_plotter/plotgui.py diff --git a/openmc_plotter/plotmodel.py b/src/openmc_plotter/plotmodel.py similarity index 100% rename from openmc_plotter/plotmodel.py rename to src/openmc_plotter/plotmodel.py diff --git a/openmc_plotter/scientific_spin_box.py b/src/openmc_plotter/scientific_spin_box.py similarity index 100% rename from openmc_plotter/scientific_spin_box.py rename to src/openmc_plotter/scientific_spin_box.py diff --git a/openmc_plotter/statepointmodel.py b/src/openmc_plotter/statepointmodel.py similarity index 100% rename from openmc_plotter/statepointmodel.py rename to src/openmc_plotter/statepointmodel.py diff --git a/openmc_plotter/tools.py b/src/openmc_plotter/tools.py similarity index 100% rename from openmc_plotter/tools.py rename to src/openmc_plotter/tools.py From d9803f2f349f8829e5562272add60b2a00a197cf Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Thu, 19 Jan 2023 16:27:18 +0000 Subject: [PATCH 2/2] renamed tests to test --- .gitignore | 5 +++++ pyproject.toml | 2 +- src/_version.py | 4 ---- 3 files changed, 6 insertions(+), 5 deletions(-) delete mode 100644 src/_version.py diff --git a/.gitignore b/.gitignore index fe98fa8..ecd1647 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,8 @@ __pycache__ plot_settings.pkl *.egg-info + +# local version file +src/_version.py + +build/ \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index ef96797..d1750f1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,7 +38,7 @@ write_to = "src/_version.py" [project.optional-dependencies] -tests = [ +test = [ "pytest", "pytest-qt" ] diff --git a/src/_version.py b/src/_version.py deleted file mode 100644 index 97c6290..0000000 --- a/src/_version.py +++ /dev/null @@ -1,4 +0,0 @@ -# file generated by setuptools_scm -# don't change, don't track in version control -__version__ = version = '0.12.1.dev156+g4f353cc.d20230119' -__version_tuple__ = version_tuple = (0, 12, 1, 'dev156', 'g4f353cc.d20230119')