Skip to content

Commit

Permalink
Merge pull request #1475 from brian-team/move_to_setuptools_scm
Browse files Browse the repository at this point in the history
Upgrade build infrastructure
  • Loading branch information
mstimberg committed Jun 28, 2023
2 parents 4755e70 + 365972e commit 4a71364
Show file tree
Hide file tree
Showing 13 changed files with 115 additions and 830 deletions.
4 changes: 4 additions & 0 deletions .git_archival.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node: $Format:%H$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
ref-names: $Format:%D$
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ MANIFEST.in text
*.png binary
*.pptx binary

brian2/_version.py export-subst
.git_archival.txt export-subst
6 changes: 3 additions & 3 deletions .github/workflows/publish_to_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ jobs:
python-version: '3.x'
- name: Build source tarball
run: |
python -m pip install --upgrade pip
python -m pip install "cython>=0.29" oldest-supported-numpy setuptools versioneer
python setup.py sdist --formats=gztar --with-cython --fail-on-error
python -m pip install --upgrade pip build
python -m pip install "cython>=0.29" oldest-supported-numpy "setuptools>=61" "setuptools_scm[toml]>=6.2"
python -m build --sdist --config-setting=--formats=gztar --config-setting=--with-cython --config-setting=--fail-on-error
if: ${{ matrix.arch == 'auto64' }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
brian2/_version.py
/dev/ideas/randomkit/CUBA
/brian2/random/randomkit/randkit.c
/dev/benchmarks/compare_to_brian1.png
Expand Down
7 changes: 2 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,23 @@ repos:
rev: v3.4.0
hooks:
- id: pyupgrade
args: [--py38-plus]
exclude: '^brian2/_version.py$'
args: [--py39-plus]
files: '^brian2/.*\.pyi?$'
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
# We exclude all __init__.py files, since we use wildcard imports, etc.
exclude: '^brian2/_version[.]py$|^brian2/tests/.*$|^brian2/.*__init__[.]py$'
exclude: '^brian2/tests/.*$|^brian2/.*__init__[.]py$'
files: '^brian2/.*\.pyi?$'
additional_dependencies: ['flake8-bugbear==23.5.9']
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
exclude: '^brian2/_version.py$'
files: '^brian2/.*\.pyi?$'
- repo: https://github.com/psf/black
rev: '22.10.0'
hooks:
- id: black
exclude: '^brian2/_version.py$'
files: '^brian2/.*\.pyi?$'
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ exclude *.yml
exclude .coveragerc
exclude .gitattributes
exclude .gitmodules
include versioneer.py
include brian2/_version.py
49 changes: 27 additions & 22 deletions brian2/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Brian 2
"""
import logging


def _check_dependencies():
Expand Down Expand Up @@ -41,29 +42,41 @@ def _check_dependencies():
from pylab import *
except ImportError:
# Do the non-matplotlib pylab imports manually
from numpy import *
from numpy.fft import *
from numpy.random import *
from numpy.linalg import *
import numpy.ma as ma

# don't let numpy's datetime hide stdlib
import datetime

from ._version import get_versions as _get_versions

__version__ = _get_versions()["version"]
__release_date__ = _get_versions()["date"]

if __release_date__ is not None:
__release_date__ = __release_date__[:10] # only use date part
__git_revision__ = _get_versions()["full-revisionid"]
import numpy.ma as ma
from numpy import *
from numpy.fft import *
from numpy.linalg import *
from numpy.random import *

# Make sure that Brian's unit-aware functions are used, even when directly
# using names prefixed with numpy or np
import brian2.numpy_ as numpy
import brian2.numpy_ as np

try:
from ._version import __version__, __version_tuple__
except ImportError:
try:
from setuptools_scm import get_version

__version__ = get_version(
root="..",
relative_to=__file__,
version_scheme="post-release",
local_scheme="no-local-version",
)
__version_tuple__ = tuple(int(x) for x in __version__.split(".")[:3])
except ImportError:
logging.getLogger("brian2").warn(
"Cannot determine Brian version, running from source and "
"setuptools_scm is not installed."
)
__version__ = "unknown"
__version_tuple__ = (0, 0, 0)

# delete some annoying names from the namespace
if "x" in globals():
del x
Expand Down Expand Up @@ -211,11 +224,3 @@ def _check_caches():


_check_caches()

from . import _version

__version__ = _version.get_versions()["version"]

from . import _version

__version__ = _version.get_versions()["version"]

0 comments on commit 4a71364

Please sign in to comment.