From b069d4abd7bd7b39973c9fcbf0d9ada02b5e4b19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20H=C3=B6chenberger?= Date: Tue, 3 Oct 2023 20:10:44 +0200 Subject: [PATCH] Move more metadata and build flags from setup.py to pyproject.toml (#12060) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Eric Larson --- mne/_ola.py | 2 +- mne/beamformer/_lcmv.py | 2 +- mne/datasets/brainstorm/bst_auditory.py | 2 +- mne/datasets/brainstorm/bst_phantom_ctf.py | 2 +- mne/datasets/brainstorm/bst_phantom_elekta.py | 2 +- mne/datasets/brainstorm/bst_raw.py | 2 +- mne/datasets/brainstorm/bst_resting.py | 2 +- mne/datasets/sleep_physionet/age.py | 6 +- mne/datasets/sleep_physionet/temazepam.py | 4 +- mne/datasets/tests/test_datasets.py | 2 +- mne/decoding/base.py | 2 +- mne/decoding/csp.py | 4 +- mne/decoding/transformer.py | 6 +- mne/minimum_norm/resolution_matrix.py | 6 +- mne/preprocessing/ecg.py | 2 +- mne/time_frequency/multitaper.py | 4 +- mne/viz/montage.py | 2 +- pyproject.toml | 93 ++++++++++++++++++- setup.py | 88 ------------------ tutorials/inverse/50_beamformer_lcmv.py | 2 +- .../preprocessing/25_background_filtering.py | 6 +- .../preprocessing/45_projectors_background.py | 8 +- tutorials/stats-sensor-space/20_erp_stats.py | 2 +- 23 files changed, 125 insertions(+), 126 deletions(-) diff --git a/mne/_ola.py b/mne/_ola.py index 75b850ee5b7..c17a47ffce6 100644 --- a/mne/_ola.py +++ b/mne/_ola.py @@ -281,7 +281,7 @@ def __init__( window="hann", tol=1e-10, *, - verbose=None + verbose=None, ): n_samples = _ensure_int(n_samples, "n_samples") n_overlap = _ensure_int(n_overlap, "n_overlap") diff --git a/mne/beamformer/_lcmv.py b/mne/beamformer/_lcmv.py index 10ce4c431e2..0abf671c716 100644 --- a/mne/beamformer/_lcmv.py +++ b/mne/beamformer/_lcmv.py @@ -207,7 +207,7 @@ def make_lcmv( noise_cov=noise_cov, rank=rank, pca=False, - **depth + **depth, ) ch_names = list(info["ch_names"]) diff --git a/mne/datasets/brainstorm/bst_auditory.py b/mne/datasets/brainstorm/bst_auditory.py index a45dc72b5cf..f6cbd7c4e43 100644 --- a/mne/datasets/brainstorm/bst_auditory.py +++ b/mne/datasets/brainstorm/bst_auditory.py @@ -33,7 +33,7 @@ def data_path( download=True, accept=False, *, - verbose=None + verbose=None, ): # noqa: D103 return _download_mne_dataset( name="bst_auditory", diff --git a/mne/datasets/brainstorm/bst_phantom_ctf.py b/mne/datasets/brainstorm/bst_phantom_ctf.py index 147626d33b6..9a64a438e89 100644 --- a/mne/datasets/brainstorm/bst_phantom_ctf.py +++ b/mne/datasets/brainstorm/bst_phantom_ctf.py @@ -22,7 +22,7 @@ def data_path( download=True, accept=False, *, - verbose=None + verbose=None, ): # noqa: D103 return _download_mne_dataset( name="bst_phantom_ctf", diff --git a/mne/datasets/brainstorm/bst_phantom_elekta.py b/mne/datasets/brainstorm/bst_phantom_elekta.py index 8e5b5a8a69c..b5e13d385f3 100644 --- a/mne/datasets/brainstorm/bst_phantom_elekta.py +++ b/mne/datasets/brainstorm/bst_phantom_elekta.py @@ -22,7 +22,7 @@ def data_path( download=True, accept=False, *, - verbose=None + verbose=None, ): # noqa: D103 return _download_mne_dataset( name="bst_phantom_elekta", diff --git a/mne/datasets/brainstorm/bst_raw.py b/mne/datasets/brainstorm/bst_raw.py index f8d92e0b26c..3aeef5e49d2 100644 --- a/mne/datasets/brainstorm/bst_raw.py +++ b/mne/datasets/brainstorm/bst_raw.py @@ -38,7 +38,7 @@ def data_path( download=True, accept=False, *, - verbose=None + verbose=None, ): # noqa: D103 return _download_mne_dataset( name="bst_raw", diff --git a/mne/datasets/brainstorm/bst_resting.py b/mne/datasets/brainstorm/bst_resting.py index 9e2f8f7e73b..cef6ab986c6 100644 --- a/mne/datasets/brainstorm/bst_resting.py +++ b/mne/datasets/brainstorm/bst_resting.py @@ -25,7 +25,7 @@ def data_path( download=True, accept=False, *, - verbose=None + verbose=None, ): # noqa: D103 return _download_mne_dataset( name="bst_resting", diff --git a/mne/datasets/sleep_physionet/age.py b/mne/datasets/sleep_physionet/age.py index 0a7fb174d1c..b0d23a94b07 100644 --- a/mne/datasets/sleep_physionet/age.py +++ b/mne/datasets/sleep_physionet/age.py @@ -29,7 +29,7 @@ def fetch_data( base_url=BASE_URL, on_missing="raise", *, - verbose=None + verbose=None, ): # noqa: D301, E501 """Get paths to local copies of PhysioNet Polysomnography dataset files. @@ -134,12 +134,12 @@ def fetch_data( psg_fname, pdl = _fetch_one( psg_records["fname"][idx].decode(), psg_records["sha"][idx].decode(), - *params + *params, ) hyp_fname, hdl = _fetch_one( hyp_records["fname"][idx].decode(), hyp_records["sha"][idx].decode(), - *params + *params, ) fnames.append([psg_fname, hyp_fname]) if pdl: diff --git a/mne/datasets/sleep_physionet/temazepam.py b/mne/datasets/sleep_physionet/temazepam.py index 4f3071300ab..8a6efc19a9a 100644 --- a/mne/datasets/sleep_physionet/temazepam.py +++ b/mne/datasets/sleep_physionet/temazepam.py @@ -104,12 +104,12 @@ def fetch_data( psg_fname, pdl = _fetch_one( records["psg fname"][idx].decode(), records["psg sha"][idx].decode(), - *params + *params, ) hyp_fname, hdl = _fetch_one( records["hyp fname"][idx].decode(), records["hyp sha"][idx].decode(), - *params + *params, ) fnames.append([psg_fname, hyp_fname]) if pdl: diff --git a/mne/datasets/tests/test_datasets.py b/mne/datasets/tests/test_datasets.py index 6b43565cf33..211dd4d0b1c 100644 --- a/mne/datasets/tests/test_datasets.py +++ b/mne/datasets/tests/test_datasets.py @@ -205,7 +205,7 @@ def test_fetch_parcellations(tmp_path): labels, parc="HCPMMP1_round", table_name="./left.fsaverage164.label.gii", - **kwargs + **kwargs, ) orig = op.join(this_subjects_dir, "fsaverage", "label", "lh.HCPMMP1.annot") first = hashfunc(orig) diff --git a/mne/decoding/base.py b/mne/decoding/base.py index eaf7ecfa3ae..6489b7f113a 100644 --- a/mne/decoding/base.py +++ b/mne/decoding/base.py @@ -419,7 +419,7 @@ def _fit_and_score( error_score="raise", *, verbose=None, - position=0 + position=0, ): """Fit estimator and compute scores for a given dataset split.""" # This code is adapted from sklearn diff --git a/mne/decoding/csp.py b/mne/decoding/csp.py index 34f1950c627..abb85afc2e9 100644 --- a/mne/decoding/csp.py +++ b/mne/decoding/csp.py @@ -281,7 +281,7 @@ def plot_patterns( name_format="CSP%01d", nrows=1, ncols="auto", - show=True + show=True, ): """Plot topographic patterns of components. @@ -412,7 +412,7 @@ def plot_filters( name_format="CSP%01d", nrows=1, ncols="auto", - show=True + show=True, ): """Plot topographic filters of components. diff --git a/mne/decoding/transformer.py b/mne/decoding/transformer.py index 29b33dde86b..9675f7bef0c 100644 --- a/mne/decoding/transformer.py +++ b/mne/decoding/transformer.py @@ -383,7 +383,7 @@ def __init__( n_jobs=None, normalization="length", *, - verbose=None + verbose=None, ): # noqa: D102 self.sfreq = sfreq self.fmin = fmin @@ -512,7 +512,7 @@ def __init__( iir_params=None, fir_design="firwin", *, - verbose=None + verbose=None, ): # noqa: D102 self.info = info self.l_freq = l_freq @@ -838,7 +838,7 @@ def __init__( fir_window="hamming", fir_design="firwin", *, - verbose=None + verbose=None, ): # noqa: D102 self.l_freq = l_freq self.h_freq = h_freq diff --git a/mne/minimum_norm/resolution_matrix.py b/mne/minimum_norm/resolution_matrix.py index 1114c25722b..a01ece26ccb 100644 --- a/mne/minimum_norm/resolution_matrix.py +++ b/mne/minimum_norm/resolution_matrix.py @@ -78,7 +78,7 @@ def _get_psf_ctf( norm, return_pca_vars, vector=False, - verbose=None + verbose=None, ): """Get point-spread (PSFs) or cross-talk (CTFs) functions.""" # check for consistencies in input parameters @@ -302,7 +302,7 @@ def get_point_spread( norm=False, return_pca_vars=False, vector=False, - verbose=None + verbose=None, ): """Get point-spread (PSFs) functions for vertices. @@ -351,7 +351,7 @@ def get_cross_talk( norm=False, return_pca_vars=False, vector=False, - verbose=None + verbose=None, ): """Get cross-talk (CTFs) function for vertices. diff --git a/mne/preprocessing/ecg.py b/mne/preprocessing/ecg.py index a7ee6a81213..388fe9e416d 100644 --- a/mne/preprocessing/ecg.py +++ b/mne/preprocessing/ecg.py @@ -530,7 +530,7 @@ def _make_ecg(inst, start, stop, reject_by_annotation=False, verbose=None): picks, return_times=True, **kwargs, - reject_by_annotation=reject_by_annotation + reject_by_annotation=reject_by_annotation, ) elif isinstance(inst, BaseEpochs): ecg = np.hstack(inst.copy().get_data(picks, **kwargs)) diff --git a/mne/time_frequency/multitaper.py b/mne/time_frequency/multitaper.py index a3ccad28080..a304d50f6c1 100644 --- a/mne/time_frequency/multitaper.py +++ b/mne/time_frequency/multitaper.py @@ -336,7 +336,7 @@ def psd_array_multitaper( n_jobs=None, *, max_iter=150, - verbose=None + verbose=None, ): r"""Compute power spectral density (PSD) using a multi-taper method. @@ -475,7 +475,7 @@ def tfr_array_multitaper( output="complex", n_jobs=None, *, - verbose=None + verbose=None, ): """Compute Time-Frequency Representation (TFR) using DPSS tapers. diff --git a/mne/viz/montage.py b/mne/viz/montage.py index f81174fa31a..19cd8c12a1b 100644 --- a/mne/viz/montage.py +++ b/mne/viz/montage.py @@ -20,7 +20,7 @@ def plot_montage( sphere=None, *, axes=None, - verbose=None + verbose=None, ): """Plot a montage. diff --git a/pyproject.toml b/pyproject.toml index ac247de714a..a9565e40d5a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,90 @@ +[project] +name = "mne" +description = "MNE-Python project for MEG and EEG data analysis." +maintainers = [ + { name = "Alexandre Gramfort", email = "alexandre.gramfort@inria.fr" }, +] +dynamic = ["version"] +license = { text = "BSD-3-Clause" } +readme = { file = "README.rst", content-type = "text/x-rst" } +requires-python = ">=3.8" +keywords = [ + "neuroscience", + "neuroimaging", + "MEG", + "EEG", + "ECoG", + "fNIRS", + "brain", +] +classifiers = [ + "Intended Audience :: Science/Research", + "Intended Audience :: Developers", + "License :: OSI Approved", + "Programming Language :: Python", + "Topic :: Software Development", + "Topic :: Scientific/Engineering", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX", + "Operating System :: Unix", + "Operating System :: MacOS", + "Programming Language :: Python :: 3", +] + +[project.scripts] +mne = "mne.commands.utils:main" + +[project.urls] +Homepage = "https://mne.tools/" +Download = "https://pypi.org/project/scikit-learn/#files" +"Bug Tracker" = "https://github.com/mne-tools/mne-python/issues/" +Documentation = "https://mne.tools/" +Forum = "https://mne.discourse.group/" +"Source Code" = "https://github.com/mne-tools/mne-python/" + +[build-system] +requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2", "wheel"] +build-backend = "setuptools.build_meta" + +[tool.setuptools_scm] +write_to = "mne/_version.py" +version_scheme = "release-branch-semver" + +[options] +zip_safe = false # the package can run out of an .egg file +include_package_data = true + +[tool.setuptools.package-data] +"mne" = [ + "data/eegbci_checksums.txt", + "data/*.sel", + "data/icos.fif.gz", + "data/coil_def*.dat", + "data/helmets/*.fif.gz", + "data/FreeSurferColorLUT.txt", + "data/image/*gif", + "data/image/*lout", + "data/fsaverage/*.fif", + "channels/data/layouts/*.lout", + "channels/data/layouts/*.lay", + "channels/data/montages/*.sfp", + "channels/data/montages/*.txt", + "channels/data/montages/*.elc", + "channels/data/neighbors/*.mat", + "datasets/sleep_physionet/SHA1SUMS", + "datasets/_fsaverage/*.txt", + "datasets/_infant/*.txt", + "datasets/_phantom/*.txt", + "html/*.js", + "html/*.css", + "html_templates/repr/*.jinja", + "html_templates/report/*.jinja", + "icons/*.svg", + "icons/*.png", + "io/artemis123/resources/*.csv", + "io/edf/gdf_encodes.txt", +] + [tool.codespell] ignore-words = "ignore_words.txt" builtin = "clear,rare,informal,names,usage" @@ -19,12 +106,12 @@ ignore-decorators = [ "setter", "mne.utils.copy_function_doc_to_method_doc", "mne.utils.copy_doc", - "mne.utils.deprecated" + "mne.utils.deprecated", ] [tool.ruff.per-file-ignores] "tutorials/time-freq/10_spectrum_class.py" = [ - "E501" # line too long + "E501", # line too long ] "mne/datasets/*/*.py" = [ "D103", # Missing docstring in public function @@ -52,4 +139,4 @@ junit_family = "xunit2" exclude = "(dist/)|(build/)|(.*\\.ipynb)" [tool.bandit.assert_used] -skips = ["*/test_*.py"] # assert statements are good practice with pytest +skips = ["*/test_*.py"] # assert statements are good practice with pytest diff --git a/setup.py b/setup.py index 7649cdc0f37..d3422b58a6a 100644 --- a/setup.py +++ b/setup.py @@ -22,15 +22,6 @@ def parse_requirements_file(fname): return requirements -DISTNAME = "mne" -DESCRIPTION = "MNE-Python project for MEG and EEG data analysis." -MAINTAINER = "Alexandre Gramfort" -MAINTAINER_EMAIL = "alexandre.gramfort@inria.fr" -URL = "https://mne.tools/dev/" -LICENSE = "BSD-3-Clause" -DOWNLOAD_URL = "http://github.com/mne-tools/mne-python" - - def package_tree(pkgroot): """Get the submodule list.""" # Adapted from VisPy @@ -47,9 +38,6 @@ def package_tree(pkgroot): if op.exists("MANIFEST"): os.remove("MANIFEST") - with open("README.rst", "r") as fid: - long_description = fid.read() - # data_dependencies is empty, but let's leave them so that we don't break # people's workflows who did `pip install mne[data]` install_requires = parse_requirements_file("requirements_base.txt") @@ -59,87 +47,11 @@ def package_tree(pkgroot): "requirements_testing.txt" ) + parse_requirements_file("requirements_testing_extra.txt") setup( - name=DISTNAME, - maintainer=MAINTAINER, - include_package_data=True, - maintainer_email=MAINTAINER_EMAIL, - description=DESCRIPTION, - license=LICENSE, - url=URL, - download_url=DOWNLOAD_URL, - long_description=long_description, - long_description_content_type="text/x-rst", - zip_safe=False, # the package can run out of an .egg file - classifiers=[ - "Intended Audience :: Science/Research", - "Intended Audience :: Developers", - "License :: OSI Approved", - "Programming Language :: Python", - "Topic :: Software Development", - "Topic :: Scientific/Engineering", - "Operating System :: Microsoft :: Windows", - "Operating System :: POSIX", - "Operating System :: Unix", - "Operating System :: MacOS", - "Programming Language :: Python :: 3", - ], - keywords="neuroscience neuroimaging MEG EEG ECoG fNIRS brain", - project_urls={ - "Homepage": "https://mne.tools/", - "Download": "https://pypi.org/project/scikit-learn/#files", - "Bug Tracker": "https://github.com/mne-tools/mne-python/issues/", - "Documentation": "https://mne.tools/", - "Forum": "https://mne.discourse.group/", - "Source Code": "https://github.com/mne-tools/mne-python/", - }, - platforms="any", - python_requires=">=3.8", 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, "test": test_requires, }, packages=package_tree("mne"), - package_data={ - "mne": [ - op.join("data", "eegbci_checksums.txt"), - op.join("data", "*.sel"), - op.join("data", "icos.fif.gz"), - op.join("data", "coil_def*.dat"), - op.join("data", "helmets", "*.fif.gz"), - op.join("data", "FreeSurferColorLUT.txt"), - op.join("data", "image", "*gif"), - op.join("data", "image", "*lout"), - op.join("data", "fsaverage", "*.fif"), - op.join("channels", "data", "layouts", "*.lout"), - op.join("channels", "data", "layouts", "*.lay"), - op.join("channels", "data", "montages", "*.sfp"), - op.join("channels", "data", "montages", "*.txt"), - op.join("channels", "data", "montages", "*.elc"), - op.join("channels", "data", "neighbors", "*.mat"), - op.join("datasets", "sleep_physionet", "SHA1SUMS"), - op.join("datasets", "_fsaverage", "*.txt"), - op.join("datasets", "_infant", "*.txt"), - op.join("datasets", "_phantom", "*.txt"), - op.join("html", "*.js"), - op.join("html", "*.css"), - op.join("html_templates", "repr", "*.jinja"), - op.join("html_templates", "report", "*.jinja"), - op.join("icons", "*.svg"), - op.join("icons", "*.png"), - op.join("io", "artemis123", "resources", "*.csv"), - op.join("io", "edf", "gdf_encodes.txt"), - ] - }, - entry_points={ - "console_scripts": [ - "mne = mne.commands.utils:main", - ] - }, ) diff --git a/tutorials/inverse/50_beamformer_lcmv.py b/tutorials/inverse/50_beamformer_lcmv.py index 6edda3c0aeb..9ccc5371d74 100644 --- a/tutorials/inverse/50_beamformer_lcmv.py +++ b/tutorials/inverse/50_beamformer_lcmv.py @@ -274,7 +274,7 @@ # Could do this for a 3-panel figure: # view_layout='horizontal', views=['coronal', 'sagittal', 'axial'], brain_kwargs=dict(silhouette=True), - **kwargs + **kwargs, ) # %% diff --git a/tutorials/preprocessing/25_background_filtering.py b/tutorials/preprocessing/25_background_filtering.py index a48572285f7..a5ec433ac7c 100644 --- a/tutorials/preprocessing/25_background_filtering.py +++ b/tutorials/preprocessing/25_background_filtering.py @@ -613,7 +613,7 @@ def plot_signal(x, offset): gain, "Chebychev-1 order=8, ripple=1 dB", compensate=True, - **kwargs + **kwargs, ) # %% @@ -632,7 +632,7 @@ def plot_signal(x, offset): gain, "Chebychev-1 order=8, ripple=6 dB", compensate=True, - **kwargs + **kwargs, ) # %% @@ -655,7 +655,7 @@ def plot_signal(x, offset): gain, "Chebychev-1 order=8, ripple=6 dB", compensate=False, - **kwargs + **kwargs, ) # %% diff --git a/tutorials/preprocessing/45_projectors_background.py b/tutorials/preprocessing/45_projectors_background.py index 5a67789b38c..a970def83a1 100644 --- a/tutorials/preprocessing/45_projectors_background.py +++ b/tutorials/preprocessing/45_projectors_background.py @@ -71,7 +71,7 @@ def setup_3d_axes(): arrow_length_ratio=0.1, color="C1", linewidth=1, - linestyle="dashed" + linestyle="dashed", ) # %% @@ -182,7 +182,7 @@ def setup_3d_axes(): *np.concatenate([origin, trigger_effect]).flatten(), arrow_length_ratio=0.1, color="C2", - alpha=0.5 + alpha=0.5, ) # plot the original vector @@ -199,7 +199,7 @@ def setup_3d_axes(): *(projected_point + offset).flat, "({}, {}, {})".format(*np.round(projected_point.flat, 2)), color="C0", - horizontalalignment="right" + horizontalalignment="right", ) # add dashed arrow showing projection @@ -210,7 +210,7 @@ def setup_3d_axes(): arrow_length_ratio=0.1, color="C1", linewidth=1, - linestyle="dashed" + linestyle="dashed", ) # %% diff --git a/tutorials/stats-sensor-space/20_erp_stats.py b/tutorials/stats-sensor-space/20_erp_stats.py index 872b1166056..504a323cbe6 100644 --- a/tutorials/stats-sensor-space/20_erp_stats.py +++ b/tutorials/stats-sensor-space/20_erp_stats.py @@ -132,7 +132,7 @@ mask=significant_points, show_names="all", titles=None, - **time_unit + **time_unit, ) plt.colorbar(axes["Left"].images[-1], ax=list(axes.values()), shrink=0.3, label="µV")