-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
repo setup using scientific-python/cookies
- Loading branch information
0 parents
commit 167de1b
Showing
10 changed files
with
418 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright (c) 2024, Andrew Walter. | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
* Neither the name of the vector package developers nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# ARI_SXN_SimBeamline | ||
|
||
[![Actions Status][actions-badge]][actions-link] | ||
[![Documentation Status][rtd-badge]][rtd-link] | ||
|
||
[![PyPI version][pypi-version]][pypi-link] | ||
[![Conda-Forge][conda-badge]][conda-link] | ||
[![PyPI platforms][pypi-platforms]][pypi-link] | ||
|
||
[![GitHub Discussion][github-discussions-badge]][github-discussions-link] | ||
|
||
<!-- SPHINX-START --> | ||
|
||
<!-- prettier-ignore-start --> | ||
[actions-badge]: https://github.com/NSLS-II-ARI/ARI_SXN_SimBeamline.git/workflows/CI/badge.svg | ||
[actions-link]: https://github.com/NSLS-II-ARI/ARI_SXN_SimBeamline.git/actions | ||
[conda-badge]: https://img.shields.io/conda/vn/conda-forge/ARI_SXN_SimBeamline | ||
[conda-link]: https://github.com/conda-forge/ARI_SXN_SimBeamline-feedstock | ||
[github-discussions-badge]: https://img.shields.io/static/v1?label=Discussions&message=Ask&color=blue&logo=github | ||
[github-discussions-link]: https://github.com/NSLS-II-ARI/ARI_SXN_SimBeamline.git/discussions | ||
[pypi-link]: https://pypi.org/project/ARI_SXN_SimBeamline/ | ||
[pypi-platforms]: https://img.shields.io/pypi/pyversions/ARI_SXN_SimBeamline | ||
[pypi-version]: https://img.shields.io/pypi/v/ARI_SXN_SimBeamline | ||
[rtd-badge]: https://readthedocs.org/projects/ARI_SXN_SimBeamline/badge/?version=latest | ||
[rtd-link]: https://ARI_SXN_SimBeamline.readthedocs.io/en/latest/?badge=latest | ||
|
||
<!-- prettier-ignore-end --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from __future__ import annotations | ||
|
||
import importlib.metadata | ||
|
||
project = "ARI_SXN_SimBeamline" | ||
copyright = "2024, Andrew Walter" | ||
author = "Andrew Walter" | ||
version = release = importlib.metadata.version("ari_sxn_simbeamline") | ||
|
||
extensions = [ | ||
"myst_parser", | ||
"sphinx.ext.autodoc", | ||
"sphinx.ext.intersphinx", | ||
"sphinx.ext.mathjax", | ||
"sphinx.ext.napoleon", | ||
"sphinx_autodoc_typehints", | ||
"sphinx_copybutton", | ||
] | ||
|
||
source_suffix = [".rst", ".md"] | ||
exclude_patterns = [ | ||
"_build", | ||
"**.ipynb_checkpoints", | ||
"Thumbs.db", | ||
".DS_Store", | ||
".env", | ||
".venv", | ||
] | ||
|
||
html_theme = "furo" | ||
|
||
myst_enable_extensions = [ | ||
"colon_fence", | ||
] | ||
|
||
intersphinx_mapping = { | ||
"python": ("https://docs.python.org/3", None), | ||
} | ||
|
||
nitpick_ignore = [ | ||
("py:class", "_io.StringIO"), | ||
("py:class", "_io.BytesIO"), | ||
] | ||
|
||
always_document_param_types = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# ARI_SXN_SimBeamline | ||
|
||
```{toctree} | ||
:maxdepth: 2 | ||
:hidden: | ||
``` | ||
|
||
```{include} ../README.md | ||
:start-after: <!-- SPHINX-START --> | ||
``` | ||
|
||
## Indices and tables | ||
|
||
- {ref}`genindex` | ||
- {ref}`modindex` | ||
- {ref}`search` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
from __future__ import annotations | ||
|
||
import argparse | ||
import shutil | ||
from pathlib import Path | ||
|
||
import nox | ||
|
||
DIR = Path(__file__).parent.resolve() | ||
|
||
nox.needs_version = ">=2024.3.2" | ||
nox.options.sessions = ["lint", "pylint", "tests"] | ||
nox.options.default_venv_backend = "uv|virtualenv" | ||
|
||
|
||
@nox.session | ||
def lint(session: nox.Session) -> None: | ||
""" | ||
Run the linter. | ||
""" | ||
session.install("pre-commit") | ||
session.run( | ||
"pre-commit", "run", "--all-files", "--show-diff-on-failure", *session.posargs | ||
) | ||
|
||
|
||
@nox.session | ||
def pylint(session: nox.Session) -> None: | ||
""" | ||
Run PyLint. | ||
""" | ||
# This needs to be installed into the package environment, and is slower | ||
# than a pre-commit check | ||
session.install(".", "pylint") | ||
session.run("pylint", "ari_sxn_simbeamline", *session.posargs) | ||
|
||
|
||
@nox.session | ||
def tests(session: nox.Session) -> None: | ||
""" | ||
Run the unit and regular tests. | ||
""" | ||
session.install(".[test]") | ||
session.run("pytest", *session.posargs) | ||
|
||
|
||
@nox.session(reuse_venv=True) | ||
def docs(session: nox.Session) -> None: | ||
""" | ||
Build the docs. Pass "--serve" to serve. Pass "-b linkcheck" to check links. | ||
""" | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--serve", action="store_true", help="Serve after building") | ||
parser.add_argument( | ||
"-b", dest="builder", default="html", help="Build target (default: html)" | ||
) | ||
args, posargs = parser.parse_known_args(session.posargs) | ||
|
||
if args.builder != "html" and args.serve: | ||
session.error("Must not specify non-HTML builder with --serve") | ||
|
||
extra_installs = ["sphinx-autobuild"] if args.serve else [] | ||
|
||
session.install("-e.[docs]", *extra_installs) | ||
session.chdir("docs") | ||
|
||
if args.builder == "linkcheck": | ||
session.run( | ||
"sphinx-build", "-b", "linkcheck", ".", "_build/linkcheck", *posargs | ||
) | ||
return | ||
|
||
shared_args = ( | ||
"-n", # nitpicky mode | ||
"-T", # full tracebacks | ||
f"-b={args.builder}", | ||
".", | ||
f"_build/{args.builder}", | ||
*posargs, | ||
) | ||
|
||
if args.serve: | ||
session.run("sphinx-autobuild", *shared_args) | ||
else: | ||
session.run("sphinx-build", "--keep-going", *shared_args) | ||
|
||
|
||
@nox.session | ||
def build_api_docs(session: nox.Session) -> None: | ||
""" | ||
Build (regenerate) API docs. | ||
""" | ||
|
||
session.install("sphinx") | ||
session.chdir("docs") | ||
session.run( | ||
"sphinx-apidoc", | ||
"-o", | ||
"api/", | ||
"--module-first", | ||
"--no-toc", | ||
"--force", | ||
"../src/ari_sxn_simbeamline", | ||
) | ||
|
||
|
||
@nox.session | ||
def build(session: nox.Session) -> None: | ||
""" | ||
Build an SDist and wheel. | ||
""" | ||
|
||
build_path = DIR.joinpath("build") | ||
if build_path.exists(): | ||
shutil.rmtree(build_path) | ||
|
||
session.install("build") | ||
session.run("python", "-m", "build") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
[build-system] | ||
requires = ["hatchling", "hatch-vcs"] | ||
build-backend = "hatchling.build" | ||
|
||
|
||
[project] | ||
name = "ARI_SXN_SimBeamline" | ||
authors = [ | ||
{ name = "Andrew Walter", email = "[email protected]" }, | ||
] | ||
description = "Code required for a simulated beamline version of ARI and SXN beamlines" | ||
readme = "README.md" | ||
license.file = "LICENSE" | ||
requires-python = ">=3.8" | ||
classifiers = [ | ||
"Development Status :: 1 - Planning", | ||
"Intended Audience :: Science/Research", | ||
"Intended Audience :: Developers", | ||
"License :: OSI Approved :: BSD License", | ||
"Operating System :: OS Independent", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3 :: Only", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Programming Language :: Python :: 3.12", | ||
"Topic :: Scientific/Engineering", | ||
"Typing :: Typed", | ||
] | ||
dynamic = ["version"] | ||
dependencies = [] | ||
|
||
[project.optional-dependencies] | ||
test = [ | ||
"pytest >=6", | ||
"pytest-cov >=3", | ||
] | ||
dev = [ | ||
"pytest >=6", | ||
"pytest-cov >=3", | ||
] | ||
docs = [ | ||
"sphinx>=7.0", | ||
"myst_parser>=0.13", | ||
"sphinx_copybutton", | ||
"sphinx_autodoc_typehints", | ||
"furo>=2023.08.17", | ||
] | ||
|
||
[project.urls] | ||
Homepage = "https://github.com/NSLS-II-ARI/ARI_SXN_SimBeamline.git" | ||
"Bug Tracker" = "https://github.com/NSLS-II-ARI/ARI_SXN_SimBeamline.git/issues" | ||
Discussions = "https://github.com/NSLS-II-ARI/ARI_SXN_SimBeamline.git/discussions" | ||
Changelog = "https://github.com/NSLS-II-ARI/ARI_SXN_SimBeamline.git/releases" | ||
|
||
|
||
[tool.hatch] | ||
version.source = "vcs" | ||
build.hooks.vcs.version-file = "src/ari_sxn_simbeamline/_version.py" | ||
|
||
[tool.hatch.envs.default] | ||
features = ["test"] | ||
scripts.test = "pytest {args}" | ||
|
||
|
||
[tool.pytest.ini_options] | ||
minversion = "6.0" | ||
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"] | ||
xfail_strict = true | ||
filterwarnings = [ | ||
"error", | ||
] | ||
log_cli_level = "INFO" | ||
testpaths = [ | ||
"tests", | ||
] | ||
|
||
|
||
[tool.coverage] | ||
run.source = ["ari_sxn_simbeamline"] | ||
report.exclude_also = [ | ||
'\.\.\.', | ||
'if typing.TYPE_CHECKING:', | ||
] | ||
|
||
[tool.mypy] | ||
files = ["src", "tests"] | ||
python_version = "3.8" | ||
warn_unused_configs = true | ||
strict = true | ||
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"] | ||
warn_unreachable = true | ||
disallow_untyped_defs = false | ||
disallow_incomplete_defs = false | ||
|
||
[[tool.mypy.overrides]] | ||
module = "ari_sxn_simbeamline.*" | ||
disallow_untyped_defs = true | ||
disallow_incomplete_defs = true | ||
|
||
|
||
[tool.ruff] | ||
src = ["src"] | ||
|
||
[tool.ruff.lint] | ||
extend-select = [ | ||
"B", # flake8-bugbear | ||
"I", # isort | ||
"ARG", # flake8-unused-arguments | ||
"C4", # flake8-comprehensions | ||
"EM", # flake8-errmsg | ||
"ICN", # flake8-import-conventions | ||
"G", # flake8-logging-format | ||
"PGH", # pygrep-hooks | ||
"PIE", # flake8-pie | ||
"PL", # pylint | ||
"PT", # flake8-pytest-style | ||
"PTH", # flake8-use-pathlib | ||
"RET", # flake8-return | ||
"RUF", # Ruff-specific | ||
"SIM", # flake8-simplify | ||
"T20", # flake8-print | ||
"UP", # pyupgrade | ||
"YTT", # flake8-2020 | ||
"EXE", # flake8-executable | ||
"NPY", # NumPy specific rules | ||
"PD", # pandas-vet | ||
] | ||
ignore = [ | ||
"PLR09", # Too many <...> | ||
"PLR2004", # Magic value used in comparison | ||
"ISC001", # Conflicts with formatter | ||
] | ||
isort.required-imports = ["from __future__ import annotations"] | ||
# Uncomment if using a _compat.typing backport | ||
# typing-modules = ["ari_sxn_simbeamline._compat.typing"] | ||
|
||
[tool.ruff.lint.per-file-ignores] | ||
"tests/**" = ["T20"] | ||
"noxfile.py" = ["T20"] | ||
|
||
|
||
[tool.pylint] | ||
py-version = "3.8" | ||
ignore-paths = [".*/_version.py"] | ||
reports.output-format = "colorized" | ||
similarities.ignore-imports = "yes" | ||
messages_control.disable = [ | ||
"design", | ||
"fixme", | ||
"line-too-long", | ||
"missing-module-docstring", | ||
"missing-function-docstring", | ||
"wrong-import-position", | ||
] |
Oops, something went wrong.