Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into pr/bjourne/1548
Browse files Browse the repository at this point in the history
  • Loading branch information
mstimberg committed Dec 20, 2024
2 parents 8245aa9 + 948dc4b commit 8ca7d44
Show file tree
Hide file tree
Showing 34 changed files with 903 additions and 931 deletions.
72 changes: 72 additions & 0 deletions .codemeta/codemeta_base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"@context": "https://w3id.org/codemeta/3.0",
"@type": "SoftwareSourceCode",
"targetProduct": {
"@type": "SoftwareLibrary",
"name": "brian2",
"runtimePlatform": [
"Python",
"Python 3"
]
},
"maintainer": [
{
"@id": "https://orcid.org/0000-0002-2648-4790"
}
],
"author": [
{
"@id": "https://orcid.org/0000-0002-2648-4790",
"@type": "Person",
"familyName": "Stimberg",
"givenName": "Marcel",
"identifier": "https://github.com/mstimberg"
},
{
"@id": "https://orcid.org/0000-0003-1007-6474",
"@type": "Person",
"familyName": "Goodman",
"givenName": "Dan F. M.",
"identifier": "https://github.com/thesamovar"
},
{
"@id": "https://orcid.org/0000-0002-1734-6070",
"@type": "Person",
"familyName": "Evans",
"givenName": "Benjamin D.",
"identifier": "https://github.com/bdevans"
},
{
"@id": "https://orcid.org/0000-0003-0110-1623",
"@type": "Person",
"familyName": "Brette",
"givenName": "Romain",
"identifier": "https://github.com/romainbrette"
}
],
"codeRepository": "https://github.com/brian-team/brian2",
"continuousIntegration": "https://github.com/brian-team/brian2/actions",
"issueTracker": "https://github.com/brian-team/brian2/issues",
"keywords": [
"biological neural networks",
"computational neuroscience",
"neural networks",
"research",
"simulation",
"spiking neurons"
],
"operatingSystem": "OS Independent",
"softwareHelp": "https://brian2.readthedocs.io/",
"developmentStatus": "active",
"description": "A clock-driven simulator for spiking neural networks",
"license": "https://spdx.org/licenses/CECILL-2.1",
"name": "Brian simulator",
"url": "https://briansimulator.org",
"programmingLanguage": [
"Python"
],
"runtimePlatform": [
"Python",
"Python 3"
]
}
52 changes: 52 additions & 0 deletions .codemeta/create_codemeta.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import re
import os
import pkg_resources
import tomllib
import json
import sys


if __name__ == "__main__":
if not len(sys.argv) == 2:
raise ValueError("Usage: python create_codemeta.py <version>")
basedir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")

with open(os.path.join(basedir, "pyproject.toml"), "rb") as f:
pyproject = tomllib.load(f)
with open(os.path.join(basedir, ".codemeta", "codemeta_base.json"), "r", encoding="utf-8") as f:
codemeta = json.load(f)
with open(os.path.join(basedir, "AUTHORS"), "r", encoding="utf-8") as f:
authors = f.read().splitlines()[6:]

# Add software requirements from pyproject.toml
parsed_deps = pkg_resources.parse_requirements(pyproject['project']['dependencies'])
codemeta["softwareRequirements"] = []
for dep in parsed_deps:
version = ",".join(f"{op}{v}" for op,v in dep.specs)
requirement = {"name": dep.project_name,"@type": "SoftwareApplication", "runtimePlatform": "Python 3"}
if version:
requirement["version"] = version
codemeta["softwareRequirements"].append(requirement)

# Add contributors from AUTHORS
codemeta["contributor"] = []
for author in authors:
matches = re.match(r"^(\w[\w-]*?) ([\w]+[.]? )??(\w+) \(@(.*)\)$", author)
if not matches:
raise ValueError("author not matched:", author)
given_name, middle_name, family_name, github = matches.groups()

contributor = {"@type": "Person", "givenName": given_name, "familyName": family_name, "identifier": f"https://github.com/{github}"}
# FIXME: additionalName does not seem to be recognized by codemeta (validation fails)
if middle_name:
contributor["givenName"] += " " + middle_name.strip()
codemeta["contributor"].append(contributor)

# Add version from setuptools_scm
version = sys.argv[1]
codemeta["version"] = version
codemeta["softwareVersion"] = version

# Write codemeta.json
with open(os.path.join(basedir, "codemeta.json"), "w", encoding="utf-8") as f:
json.dump(codemeta, f, indent=2, ensure_ascii=False)
38 changes: 38 additions & 0 deletions .github/workflows/post_release_updates.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Update metadata after release

on: workflow_dispatch

