Skip to content

Commit

Permalink
ENH: Use setuptools_scm to set the version (mne-tools#11517)
Browse files Browse the repository at this point in the history
  • Loading branch information
larsoner authored Mar 2, 2023
1 parent 8667612 commit 3bf04ed
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ MNE-brainstorm-data*
physionet-sleep-data*
MEGSIM*
build
mne/_version.py
coverage
htmlcov
.cache/
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ docstring:
@$(PYTESTS) --doctest-modules mne/tests/test_docstring_parameters.py

check-manifest:
check-manifest -q --ignore .circleci/config.yml,doc,logo,mne/io/*/tests/data*,mne/io/tests/data,mne/preprocessing/tests/data,.DS_Store
check-manifest -q --ignore .circleci/config.yml,doc,logo,mne/io/*/tests/data*,mne/io/tests/data,mne/preprocessing/tests/data,.DS_Store,mne/_version.py

check-readme: clean wheel_quiet
twine check dist/*
Expand Down
9 changes: 8 additions & 1 deletion mne/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@
# Dev branch marker is: 'X.Y.devN' where N is an integer.
#

from ._version import __version__
try:
from importlib.metadata import version
__version__ = version("mne")
except Exception:
try:
from ._version import __version__
except ImportError:
__version__ = '0.0.0'

# have to import verbose first since it's needed by many things
from .utils import (set_log_level, set_log_file, verbose, set_config,
Expand Down
6 changes: 0 additions & 6 deletions mne/_version.py

This file was deleted.

3 changes: 2 additions & 1 deletion requirements_base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ pooch>=1.5
decorator
packaging
jinja2
importlib_resources>=5.10.2
importlib_resources>=5.10.2
importlib_metadata; python_version < '3.8'
18 changes: 5 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,13 @@ def parse_requirements_file(fname):
return requirements


# get the version (don't import mne here, so dependencies are not needed)
version = None
with open(op.join('mne', '_version.py'), 'r') as fid:
for line in (line.strip() for line in fid):
if line.startswith('__version__'):
version = line.split('=')[1].strip().strip('\'')
break
if version is None:
raise RuntimeError('Could not determine version')


DISTNAME = 'mne'
DESCRIPTION = 'MNE-Python project for MEG and EEG data analysis.'
MAINTAINER = 'Alexandre Gramfort'
MAINTAINER_EMAIL = '[email protected]'
URL = 'https://mne.tools/dev/'
LICENSE = 'BSD-3-Clause'
DOWNLOAD_URL = 'http://github.com/mne-tools/mne-python'
VERSION = version


def package_tree(pkgroot):
Expand Down Expand Up @@ -74,7 +62,6 @@ def package_tree(pkgroot):
description=DESCRIPTION,
license=LICENSE,
url=URL,
version=VERSION,
download_url=DOWNLOAD_URL,
long_description=long_description,
long_description_content_type='text/x-rst',
Expand All @@ -100,6 +87,11 @@ def package_tree(pkgroot):
platforms='any',
python_requires='>=3.7',
install_requires=install_requires,
setup_requires=["setuptools>=45", "setuptools_scm>=6.2"],
use_scm_version={
"write_to": "mne/_version.py",
"version_scheme": "release-branch-semver",
},
extras_require={
'data': data_requires,
'hdf5': hdf5_requires,
Expand Down

0 comments on commit 3bf04ed

Please sign in to comment.