From 7a4c30ff0228c9cd4cddc76a4bad38bc9e2cda38 Mon Sep 17 00:00:00 2001 From: Rob Nagler <5495179+robnagler@users.noreply.github.com> Date: Fri, 28 Nov 2025 22:07:58 +0000 Subject: [PATCH 1/3] upgrade to pyproject toml --- .github/workflows/python-ci.yml | 2 +- .gitignore | 107 ++++---------------------------- .readthedocs.yml | 12 ++++ LICENSE | 5 +- MANIFEST.in | 3 + docs/.gitignore | 5 ++ docs/index.rst | 4 ++ pyproject.toml | 67 ++++++++++++++++++++ requirements.txt | 2 - rshellweg/__init__.py | 13 +++- rshellweg/rshellweg_console.py | 11 ++-- setup.py | 62 ------------------ 12 files changed, 122 insertions(+), 171 deletions(-) create mode 100644 .readthedocs.yml create mode 100644 MANIFEST.in create mode 100644 docs/.gitignore create mode 100644 pyproject.toml delete mode 100644 requirements.txt delete mode 100644 setup.py diff --git a/.github/workflows/python-ci.yml b/.github/workflows/python-ci.yml index 42954ad..cd33214 100644 --- a/.github/workflows/python-ci.yml +++ b/.github/workflows/python-ci.yml @@ -13,5 +13,5 @@ jobs: python-ci: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: curl -LsS https://radia.run | bash -s python-ci diff --git a/.gitignore b/.gitignore index 994656d..e0a3533 100644 --- a/.gitignore +++ b/.gitignore @@ -1,68 +1,17 @@ pyhellweg.cpp -__history +pyhellweg.o -# Created by https://www.gitignore.io/api/c++ - -### C++ ### -# Prerequisites -*.d - -# Compiled Object files -*.slo -*.lo -*.o -*.obj - -# Precompiled Headers -*.gch -*.pch - -# Compiled Dynamic libraries -*.so -*.dylib -*.dll - -# Fortran module files -*.mod -*.smod - -# Compiled Static libraries -*.lai -*.la -*.a -*.lib - -# Executables -*.exe -*.out -*.app - -# Created by https://www.gitignore.io/api/cmake - -### CMake ### -CMakeCache.txt -CMakeFiles -CMakeScripts -Makefile -cmake_install.cmake -install_manifest.txt -CTestTestfile.cmake - -# Backup files -*.#00 -*.~1~ -*.~3~ -*.~4~ -*~ - - -# Created by https://www.gitignore.io/api/python +pytest.ini +tox.ini +.python-version +.#* +\#* +.idea/ +.vscode/ -### Python ### # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] -*$py.class # C extensions *.so @@ -74,8 +23,8 @@ build/ develop-eggs/ dist/ downloads/ -eggs/ .eggs/ +eggs/ lib/ lib64/ parts/ @@ -104,7 +53,7 @@ htmlcov/ nosetests.xml coverage.xml *,cover -.hypothesis/ +.pytest_cache # Translations *.mo @@ -112,44 +61,10 @@ coverage.xml # Django stuff: *.log -local_settings.py - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy # Sphinx documentation docs/_build/ +_build_html/ # PyBuilder target/ - -# IPython Notebook -.ipynb_checkpoints - -# pyenv -.python-version - -# celery beat schedule file -celerybeat-schedule - -# dotenv -.env - -# virtualenv -.venv/ -venv/ -ENV/ -.direnv/ - -# Spyder project settings -.spyderproject - -# Rope project settings -.ropeproject - -PARSED.TXT -MANIFEST.in diff --git a/.readthedocs.yml b/.readthedocs.yml new file mode 100644 index 0000000..a420660 --- /dev/null +++ b/.readthedocs.yml @@ -0,0 +1,12 @@ +# Read The Docs configuration file +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details +version: 2 +build: + os: ubuntu-22.04 + tools: + python: "3.9" + jobs: + pre_build: + - curl https://radia.run | bash -s readthedocs +sphinx: + configuration: docs/conf.py diff --git a/LICENSE b/LICENSE index 8dada3e..d645695 100644 --- a/LICENSE +++ b/LICENSE @@ -1,3 +1,4 @@ + Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -178,7 +179,7 @@ APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" + boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a @@ -186,7 +187,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright {yyyy} {name of copyright owner} + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..87224f4 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,3 @@ +include src/physics/*.h +include src/libHellweg2D/*.h +include src/libHellweg2D/*.hpp diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 0000000..816bb96 --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1,5 @@ +* +!.gitignore +!_static/ +!_templates/ +!index.rst diff --git a/docs/index.rst b/docs/index.rst index dadcd5a..eea6e93 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -3,6 +3,10 @@ Welcome to rshellweg description +.. autosummary:: + :toctree: _autosummary + :recursive: + .. toctree:: :maxdepth: 2 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..280c97b --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,67 @@ +[build-system] +requires = [ + "chronver", + "setuptools>=66", + "Cython>=3.0", +] +build-backend = "setuptools.build_meta" + +[project] +authors = [ + { name = "RadiaSoft LLC", email = "pip@radiasoft.net" }, +] +classifiers = [ + "Development Status :: 2 - Pre-Alpha", + "Environment :: Console", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Natural Language :: English", + "Programming Language :: Python", + "Topic :: Utilities", +] +dependencies = [ + "pykern", + "Cython", +] +description = "description" +dynamic = ["version"] +name = "rshellweg" +readme = "README.md" + +[project.scripts] +rshellweg = "rshellweg.rshellweg_console:main" + +[project.urls] +Homepage = "https://git.radiasoft.org/rshellweg" + +[tool.setuptools.package-data] +rshellweg = ["package_data/**"] + +[tool.setuptools.packages.find] +include = ["rshellweg*"] + +# Cython/C++ extension replacing the pykern.pksetup.setup(ext_modules=...) +[[tool.setuptools.ext-modules]] +name = "rshellweg.pyhellweg" +language = "c++" +extra-compile-args = ["-std=c++11", "-DRSHELLWEG_LINUX=1"] +include-dirs = [ + "src/libHellweg2D", + "src/physics", +] +sources = [ + "pyhellweg.pyx", + "src/libHellweg2D/AnsiString.cpp", + "src/libHellweg2D/IniFiles.cpp", + "src/libHellweg2D/TStringList.cpp", + "src/libHellweg2D/libHellweg2D.cpp", + "src/physics/Beam.cpp", + "src/physics/BeamSolver.cpp", + "src/physics/ConstUnit.cpp", + "src/physics/Functions.cpp", + "src/physics/Matrix.cpp", + "src/physics/Spectrum.cpp", + "src/physics/SpectrumPhase.cpp", + "src/physics/Spline.cpp", + "src/physics/Types.cpp", +] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 7e746e0..0000000 --- a/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -# only one dependency for Python -pykern diff --git a/rshellweg/__init__.py b/rshellweg/__init__.py index 792d600..d793cff 100644 --- a/rshellweg/__init__.py +++ b/rshellweg/__init__.py @@ -1 +1,12 @@ -# +""":mod:`rshellweg` package + +:copyright: Copyright (c) 2025 RadiaSoft LLC. All Rights Reserved. +:license: https://www.apache.org/licenses/LICENSE-2.0.html +""" +import importlib.metadata + +try: + # We only have a version once the package is installed. + __version__ = importlib.metadata.version("rshellweg") +except importlib.metadata.PackageNotFoundError: + pass diff --git a/rshellweg/rshellweg_console.py b/rshellweg/rshellweg_console.py index a594da6..b78f279 100644 --- a/rshellweg/rshellweg_console.py +++ b/rshellweg/rshellweg_console.py @@ -1,20 +1,17 @@ -# -*- coding: utf-8 -*- """Front-end command line for :mod:`rshellweg`. See :mod:`pykern.pkcli` for how this module is used. -:copyright: Copyright (c) 2016 RadiaSoft LLC. All Rights Reserved. -:license: http://www.apache.org/licenses/LICENSE-2.0.html +:copyright: Copyright (c) 2025 RadiaSoft LLC. All Rights Reserved. +:license: https://www.apache.org/licenses/LICENSE-2.0.html """ -from __future__ import absolute_import, division, print_function +import pykern.pkcli import sys -from pykern import pkcli - def main(): - return pkcli.main("rshellweg") + return pykern.pkcli.main("rshellweg") if __name__ == "__main__": diff --git a/setup.py b/setup.py deleted file mode 100644 index 621c29d..0000000 --- a/setup.py +++ /dev/null @@ -1,62 +0,0 @@ -# -*- coding: utf-8 -*- -"""rshellweg setup script - -:copyright: Copyright (c) 2016 RadiaSoft LLC. All Rights Reserved. -:license: http://www.apache.org/licenses/LICENSE-2.0.html -""" -from glob import glob -import setuptools -import os -import sysconfig -import pykern.pksetup -import Cython.Build - -_LIB_DIR = os.path.join("src", "libHellweg2D") - -_PHYS_DIR = os.path.join("src", "physics") - - -def _get_src_files(directory, extension): - """Get list of files in `directory` with `extension`""" - return glob(os.path.join(directory, "*.{}".format(extension))) - - -def _get_compile_args(): - """Returns compiler arguments based on $CC or Python's default CC""" - compiler = os.environ.get("CC", sysconfig.get_config_var("CC")) - # libHellweg2D uses c++11 features - if "gcc" in compiler: - return ["-std=c++11", "-I" + os.path.expanduser("~/.local/include")] - return None - - -pykern.pksetup.setup( - name="rshellweg", - author="RadiaSoft LLC", - author_email="pip@radiasoft.net", - description="description", - license="http://www.apache.org/licenses/LICENSE-2.0.html", - url="https://github.com/radiasoft/rshellweg", - classifiers=[ - "Development Status :: 2 - Pre-Alpha", - "Environment :: Console", - "Intended Audience :: Developers", - "License :: OSI Approved :: Apache Software License", - "Natural Language :: English", - "Programming Language :: Python", - "Topic :: Utilities", - ], - ext_modules=Cython.Build.cythonize( - [ - setuptools.Extension( - name="rshellweg.pyhellweg", - define_macros=[("RSHELLWEG_LINUX", 1)], - include_dirs=[_LIB_DIR, _PHYS_DIR], - sources=_get_src_files(_PHYS_DIR, "cpp") - + _get_src_files(_LIB_DIR, "cpp") - + ["pyhellweg.pyx"], - extra_compile_args=_get_compile_args(), - ), - ] - ), -) From 0bc81a77e586a784eb0661be147107574a768a9c Mon Sep 17 00:00:00 2001 From: Rob Nagler <5495179+robnagler@users.noreply.github.com> Date: Fri, 28 Nov 2025 22:52:52 +0000 Subject: [PATCH 2/3] unnecessary comment --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 280c97b..3587fd2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,6 @@ rshellweg = ["package_data/**"] [tool.setuptools.packages.find] include = ["rshellweg*"] -# Cython/C++ extension replacing the pykern.pksetup.setup(ext_modules=...) [[tool.setuptools.ext-modules]] name = "rshellweg.pyhellweg" language = "c++" From 9a8a39b270eacaec1f2c515d0768f906fdfded7a Mon Sep 17 00:00:00 2001 From: Rob Nagler <5495179+robnagler@users.noreply.github.com> Date: Sat, 29 Nov 2025 16:55:44 +0000 Subject: [PATCH 3/3] CI does not work so remove for now --- .github/workflows/python-ci.yml | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 .github/workflows/python-ci.yml diff --git a/.github/workflows/python-ci.yml b/.github/workflows/python-ci.yml deleted file mode 100644 index cd33214..0000000 --- a/.github/workflows/python-ci.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: python-ci -on: - pull_request: - branches: - - main - - master - push: - branches: - - main - - master - -jobs: - python-ci: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - run: curl -LsS https://radia.run | bash -s python-ci