jobs:
build:
runs-on: ubuntu-latest
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
persist-credentials: true # Needed to push changes back to the repository
fetch-depth: 0
fetch-tags: true
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install dependencies
run: python -m pip install cffconvert pyaml ruamel.yaml requests
- name: Update metadata
run: python dev/continuous-integration/update_zenodo_swh.py
- name: Verify CITATION.cff
run: cffconvert --validate
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
delete-branch: true
branch: update-metadata-post-release
title: Update CITATION.cff and README.md with metadata from Zenodo/SWH
commit-message: |
Update CITATION.cff and README.md with metadata from Zenodo/SWH
[ci skip]
27 changes: 21 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ windows-latest, macOS-12, macOS-14 ]
os: [ windows-latest, macOS-13, macOS-14 ]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Set up Python 3.x
uses: actions/setup-python@v5
with:
Expand All @@ -48,7 +49,7 @@ jobs:
path: ${{ steps.cibuildwheel-cache.outputs.dir }}
key: ${{ runner.os }}-cibuildwheel
- name: Build wheels
uses: pypa/cibuildwheel@v2.19.2
uses: pypa/cibuildwheel@v2.22.0
env:
CIBW_PROJECT_REQUIRES_PYTHON: ">=${{ needs.get_python_versions.outputs.min-python }}"
CIBW_ARCHS: auto64
Expand Down Expand Up @@ -76,6 +77,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Set up Python 3.x
uses: actions/setup-python@v5
with:
Expand Down Expand Up @@ -106,7 +108,7 @@ jobs:
path: ${{ steps.cibuildwheel-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.arch }}-cibuildwheel
- name: Build wheels
uses: pypa/cibuildwheel@v2.19.2
uses: pypa/cibuildwheel@v2.22.0
env:
CIBW_PROJECT_REQUIRES_PYTHON: ">=${{ needs.get_python_versions.outputs.min-python }}"
CIBW_ARCHS_LINUX: ${{ matrix.arch }}
Expand Down Expand Up @@ -168,9 +170,13 @@ jobs:
name: Build docker image
runs-on: ubuntu-latest
needs: build-linux
# Skip everything for PR authors that do not have permission to access secrets
if: ${{ github.event.pull_request.author_association != 'COLLABORATOR' && github.event.pull_request.author_association != 'OWNER' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
# https://github.com/actions/checkout/
- name: Docker meta
id: meta
Expand All @@ -179,9 +185,9 @@ jobs:
with:
images: |
briansimulator/brian
ghcr.io/brian-team/brian
flavor: latest=true
tags: |
# type=semver,pattern={{raw}}
type=ref,event=tag
labels: |
org.opencontainers.image.title="Brian Docker Image"
Expand All @@ -203,6 +209,13 @@ jobs:
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
if: ${{ github.repository == 'brian-team/brian2' && github.actor != 'dependabot[bot]'}}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: load Linux x86 distribution 📦
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -235,5 +248,7 @@ jobs:
'BASE_IMAGE_TAG=3.12-bookworm'
platforms: 'amd64,arm64'
push: true
tags: briansimulator/brian-dev:dev-${{ github.ref_name }}
labels: ${{ steps.meta.outputs.labels }}
tags: |
briansimulator/brian-dev:dev-${{ github.ref_name }}
ghcr.io/brian-team/brian-dev:dev-${{ github.ref_name }}
labels: ${{ steps.meta.outputs.labels }}
29 changes: 29 additions & 0 deletions .github/workflows/static_analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: " GitHub Actions Security Analysis with Zizmor"

# The scheduled workflow runs every Sunday at 23:45 UTC.
on:
push:
schedule:
- cron: '45 23 * * 0'

jobs:
build:
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Get zizmor
run: cargo install zizmor
# https://github.com/woodruffw/zizmor
- name: Run zizmor
run: zizmor --format sarif . > results.sarif
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: results.sarif
category: zizmor
46 changes: 31 additions & 15 deletions .github/workflows/test_latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ jobs:
matrix:
os: [{image: ubuntu-latest, triplet: x64-linux},
{image: windows-latest, triplet: x64-windows},
{image: macOS-12, triplet: x64-osx},
{image: macOS-14, triplet: arm64-osx}]
{image: macOS-13, triplet: x64-osx},
{image: macOS-latest, triplet: arm64-osx}]
standalone: [false, true]
float_dtype_32: [false, true]
python-version: ["${{ needs.get_python_versions.outputs.max-python }}"]
Expand All @@ -41,6 +41,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Install GSL
uses: johnwason/vcpkg-action@v6
id: vcpkg
Expand All @@ -65,24 +66,32 @@ jobs:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Install dependencies
shell: bash
env:
PYTHON_BINARY: ${{ steps.python.outputs.python-path }}
run: |
${{ steps.python.outputs.python-path }} -m pip install --upgrade pip setuptools
${{ steps.python.outputs.python-path }} -m pip install --pre -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy scipy
${{ steps.python.outputs.python-path }} -m pip install mpmath # install stable version
${{ steps.python.outputs.python-path }} -m pip install --pre pytest pytest-xdist pytest-cov pytest-timeout cython sympy pyparsing jinja2 sphinx
"$PYTHON_BINARY" -m pip install --upgrade pip setuptools
"$PYTHON_BINARY" -m pip install --pre -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy scipy
"$PYTHON_BINARY" -m pip install mpmath # install stable version
"$PYTHON_BINARY" -m pip install --pre pytest pytest-xdist pytest-cov pytest-timeout cython sympy pyparsing jinja2 sphinx
- name: Install Brian2
shell: bash
env:
PYTHON_BINARY: ${{ steps.python.outputs.python-path }}
run: |
cp numpy2.pyproject.toml pyproject.toml
${{ steps.python.outputs.python-path }} -m pip install --pre -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple --extra-index-url https://pypi.org/simple .
"$PYTHON_BINARY" -m pip install --pre -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple --extra-index-url https://pypi.org/simple .
- name: Run Tests
shell: bash
run: |
cd ${{ github.workspace }}/.. # move out of the workspace to avoid direct import
${{ steps.python.outputs.python-path }} -Wd ${{ github.workspace }}/dev/continuous-integration/run_test_suite.py
cd "$GITHUB_WORKSPACE"/.. # move out of the workspace to avoid direct import
"$PYTHON_BINARY" -Wd "$GITHUB_WORKSPACE/dev/continuous-integration/run_test_suite.py"
env:
AGENT_OS: ${{runner.os}}
STANDALONE: ${{ matrix.standalone }}
FLOAT_DTYPE_32: ${{ matrix.float_dtype_32 }}
DO_NOT_RESET_PREFERENCES: true # Make sure that GSL setting is used
PYTHON_BINARY: ${{ steps.python.outputs.python-path }}

test-deprecations:
needs: [ get_python_versions ]
Expand All @@ -99,6 +108,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Install GSL
uses: johnwason/vcpkg-action@v6
id: vcpkg
Expand All @@ -116,16 +126,21 @@ jobs:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Install dependencies
env:
PYTHON_BINARY: ${{ steps.python.outputs.python-path }}
run: |
${{ steps.python.outputs.python-path }} -m pip install --upgrade pip setuptools
${{ steps.python.outputs.python-path }} -m pip install --pre -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy scipy
${{ steps.python.outputs.python-path }} -m pip install --pre pytest cython sympy pyparsing jinja2 sphinx
"$PYTHON_BINARY" -m pip install --upgrade pip setuptools
"$PYTHON_BINARY" -m pip install --pre -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy scipy
"$PYTHON_BINARY" -m pip install --pre pytest cython sympy pyparsing jinja2 sphinx
- name: Install Brian2
run: ${{ steps.python.outputs.python-path }} -m pip install --pre -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple --extra-index-url https://pypi.org/simple .
env:
PYTHON_BINARY: ${{ steps.python.outputs.python-path }}
run: |
"$PYTHON_BINARY" -m pip install --pre -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple --extra-index-url https://pypi.org/simple .
- name: Determine Cython cache dir
id: cython-cache
run: |
CACHE_DIR=$(python -c 'import os; from Cython.Utils import get_cython_cache_dir; print(os.path.join(get_cython_cache_dir(), "brian_extensions"))')
CACHE_DIR=$(python -c 'from brian2.codegen.runtime.cython_rt.extension_manager import get_cython_cache_dir; print(get_cython_cache_dir())')
echo "Cython cache dir: $CACHE_DIR"
echo "cachedir=$CACHE_DIR" >> "$GITHUB_OUTPUT"
- name: restore Cython cache
Expand All @@ -137,8 +152,9 @@ jobs:
- name: Run Tests
run: |
cd ${{ github.workspace }}/.. # move out of the workspace to avoid direct import
${{ steps.python.outputs.python-path }} -Wd ${{ github.workspace }}/dev/continuous-integration/run_test_suite.py || echo "Tests failed (but not marked as failed on GA)"
"$PYTHON_BINARY" -Wd ${{ github.workspace }}/dev/continuous-integration/run_test_suite.py || echo "Tests failed (but not marked as failed on GA)"
env:
DEPRECATION_ERROR: true
AGENT_OS: linux
STANDALONE: ${{ matrix.standalone }}
PYTHON_BINARY: ${{ steps.python.outputs.python-path }}
Loading

0 comments on commit 8ca7d44

Please sign in to comment.