diff --git a/.github/actions/restore-elephant-data/action.yml b/.github/actions/restore-elephant-data/action.yml new file mode 100644 index 000000000..dca0d099f --- /dev/null +++ b/.github/actions/restore-elephant-data/action.yml @@ -0,0 +1,35 @@ +# Composite action: restore the elephant-data cache and set ELEPHANT_DATA_LOCATION. +name: Restore elephant-data cache +runs: + using: "composite" + steps: + - name: Get elephant_data hash + id: elephant-data + shell: bash + run: echo "dataset_hash=$(git ls-remote https://gin.g-node.org/NeuralEnsemble/elephant-data.git HEAD | cut -f1)" >> $GITHUB_OUTPUT + + - uses: actions/cache/restore@v5 + with: + path: ~/elephant-data + key: datasets-${{ steps.elephant-data.outputs.dataset_hash }} + restore-keys: datasets- + enableCrossOsArchive: true + + - name: Export Data Location (Unix) + shell: bash + if: runner.os != 'Windows' + run: | + DATA_DIR="$HOME/elephant-data" + if [ -d "$DATA_DIR" ]; then + echo "ELEPHANT_DATA_LOCATION=$DATA_DIR" >> "$GITHUB_ENV" + echo "$DATA_DIR" + fi + + - name: Export Data Location (Windows) + if: runner.os == 'Windows' + shell: pwsh + run: | + if (Test-Path "$env:USERPROFILE\elephant-data") { + "ELEPHANT_DATA_LOCATION=$env:USERPROFILE\elephant-data" >> $env:GITHUB_ENV + Write-Output $env:USERPROFILE\elephant-data + } diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 73ae47286..4cb975a70 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,10 +1,10 @@ -# This workflow will set up GitHub-hosted runners and install the required dependencies for elephant tests. -# On a pull requests and on pushes to master it will run different tests for elephant. +# This workflow sets up GitHub runners and runs unit tests +# Triggered on pull requests, pushes to master and manual trigger from github web +# Triggers name: tests -# define events that trigger workflow 'tests' on: - workflow_dispatch: # enables manual triggering of workflow + workflow_dispatch: inputs: logLevel: description: 'Log level' @@ -20,23 +20,13 @@ on: branches: - master types: - #- assigned - #- unassigned - #- labeled - #- unlabeled - opened - #- edited - #- closed - reopened - synchronize - #- converted_to_draft - #- ready_for_review - #- locked - #- unlocked - #- review_requested - #- review_request_removed - #- auto_merge_enabled - #- auto_merge_disabled + + pull_request_review: + types: + - submitted push: branches: @@ -47,9 +37,30 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -# jobs define the steps that will be executed on the runner +# Single source of truth for CI matrix sizes. +# Fast CI: ubuntu-latest + 3.12 only. Full CI: all OS/Python combos. +env: + FAST_MATRIX: '{"os":["ubuntu-latest"],"python-version":["3.12"]}' + FULL_MATRIX: '{"os":["ubuntu-latest","macos-latest","windows-latest"],"python-version":["3.9","3.10","3.11","3.12","3.13","3.14"]}' + jobs: + # Selects fast or full matrix based on PR approval. + setup: + runs-on: ubuntu-latest + if: github.event_name != 'pull_request_review' || github.event.review.state == 'approved' + outputs: + pip-matrix: ${{ steps.pick.outputs.pip-matrix }} + steps: + - id: pick + run: | + if [[ "${{ github.event.action }}" == "submitted" && \ + "${{ github.event.review.state }}" == "approved" ]]; then + echo "pip-matrix=$FULL_MATRIX" >> $GITHUB_OUTPUT + else + echo "pip-matrix=$FAST_MATRIX" >> $GITHUB_OUTPUT + fi + # _ # _ __ (_)_ __ # | '_ \| | '_ \ @@ -57,200 +68,48 @@ jobs: # | .__/|_| .__/ # |_| |_| - # install dependencies and elephant with pip and run tests with pytest build-and-test-pip: + needs: setup + name: pip (${{ matrix.python-version }}, ${{ matrix.os }}) runs-on: ${{ matrix.os }} strategy: - matrix: - # python versions for elephant: [3.8, 3.9, "3.10", 3.11, 3.12, 3.13] - python-version: [3.9, "3.10", 3.11, 3.12, 3.13] - # OS [ubuntu-latest, macos-latest, windows-latest] - os: [ubuntu-latest] - # do not cancel all in-progress jobs if any matrix job fails fail-fast: false + matrix: ${{ fromJSON(needs.setup.outputs.pip-matrix) }} steps: - - uses: actions/checkout@v4.1.6 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5.1.0 - with: - python-version: ${{ matrix.python-version }} - check-latest: true - cache: 'pip' - cache-dependency-path: | - **/requirements.txt - **/requirements-extras.txt - **/requirements-tests.txt - - - name: Get current hash (SHA) of the elephant_data repo - id: elephant-data - run: | - echo "dataset_hash=$(git ls-remote https://gin.g-node.org/NeuralEnsemble/elephant-data.git HEAD | cut -f1)" >> $GITHUB_OUTPUT - - - uses: actions/cache/restore@v4.2.2 - # Loading cache of elephant-data - id: cache-datasets - with: - path: ~/elephant-data - key: datasets-${{ steps.elephant-data.outputs.dataset_hash }} - restore-keys: datasets- - enableCrossOsArchive: true - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install coveralls - pip install -e .[extras,tests] - - - name: List packages - run: | - pip list - python --version - - - name: Test with pytest - run: | - if [ -d ~/elephant-data ]; then - export ELEPHANT_DATA_LOCATION=~/elephant-data - echo $ELEPHANT_DATA_LOCATION - fi - - coverage run --source=elephant -m pytest - coveralls --service=github || echo "Coveralls submission failed" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - # ___ ____ - # _ __ ___ __ _ ___ / _ \/ ___| - # | '_ ` _ \ / _` |/ __| | | \___ \ - # | | | | | | (_| | (__| |_| |___) | - # |_| |_| |_|\__,_|\___|\___/|____/ - - test-macOS: - name: conda (${{ matrix.python-version }}, ${{ matrix.os }}) - runs-on: ${{ matrix.os }} - strategy: - # do not cancel all in-progress jobs if any matrix job fails - fail-fast: false - matrix: - # OS [ubuntu-latest, macos-latest, windows-latest] - os: [macos-14,macos-15] - python-version: [3.12] - steps: - - name: Get current year-month - id: date - run: echo "date=$(date +'%Y-%m')" >> $GITHUB_OUTPUT - - - uses: actions/checkout@v4.1.6 + - uses: actions/checkout@v6.0.2 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5.1.0 + uses: actions/setup-python@v6.2.0 with: python-version: ${{ matrix.python-version }} check-latest: true cache: 'pip' - cache-dependency-path: | - **/requirements.txt - **/requirements-extras.txt - **/requirements-tests.txt - - - name: Get current hash (SHA) of the elephant_data repo - id: elephant-data - run: | - echo "dataset_hash=$(git ls-remote https://gin.g-node.org/NeuralEnsemble/elephant-data.git HEAD | cut -f1)" >> $GITHUB_OUTPUT + cache-dependency-path: pyproject.toml - - uses: actions/cache/restore@v4.2.2 - # Loading cache of elephant-data - id: cache-datasets - with: - path: ~/elephant-data - key: datasets-${{ steps.elephant-data.outputs.dataset_hash }} - restore-keys: datasets- + - uses: ./.github/actions/restore-elephant-data - name: Install dependencies run: | - python --version python -m pip install --upgrade pip - pip install pytest-cov coveralls pip install -e .[extras,tests] - name: List packages - shell: bash -l {0} run: | pip list python --version - name: Test with pytest - shell: bash -l {0} - run: | - if [ -d ~/elephant-data ]; then - export ELEPHANT_DATA_LOCATION=~/elephant-data - echo $ELEPHANT_DATA_LOCATION - fi - pytest --cov=elephant + shell: bash + run: pytest --cov=elephant --cov-report=lcov:coverage.lcov - # __ ___ _ - # \ \ / (_)_ __ __| | _____ _____ - # \ \ /\ / /| | '_ \ / _` |/ _ \ \ /\ / / __| - # \ V V / | | | | | (_| | (_) \ V V /\__ \ - # \_/\_/ |_|_| |_|\__,_|\___/ \_/\_/ |___/ - - # install dependencies with pip and run tests with pytest - test-pip: - runs-on: ${{ matrix.os }} - strategy: - matrix: - # python versions for elephant: [3.8, 3.9, 3.10, 3.11] - python-version: [3.11,] - # OS [ubuntu-latest, macos-latest, windows-latest] - os: [windows-latest] - - steps: - - uses: actions/checkout@v4.1.6 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5.1.0 + - name: Upload coverage to Coveralls + uses: coverallsapp/github-action@v2 with: - python-version: ${{ matrix.python-version }} - check-latest: true - cache: 'pip' - cache-dependency-path: | - **/requirements.txt - **/requirements-extras.txt - **/requirements-tests.txt - - - name: Get current hash (SHA) of the elephant_data repo - id: elephant-data - run: | - echo "dataset_hash=$(git ls-remote https://gin.g-node.org/NeuralEnsemble/elephant-data.git HEAD | cut -f1)" >> $GITHUB_OUTPUT - - - uses: actions/cache/restore@v4.2.2 - # Loading cache of elephant-data - id: cache-datasets - with: - path: ~/elephant-data - key: datasets-${{ steps.elephant-data.outputs.dataset_hash }} - restore-keys: datasets- - enableCrossOsArchive: true - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install pytest-cov coveralls - pip install -e .[extras,tests] - - - name: List packages - run: | - pip list - python --version - - - name: Test with pytest - run: | - if (Test-Path "$env:USERPROFILE\elephant-data") { - $env:ELEPHANT_DATA_LOCATION = "$env:USERPROFILE\elephant-data" - Write-Output $env:ELEPHANT_DATA_LOCATION - } - pytest --cov=elephant + github-token: ${{ secrets.GITHUB_TOKEN }} + flag-name: py${{ matrix.python-version }}-${{ matrix.os }} + parallel: true + file: coverage.lcov # __ __ ____ ___ # | \/ | _ \_ _| @@ -260,53 +119,34 @@ jobs: # install dependencies and elephant with pip and run MPI test-pip-MPI: + needs: setup + name: mpi (${{ matrix.python-version }}, ${{ matrix.os }}) runs-on: ${{ matrix.os }} strategy: matrix: - # python versions for elephant: [3.8, 3.9, 3.10, 3.11] - python-version: [3.9] - # OS [ubuntu-latest, macos-latest, windows-latest] + python-version: ["3.12"] os: [ubuntu-latest] - - # do not cancel all in-progress jobs if any matrix job fails fail-fast: false steps: - - uses: actions/checkout@v4.1.6 + - uses: actions/checkout@v6.0.2 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5.1.0 + uses: actions/setup-python@v6.2.0 with: python-version: ${{ matrix.python-version }} check-latest: true cache: 'pip' - cache-dependency-path: | - **/requirements.txt - **/requirements-extras.txt - **/requirements-tests.txt + cache-dependency-path: pyproject.toml - - name: Get current hash (SHA) of the elephant_data repo - id: elephant-data - run: | - echo "dataset_hash=$(git ls-remote https://gin.g-node.org/NeuralEnsemble/elephant-data.git HEAD | cut -f1)" >> $GITHUB_OUTPUT - - - uses: actions/cache/restore@v4.2.2 - # Loading cache of elephant-data - id: cache-datasets - with: - path: ~/elephant-data - key: datasets-${{ steps.elephant-data.outputs.dataset_hash }} - restore-keys: datasets- - enableCrossOsArchive: true + - uses: ./.github/actions/restore-elephant-data - name: Setup environment run: | sudo apt-get update sudo apt install -y libopenmpi-dev openmpi-bin - python -m pip install --upgrade pip pip install mpi4py - pip install pytest-cov coveralls pip install -e .[extras,tests] - name: List packages @@ -315,15 +155,15 @@ jobs: python --version - name: Test with pytest - run: | - if [ -d ~/elephant-data ]; then - export ELEPHANT_DATA_LOCATION=~/elephant-data - echo $ELEPHANT_DATA_LOCATION - fi - mpiexec -n 1 python -m mpi4py -m coverage run --source=elephant -m pytest - coveralls --service=github || echo "Coveralls submission failed" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: mpiexec -n 1 python -m mpi4py -m pytest --cov=elephant --cov-report=lcov:coverage.lcov + + - name: Upload coverage to Coveralls + uses: coverallsapp/github-action@v2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + flag-name: mpi + parallel: true + file: coverage.lcov # ____ _ # / ___|___ _ __ __| | __ _ @@ -331,17 +171,14 @@ jobs: # | |__| (_) | | | | (_| | (_| | # \____\___/|_| |_|\__,_|\__,_| - # install dependencies with conda and run tests with pytest test-conda: + needs: setup + name: conda (${{ matrix.python-version }}, ${{ matrix.os }}) runs-on: ${{ matrix.os }} strategy: matrix: - # python versions for elephant: [3.8, 3.9, 3.10, 3.11] - python-version: [3.11] - # OS [ubuntu-latest, macos-latest, windows-latest] + python-version: [3.12] os: [ubuntu-latest] - - # do not cancel all in-progress jobs if any matrix job fails fail-fast: false steps: @@ -349,7 +186,7 @@ jobs: id: date run: echo "date=$(date +'%Y-%m')" >> $GITHUB_OUTPUT - - uses: actions/checkout@v4.1.6 + - uses: actions/checkout@v6.0.2 - name: Get pip cache dir id: pip-cache @@ -357,27 +194,16 @@ jobs: echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT - name: Cache pip - uses: actions/cache@v4.2.2 + uses: actions/cache@v5.0.5 with: path: ${{ steps.pip-cache.outputs.dir }} key: ${{ runner.os }}-pip-${{hashFiles('requirements/environment-tests.yml') }}-${{ hashFiles('**/CI.yml') }}-${{ steps.date.outputs.date }} - - name: Get current hash (SHA) of the elephant_data repo - id: elephant-data - run: | - echo "dataset_hash=$(git ls-remote https://gin.g-node.org/NeuralEnsemble/elephant-data.git HEAD | cut -f1)" >> $GITHUB_OUTPUT - - uses: actions/cache/restore@v4.2.2 - # Loading cache of elephant-data - id: cache-datasets - with: - path: ~/elephant-data - key: datasets-${{ steps.elephant-data.outputs.dataset_hash }} - restore-keys: datasets- - enableCrossOsArchive: true + - uses: ./.github/actions/restore-elephant-data - - uses: mamba-org/setup-micromamba@v2 + - uses: mamba-org/setup-micromamba@v3.0.0 with: create-args: python=${{ matrix.python-version }} environment-file: requirements/environment-tests.yml @@ -387,7 +213,6 @@ jobs: shell: bash -el {0} run: | python --version - micromamba install -y -c conda-forge pytest pytest-cov coveralls mpi4py openmpi pip install -e . - name: List packages @@ -395,16 +220,10 @@ jobs: run: | pip list micromamba list - python --version - name: Test with pytest shell: bash -el {0} - run: | - if [ -d ~/elephant-data ]; then - export ELEPHANT_DATA_LOCATION=~/elephant-data - echo $ELEPHANT_DATA_LOCATION - fi - pytest --cov=elephant + run: pytest # ____ # | _ \ ___ ___ ___ @@ -412,124 +231,107 @@ jobs: # | |_| | (_) | (__\__ \ # |____/ \___/ \___|___/ - # install dependencies for the documentation and build .html docs: - name: docs (${{ matrix.os }}) + needs: setup + name: docs (${{ matrix.python-version }}, ${{ matrix.os }}) runs-on: ${{ matrix.os }} strategy: matrix: - # python versions for elephant: [3.8, 3.9, 3.10, 3.11, 3.12] python-version: [3.12] - # OS [ubuntu-latest, macos-latest, windows-latest] os: [ubuntu-latest] steps: + - uses: actions/checkout@v6.0.2 - - name: Get current year-month - id: date - run: echo "date=$(date +'%Y-%m')" >> $GITHUB_OUTPUT - - - uses: actions/checkout@v4.1.6 - - - name: Get pip cache dir - id: pip-cache - run: | - echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT - - - name: Cache pip - uses: actions/cache@v4.2.2 - with: - path: ${{ steps.pip-cache.outputs.dir }} - # Look to see if there is a cache hit for the corresponding requirements files - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-docs.txt') }}-${{ hashFiles('**/requirements-tutorials.txt') }}-${{ hashFiles('**/environment-docs.yml') }} - -${{ hashFiles('**/CI.yml') }}-${{ steps.date.outputs.date }} - - - uses: mamba-org/setup-micromamba@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v6.2.0 with: - create-args: python=${{ matrix.python-version }} - environment-file: requirements/environment.yml - init-shell: bash + python-version: ${{ matrix.python-version }} + check-latest: true + cache: 'pip' + cache-dependency-path: pyproject.toml - name: Install dependencies shell: bash -el {0} run: | sudo apt-get update - sudo apt install -y libopenmpi-dev openmpi-bin - # Moved openmpi pandoc and libstdcxx-ng to environment-docs file - # micromamba install -y -c conda-forge openmpi pandoc libstdcxx-ng # fix libstdc++.so.6: version for new scipy versions > 1.9.1 - micromamba env update --file requirements/environment-docs.yml --name elephant + sudo apt install -y libopenmpi-dev openmpi-bin pandoc python -m pip install --upgrade pip + pip install mpi4py pip install -e .[extras,tutorials,docs] - # run notebooks sed -i -E "s/nbsphinx_execute *=.*/nbsphinx_execute = 'always'/g" doc/conf.py - name: List packages - shell: bash -el {0} run: | pip list - micromamba list python --version - name: make html - shell: bash -el {0} run: | cd doc make html - # install dependencies and elephant with pip and run tests with pytest +# _____ _______ _ +# | __ \ ___ ___ |__ __| ___| |_ ___ +# | | | |/ _ \ / __| | |/ _ \/ __| __/ __| +# | |__| | (_) | (__ | | __/\__ \ |_\__ \ +# |_____/ \___/ \___| |_|\___||___/\__|___/ doctests: + needs: setup + name: doctests (${{ matrix.python-version }}, ${{ matrix.os }}) runs-on: ${{ matrix.os }} strategy: matrix: - # python versions for elephant: [3.7, 3.8, 3.9, "3.10"] - python-version: ["3.10"] - - # OS [ubuntu-latest, macos-latest, windows-latest] + python-version: ["3.12"] os: [ubuntu-latest] steps: - # used to reset cache every month - - name: Get current year-month - id: date - run: echo "::set-output name=date::$(date +'%Y-%m')" - - uses: actions/checkout@v4.1.6 + - uses: actions/checkout@v6.0.2 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5.1.0 + uses: actions/setup-python@v6.2.0 with: python-version: ${{ matrix.python-version }} - - - name: Cache test_env - uses: actions/cache@v4.2.2 - with: - path: ~/test_env - # Look to see if there is a cache hit for the corresponding requirements files - # cache will be reset on changes to any requirements or every month - key: ${{ runner.os }}-venv-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/requirements-tests.txt') }} - -${{ hashFiles('**/requirements-extras.txt') }}-${{ hashFiles('**/CI.yml') }}-${{ hashFiles('setup.py') }} - -${{ steps.date.outputs.date }} + check-latest: true + cache: 'pip' + cache-dependency-path: pyproject.toml - name: Install dependencies run: | - # create an environment and install everything - python -m venv ~/test_env - source ~/test_env/bin/activate sudo apt-get update sudo apt install -y libopenmpi-dev openmpi-bin - python -m pip install --upgrade pip pip install mpi4py - pip install pytest-cov coveralls pip install -e .[extras,tests] - name: List packages run: | - source ~/test_env/bin/activate pip list python --version - name: Run doctests run: | - source ~/test_env/bin/activate printf "def pytest_configure(config):\n import numpy as np\n import builtins\n np.set_printoptions(legacy='1.25')\n builtins.np = np\n" > conftest.py - pytest elephant --doctest-modules --ignore=elephant/test/ + pytest elephant --doctest-modules --ignore=elephant/test/ --cov=elephant --cov-report=lcov:coverage.lcov + + - name: Upload coverage to Coveralls + uses: coverallsapp/github-action@v2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + flag-name: doctests + parallel: true + file: coverage.lcov + + + # Coveralls Finish Job + # Combine coverals report and make PR comment + coveralls-finish: + needs: [build-and-test-pip, test-pip-MPI, doctests] + if: always() + runs-on: ubuntu-latest + steps: + - name: Coveralls finished + uses: coverallsapp/github-action@v2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + parallel-finished: true diff --git a/.github/workflows/cache_elephant_data.yml b/.github/workflows/cache_elephant_data.yml index 833faef74..aa769b1de 100644 --- a/.github/workflows/cache_elephant_data.yml +++ b/.github/workflows/cache_elephant_data.yml @@ -29,6 +29,7 @@ jobs: with: path: ~/elephant-data key: datasets-${{ steps.elephant-data.outputs.dataset_hash }} + enableCrossOsArchive: true - name: Cache found? run: echo "Cache-hit == ${{steps.cache-datasets.outputs.cache-hit == 'true'}}" diff --git a/.gitignore b/.gitignore index 6f6651146..f201f8a60 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,9 @@ env/ .pytest_cache/ **/*/__pycache__ *.vscode - +.mypy_cache +.ruff_cache +.venv # Compiled source # ################### *.a diff --git a/elephant/datasets.py b/elephant/datasets.py index fc8ebfc24..f91aed72a 100644 --- a/elephant/datasets.py +++ b/elephant/datasets.py @@ -370,7 +370,7 @@ def download_datasets(repo_path, filepath=None, checksum=None, if local_file.is_file(): # If a checksum is given, check integrity of the local file if checksum and not check_integrity(local_file, checksum): - raise ValueError(f"Local file at {local_file} does " + raise ValueError(f"Local file at {local_file.as_posix()} does " "not agree with MD5 hash " f"{checksum}.") diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..eb4c85a2a --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,55 @@ +[build-system] +requires = ["setuptools >= 61.0"] +build-backend = "setuptools.build_meta" + +[project] +name = "elephant" +dynamic = ["version", "dependencies", "optional-dependencies"] +description = "Elephant (Electrophysiology Analysis Toolkit) is an open-source, community centered library for the analysis of electrophysiological data in the Python programming language. The focus of Elephant is on generic analysis functions for spike train data and time series recordings from electrodes, such as the local field potentials (LFP) or intracellular voltages.In addition to providing a common platform for analysis code from different laboratories, the Elephant project aims to provide a consistent and homogeneous analysis framework that is built on a modular foundation. Elephant is the direct successor to Neurotools and maintains ties to complementary projects such as OpenElectrophy and spykeviewer." +license = "BSD-3-Clause" +license-files = [ "LICENSE.txt"] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Science/Research", + "Natural Language :: English", "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", + "Programming Language :: Python :: 3 :: Only", + "Topic :: Scientific/Engineering"] +keywords = ["neuroscience", "neurophysiology", "electrophysiology", "statistics", "data-analysis"] +readme = {file = "README.md", content-type = "text/markdown"} +requires-python = ">=3.9" + +[tool.setuptools.dynamic] +version = {file = "elephant/VERSION"} +dependencies = {file = "requirements/requirements.txt"} +optional-dependencies.docs = {file = "requirements/requirements-docs.txt"} +optional-dependencies.extras = {file = "requirements/requirements-extras.txt"} +optional-dependencies.opencl = {file = "requirements/requirements-opencl.txt"} +optional-dependencies.cuda = {file = "requirements/requirements-cuda.txt"} +optional-dependencies.tests = {file = "requirements/requirements-tests.txt"} +optional-dependencies.tutorials = {file = "requirements/requirements-tutorials.txt"} + +# Include source files; uses a flat layout +[tool.setuptools.packages.find] +where = ["."] +include = ["elephant*"] + +# Include package data as per MANIFEST.in +[tool.setuptools] +include-package-data = true + +[project.urls] +Homepage = "http://python-elephant.org" +Documentation = "https://elephant.readthedocs.io/en/latest/" +Repository = "https://github.com/NeuralEnsemble/elephant" +Issues = "https://github.com/NeuralEnsemble/elephant/issues" +Changelog = "https://github.com/NeuralEnsemble/elephant/releases" + +# This file was created following this guide: +# https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#writing-pyproject-toml diff --git a/requirements/environment-docs.yml b/requirements/environment-docs.yml index 48e9a2f57..ef95c6d02 100644 --- a/requirements/environment-docs.yml +++ b/requirements/environment-docs.yml @@ -1,21 +1,17 @@ name: elephant channels: - - conda-forge # required for MPI + - conda-forge # required for MPI and pandoc dependencies: - - python=3.12 + - python=3.12 # pinned cause >=3.13 breaks matplotlib<3.9 (RecursionError) + - pip # explicitly adding pip to ensure mamba uses env pip, not base one + - mpi4py - openmpi - pandoc - libstdcxx-ng - - mpi4py - - numpy>=1.19.5 - - scipy - - tqdm - - scikit-learn - - statsmodels - - jinja2 - pip: - - neo>=0.10.0 - - viziphant - # neo, viziphant can be removed once it is integrated into requirements-tutorials.txt + - -r requirements.txt + - -r requirements-extras.txt + - -r requirements-docs.txt + - -r requirements-tutorials.txt diff --git a/requirements/environment-tests.yml b/requirements/environment-tests.yml index 508ed1030..0b20b75f8 100644 --- a/requirements/environment-tests.yml +++ b/requirements/environment-tests.yml @@ -4,17 +4,10 @@ channels: - conda-forge # required for MPI dependencies: - - python>=3.8 - + - python>=3.9 - mpi4py - - numpy>=1.19.5 - - scipy - - tqdm - - scikit-learn - - statsmodels - - jinja2 + - openmpi - pip: - - neo>=0.10.0 - - nixio>=1.5.0 - # - viziphant - # neo, viziphant can be removed once it is integrated into requirements-tutorials.txt + - -r requirements.txt + - -r requirements-extras.txt + - -r requirements-tests.txt diff --git a/requirements/environment.yml b/requirements/environment.yml index fa8fb6e1d..42e0bb4e6 100644 --- a/requirements/environment.yml +++ b/requirements/environment.yml @@ -4,15 +4,9 @@ channels: - conda-forge # required for MPI dependencies: - - python>=3.8 + - python>=3.9 - mpi4py - - numpy>=1.19.5, <2 - - scipy>=1.10.0 - - tqdm - - scikit-learn - - statsmodels - - jinja2 - pip: - - neo>=0.10.0 - - viziphant - # neo, viziphant can be removed once it is integrated into requirements-tutorials.txt + - -r requirements.txt + - -r requirements-extras.txt + - -r requirements-tutorials.txt diff --git a/requirements/requirements-tests.txt b/requirements/requirements-tests.txt index b74c40190..3c04d1616 100644 --- a/requirements/requirements-tests.txt +++ b/requirements/requirements-tests.txt @@ -1,2 +1,3 @@ pytest +pytest-cov nixio>=1.5.0 diff --git a/requirements/requirements-tutorials.txt b/requirements/requirements-tutorials.txt index 5c142ab15..e7b3f4e92 100644 --- a/requirements/requirements-tutorials.txt +++ b/requirements/requirements-tutorials.txt @@ -1,4 +1,5 @@ # Packages required to execute jupyter notebook tutorials matplotlib>=3.3.2, <3.9.0 h5py>=3.1.0 -nixio>=1.5.0 \ No newline at end of file +nixio>=1.5.0 +viziphant diff --git a/requirements/requirements.txt b/requirements/requirements.txt index bdcdac60a..15f34e161 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -2,5 +2,4 @@ neo>=0.10.0 numpy>=2.0.0 quantities>=0.14.1 scipy>=1.10.0 -six>=1.10.0 tqdm diff --git a/setup.py b/setup.py index 349c79591..d7ad8f238 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -import os.path import platform import sys @@ -7,19 +5,6 @@ from setuptools.command.install import install from setuptools.command.develop import develop -with open(os.path.join(os.path.dirname(__file__), - "elephant", "VERSION")) as version_file: - version = version_file.read().strip() - -with open("README.md") as f: - long_description = f.read() -with open('requirements/requirements.txt') as fp: - install_requires = fp.read().splitlines() -extras_require = {} -for extra in ['extras', 'docs', 'tests', 'tutorials', 'cuda', 'opencl']: - with open('requirements/requirements-{0}.txt'.format(extra)) as fp: - extras_require[extra] = fp.read() - if platform.system() == "Windows": fim_module = Extension( name='elephant.spade_src.fim', @@ -62,41 +47,7 @@ optional=True ) -setup_kwargs = { - "name": "elephant", - "version": version, - "packages": ['elephant', 'elephant.test'], - "include_package_data": True, - "install_requires": install_requires, - "extras_require": extras_require, - "author": "Elephant authors and contributors", - "author_email": "contact@python-elephant.org", - "description": "Elephant is a package for analysis of electrophysiology data in Python", # noqa - "long_description": long_description, - "long_description_content_type": "text/markdown", - "license": "BSD", - "url": 'http://python-elephant.org', - "project_urls": { - "Bug Tracker": "https://github.com/NeuralEnsemble/elephant/issues", - "Documentation": "https://elephant.readthedocs.io/en/latest/", - "Source Code": "https://github.com/NeuralEnsemble/elephant", - }, - "python_requires": ">=3.9", - "classifiers": [ - 'Development Status :: 5 - Production/Stable', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: BSD License', - 'Natural Language :: English', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'Programming Language :: Python :: 3.12', - 'Programming Language :: Python :: 3.13', - 'Programming Language :: Python :: 3 :: Only', - 'Topic :: Scientific/Engineering'] -} +setup_kwargs = {} # no compile options and corresponding extensions options = {"--no-compile": None, "--no-compile-spade": fim_module}