Repository: BrkRaw/brkraw (language: python)

Issue:
modernize packaging
in short get away from setup.py and move to pyproject.toml


Discussion / hints:

Fix patch:
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 0000000..5ab0ddf
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,9 @@
+---
+# Documentation
+# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
+version: 2
+updates:
+-   package-ecosystem: github-actions
+    directory: /
+    schedule:
+        interval: monthly
diff --git a/.gitignore b/.gitignore
index 98c5b69..1e681b8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,8 +8,7 @@ ui/styles/*.css
 dist
 build
 *.pid
-test
-test/*
 *.egg-info
 *.egg-info/*
-.DS_Store
\ No newline at end of file
+.DS_Store
+tests/tutorials
\ No newline at end of file
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..30cb7df
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,21 @@
+clean:
+	rm -rf tests/tutorials
+
+tests/tutorials:
+	git clone https://github.com/BrkRaw/tutorials.git tests/tutorials
+
+tests/tutorials/SampleData/20190724_114946_BRKRAW_1_1: tests/tutorials
+	unzip -uq tests/tutorials/SampleData/20190724_114946_BRKRAW_1_1.zip -d tests/tutorials/SampleData/
+
+tests/tutorials/bids_map.csv: tests/tutorials/SampleData/20190724_114946_BRKRAW_1_1
+	brkraw bids_helper tests/tutorials/SampleData/20190724_114946_BRKRAW_1_1 \
+						tests/tutorials/bids_map
+
+tests/tutorials/raw: tests/tutorials/bids_map.csv
+	brkraw bids_convert tests/tutorials/SampleData/20190724_114946_BRKRAW_1_1 \
+						tests/tutorials/bids_map.csv \
+						--output tests/tutorials/raw
+
+demo: tests/tutorials
+	brkraw info tests/tutorials/SampleData/20190724_114946_BRKRAW_1_1.zip
+	make tests/tutorials/raw
\ No newline at end of file
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 0000000..ad6c3d6
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,45 @@
+[build-system]
+build-backend = "hatchling.build"
+requires = ["hatchling"]
+
+[project]
+classifiers = [
+    'Development Status :: 5 - Production/Stable',
+    'Intended Audience :: Science/Research',
+    'Topic :: Scientific/Engineering :: Medical Science Apps.',
+    'Natural Language :: English',
+]
+dependencies = [
+    'nibabel>=3.0.2',
+    'numpy>=1.18.0',
+    'pandas>=1.0.0',
+    'pillow>=7.1.1',
+    'tqdm>=4.45.0',
+    'openpyxl>=3.0.3',
+    'xlrd>=1.0.0'
+]
+description = "Bruker PvDataset Loader"
+license = {text = "GNLv3"}
+version = "0.3.10"
+maintainers = [{name = "SungHo Lee", email = 'shlee@unc.edu'}]
+name = "brkraw"
+readme = "README.md"
+requires-python = ">=3.7"
+keywords = ['bruker', 'data_handler', 'converter', 'administrator_tool']
+
+[project.urls]
+Homepage = "https://github.com/brkraw/brkraw"
+
+[project.optional-dependencies]
+SimpleITK = [
+    'SimpleITK>=1.2.4'
+]
+dev = [
+    "flake8",
+    "pytest",
+    "nbmake"
+]
+
+[project.scripts]
+brkraw = "brkraw.scripts.brkraw:main"
+brk-backup = 'brkraw.scripts.brk_backup:main'
\ No newline at end of file
diff --git a/setup.py b/setup.py
deleted file mode 100644
index 2494c6e..0000000
--- a/setup.py
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/usr/scripts/env python
-"""
-Bruker PVdataset loader / converter
-"""
-from distutils.core import setup
-from setuptools import find_packages
-import re
-import io
-
-__version__ = re.search(
-    r'__version__\s*=\s*[\'"]([^\'"]*)[\'"]',
-    io.open('brkraw/__init__.py', encoding='utf_8_sig').read()
-    ).group(1)
-
-__author__ = 'SungHo Lee'
-__email__ = 'shlee@unc.edu'
-__url__ = 'https://github.com/brkraw/brkraw'
-
-setup(name='brkraw',
-      version=__version__,
-      description='Bruker PvDataset Loader',
-      python_requires='>3.5',
-      author=__author__,
-      author_email=__email__,
-      url=__url__,
-      license='GNLv3',
-      packages=find_packages(),
-      install_requires=['nibabel>=3.0.2',
-                        'numpy>=1.18.0',
-                        'pandas>=1.0.0',
-                        'pillow>=7.1.1',
-                        'tqdm>=4.45.0',
-                        'openpyxl>=3.0.3',
-                        'xlrd>=1.0.0'],
-      extras_require = {
-          'SimpleITK':  ['SimpleITK>=1.2.4']
-      },
-      entry_points={
-          'console_scripts': [
-              'brkraw=brkraw.scripts.brkraw:main',
-              'brk-backup=brkraw.scripts.brk_backup:main',
-          ],
-      },
-      classifiers=[
-            'Development Status :: 5 - Production/Stable',
-            'Intended Audience :: Science/Research',
-            'Topic :: Scientific/Engineering :: Medical Science Apps.',
-            'Natural Language :: English',
-      ],
-      keywords = 'bruker data_handler converter administrator_tool'
-     )


Test patch:
diff --git a/.github/workflows/autotest.yml b/.github/workflows/autotest.yml
deleted file mode 100644
index e69c11e..0000000
--- a/.github/workflows/autotest.yml
+++ /dev/null
@@ -1,34 +0,0 @@
-name: test
-
-on:
-  # this workflow triggered on below condition [push, pull_request]
-  push:
-    branches: [ master ]
-  pull_request:
-    branches: [ master ]
-
-jobs:
-  build:
-
-    runs-on: ubuntu-latest
-    strategy:
-      matrix:
-        python-version: [3.5, 3.6, 3.7, 3.8]
-
-    steps:
-    - uses: actions/checkout@v2
-    - name: Set up python ${{ matrix.python-version }}
-      uses: actions/setup-python@v2
-      with:
-        python-version: ${{ matrix.python-version }}
-    - name: Install dependencies
-      run: |
-        python -m pip install --upgrade pip
-        pip install flake8 pytest
-        if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
-    - name: Lint with flake8
-      run: |
-        # stop the build if there are Python syntax errors or undefined names
-        flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
-        # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
-        flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
\ No newline at end of file
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 0000000..a256f2f
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,81 @@
+name: test
+
+on:
+  # this workflow triggered on below condition [push, pull_request]
+  push:
+    branches: [ main ]
+  pull_request:
+    branches: [ "*" ]
+
+# cancel previous similar workflow runs
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  test_cli:
+
+    strategy:
+      matrix:
+        python-version: ["3.8", "3.9", "3.10", "3.11"]
+        os: [ubuntu-latest, windows-latest, macos-latest]
+      fail-fast: false
+
+    runs-on: ${{ matrix.os }}
+
+    steps:
+
+    - uses: actions/checkout@v2
+
+    - name: Set up python ${{ matrix.python-version }}
+
+      uses: actions/setup-python@v2
+      with:
+        python-version: ${{ matrix.python-version }}
+
+    - name: Install package
+      run: |
+        python -m pip install --upgrade pip
+        pip install .
+
+    - name: Version and help
+      run: |
+        brkraw --version
+        brkraw --help
+
+    - name: "smoke end-to-end test: use CLI on tutorial data"
+      run: make demo
+        
+
+  test_tutorial:
+
+    strategy:
+      matrix:
+        python-version: ["3.8", "3.9", "3.10", "3.11"]
+        os: [ubuntu-latest, windows-latest, macos-latest]
+      fail-fast: false
+
+    runs-on: ${{ matrix.os }}
+
+    steps:
+
+    - uses: actions/checkout@v2
+
+    - name: Set up python ${{ matrix.python-version }}
+
+      uses: actions/setup-python@v2
+      with:
+        python-version: ${{ matrix.python-version }}
+
+    - name: Install dependencies
+      run: |
+        python -m pip install --upgrade pip
+        pip install .[dev]
+
+    - name: Install tutorial
+      run: make tests/tutorials
+
+    - name: Test tutorial notebook
+      run: |
+        python -m pytest --nbmake tests/tutorials/JupyterNotebooks/01_GettingStarted.ipynb
+        tree tests/tutorials/raw
\ No newline at end of file