diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml new file mode 100644 index 00000000..62e1ea71 --- /dev/null +++ b/.github/workflows/test_and_deploy.yml @@ -0,0 +1,66 @@ +name: tests + +on: + push: + branches: + - '*' + tags: + - '*' + pull_request: + +jobs: + linting: + runs-on: ubuntu-latest + steps: + - uses: neuroinformatics-unit/actions/lint@v2 + + manifest: + name: Check Manifest + runs-on: ubuntu-latest + steps: + - uses: neuroinformatics-unit/actions/check_manifest@v2 + + test: + needs: [linting, manifest] + name: ${{ matrix.os }} py${{ matrix.python-version }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + # Run all supported Python versions on linux + python-version: ["3.8", "3.9", "3.10"] + os: [ubuntu-latest] + # Include one windows and macos run + include: + - os: macos-latest + python-version: "3.10" + - os: windows-latest + python-version: "3.10" + + steps: + # Run tests + - uses: neuroinformatics-unit/actions/test@v2 + with: + python-version: ${{ matrix.python-version }} + + build_sdist_wheels: + name: Build source distribution + needs: [test] + if: github.event_name == 'push' && github.ref_type == 'tag' + runs-on: ubuntu-latest + steps: + - uses: neuroinformatics-unit/actions/build_sdist_wheels@v2 + + + upload_all: + name: Publish build distributions + needs: [build_sdist_wheels] + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v3 + with: + name: artifact + path: dist + - uses: pypa/gh-action-pypi-publish@v1.5.0 + with: + user: __token__ + password: ${{ secrets.TWINE_API_KEY }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..aedc8d7c --- /dev/null +++ b/.gitignore @@ -0,0 +1,83 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py + +# Flask instance folder +instance/ + +# Sphinx documentation +docs/_build/ + +# MkDocs documentation +/site/ + +# PyBuilder +target/ + +# Pycharm and VSCode +.idea/ +venv/ +.vscode/ + +# IPython Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# OS +.DS_Store + +# written by setuptools_scm +**/_version.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..fe4a64e7 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,34 @@ + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-docstring-first + - id: check-executables-have-shebangs + - id: check-merge-conflict + - id: check-toml + - id: end-of-file-fixer + - id: mixed-line-ending + args: [--fix=lf] + - id: requirements-txt-fixer + - id: trailing-whitespace + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.0.272 + hooks: + - id: ruff + - repo: https://github.com/psf/black + rev: 23.3.0 + hooks: + - id: black + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.3.0 + hooks: + - id: mypy + additional_dependencies: + - types-setuptools + - repo: https://github.com/mgedmin/check-manifest + rev: "0.49" + hooks: + - id: check-manifest + args: [--no-build-isolation] + additional_dependencies: [setuptools-scm] diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..ebfbb262 --- /dev/null +++ b/LICENSE @@ -0,0 +1,28 @@ + +Copyright (c) 2023, BrainGlobe developers +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 brainglobe-scripts 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. diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 00000000..c1b54649 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,10 @@ +include LICENSE +include README.md +exclude .pre-commit-config.yaml + +recursive-include brainglobe_workflows *.py + +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] +recursive-exclude docs * +recursive-exclude tests * diff --git a/README.md b/README.md index e69de29b..e3bf3ae6 100644 --- a/README.md +++ b/README.md @@ -0,0 +1 @@ +# brainglobe-workflows diff --git a/brainglobe_workflows/__init__.py b/brainglobe_workflows/__init__.py new file mode 100644 index 00000000..28709be9 --- /dev/null +++ b/brainglobe_workflows/__init__.py @@ -0,0 +1,7 @@ +from importlib.metadata import PackageNotFoundError, version + +try: + __version__ = version("brainglobe-scripts") +except PackageNotFoundError: + # package is not installed + pass diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..ec5c3257 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,105 @@ +[project] +name = "brainglobe-workflows" +authors = [{name = "BrainGlobe developers", email= "a.felder@ucl.ac.uk"}] +description = "A place to keep scripts to use as benchmarks, user-examples end-to-end tests and for tutorials" +readme = "README.md" +requires-python = ">=3.8.0" +dynamic = ["version"] + +license = {text = "BSD-3-Clause"} + +classifiers = [ + "Development Status :: 2 - Pre-Alpha", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Operating System :: OS Independent", + "License :: OSI Approved :: BSD License", +] + +[project.urls] +"Homepage" = "https://github.com/brainglobe/brainglobe-scripts" +"Bug Tracker" = "https://github.com/brainglobe/brainglobe-scripts/issues" +"Documentation" = "https://github.com/brainglobe/brainglobe-scripts" +"Source Code" = "https://github.com/brainglobe/brainglobe-scripts" +"User Support" = "https://github.com/brainglobe/brainglobe-scripts/issues" + +[project.optional-dependencies] +dev = [ + "pytest", + "pytest-cov", + "coverage", + "tox", + "black", + "mypy", + "pre-commit", + "ruff", + "setuptools_scm", +] + +[build-system] +requires = [ + "setuptools>=45", + "wheel", + "setuptools_scm[toml]>=6.2", +] +build-backend = "setuptools.build_meta" + +[tool.setuptools] +include-package-data = true + +[tool.setuptools.packages.find] +include = ["brainglobe_scripts*"] +exclude = ["tests*"] + +[tool.pytest.ini_options] +addopts = "--cov=brainglobe_scripts" + +[tool.black] +target-version = ['py38', 'py39', 'py310'] +skip-string-normalization = false +line-length = 79 + +[tool.setuptools_scm] + +[tool.check-manifest] +ignore = [ + ".yaml", + "tox.ini", + "tests/", + "tests/test_unit/", + "tests/test_integration/", +] + +[tool.ruff] +line-length = 79 +exclude = ["__init__.py","build",".eggs"] +select = ["I", "E", "F"] +fix = true + +[tool.cibuildwheel] +build = "cp38-* cp39-* cp310-*" + +[tool.cibuildwheel.macos] +archs = ["x86_64", "arm64"] + +[tool.tox] +legacy_tox_ini = """ +[tox] +envlist = py{38,39,310} +isolated_build = True + +[gh-actions] +python = + 3.8: py38 + 3.9: py39 + 3.10: py310 + +[testenv] +extras = + dev +commands = + pytest -v --color=yes --cov=brainglobe_scripts --cov-report=xml +""" diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/test_integration/__init__.py b/tests/test_integration/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/test_unit/__init__.py b/tests/test_unit/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/test_unit/test_placeholder.py b/tests/test_unit/test_placeholder.py new file mode 100644 index 00000000..3ada1ee4 --- /dev/null +++ b/tests/test_unit/test_placeholder.py @@ -0,0 +1,2 @@ +def test_placeholder(): + assert True