From 134199b4a9f9776fc7fea271e089d83a39828295 Mon Sep 17 00:00:00 2001 From: Christophe Bedetti Date: Sun, 1 Dec 2019 13:04:06 -0500 Subject: [PATCH] Add black flake8 and pylint, update setup.py --- .flake8 | 3 ++ .pylintrc | 3 ++ MANIFEST.in | 3 -- requirements-dev.txt | 6 +-- requirements-test.txt | 6 +++ requirements.txt | 1 - setup.cfg | 2 - setup.py | 96 +++++++++++++++++++++++++++++-------------- tox.ini | 24 +++++++---- 9 files changed, 97 insertions(+), 47 deletions(-) create mode 100644 .flake8 create mode 100644 .pylintrc delete mode 100644 MANIFEST.in create mode 100644 requirements-test.txt delete mode 100644 requirements.txt delete mode 100644 setup.cfg mode change 100644 => 100755 setup.py diff --git a/.flake8 b/.flake8 new file mode 100644 index 00000000..8dd399ab --- /dev/null +++ b/.flake8 @@ -0,0 +1,3 @@ +[flake8] +max-line-length = 88 +extend-ignore = E203 diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 00000000..ee4ae58d --- /dev/null +++ b/.pylintrc @@ -0,0 +1,3 @@ +[pylint] +disable=bad-continuation, + invalid-name, \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 08bb422f..00000000 --- a/MANIFEST.in +++ /dev/null @@ -1,3 +0,0 @@ -include README.md -include LICENSE.txt -include MANIFEST.in diff --git a/requirements-dev.txt b/requirements-dev.txt index c8c7979e..d373740d 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,5 +1,3 @@ +ipython>=7.10.0 mkdocs>=1.0.4 -pybids>=0.8.0 -pytest>=4.3.0 -pytest-cov>=2.6.1 -tox>=3.7.0 +tox>=3.14.0 diff --git a/requirements-test.txt b/requirements-test.txt new file mode 100644 index 00000000..be0928aa --- /dev/null +++ b/requirements-test.txt @@ -0,0 +1,6 @@ +pybids>=0.9.5 +pytest>=5.3.1 +pytest-black>=0.3.7 +pytest-cov>=2.8.1 +pytest-flake8>=1.0.4 +pytest-pylint>=0.14.1 diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index cfa52258..00000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -future>=0.17.1 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 3c6e79cf..00000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[bdist_wheel] -universal=1 diff --git a/setup.py b/setup.py old mode 100644 new mode 100755 index 2d4c78cd..8f4f3851 --- a/setup.py +++ b/setup.py @@ -1,50 +1,86 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +# type: ignore +"""Setup file for the dcm2bids package""" import glob import os from setuptools import setup -#Get __version__ from dcm2bids.version -exec(open(os.path.join("dcm2bids", "version.py")).read()) +def load_version(): + """Execute dcm2bids.version in a global dictionary""" + global_dict = {} + with open(os.path.join("dcm2bids", "version.py")) as _: + exec(_.read(), global_dict) + return global_dict -description = """Reorganising NIfTI files from dcm2niix into the Brain Imaging Data Structure""" - - -try: - with open('README.md', encoding='utf-8') as f: - long_description = f.read() -except: - #python2 compatibility - from io import open - with open('README.md', encoding='utf-8') as f: - long_description = f.read() +def install_requires(): + """Get list of required modules""" + required = [] + for module, meta in _VERSION["REQUIRED_MODULE_METADATA"]: + required.append(f"{module}>={meta['min_version']}") + return required +_VERSION = load_version() DISTNAME = "dcm2bids" -DESCRIPTION = description -VERSION = __version__ +VERSION = _VERSION["__version__"] AUTHOR = "Christophe Bedetti" AUTHOR_EMAIL = "christophe.bedetti@umontreal.ca" -URL = "https://github.com/cbedetti/Dcm2Bids" -DOWNLOAD_URL = URL + "/archive/" + VERSION + ".tar.gz" +DESCRIPTION = ( + "Reorganising NIfTI files from dcm2niix into the Brain Imaging Data Structure" +) +with open("README.md", encoding="utf-8") as _: + LONG_DESCRIPTION = _.read() +LICENSE = "GPLv3+" +PROJECT_URLS = { + "Documentation": "https://cbedetti.github.io/Dcm2Bids", + "Source Code": "https://github.com/cbedetti/Dcm2Bids", +} +CLASSIFIERS = [ + "Intended Audience :: Healthcare Industry", + "Intended Audience :: Science/Research", + # 'Operating System :: MacOS', + # 'Operating System :: Microsoft :: Windows', + # 'Operating System :: POSIX', + # 'Operating System :: Unix', + "Programming Language :: Python", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Topic :: Scientific/Engineering", + "Topic :: Scientific/Engineering :: Bio-Informatics", + "Topic :: Scientific/Engineering :: Medical Science Apps.", +] if __name__ == "__main__": setup( - name=DISTNAME, - version=VERSION, - description=description, - long_description=long_description, - long_description_content_type='text/markdown', - author=AUTHOR, - author_email=AUTHOR_EMAIL, - url=URL, - download_url=DOWNLOAD_URL, - packages=['dcm2bids'], - scripts=glob.glob('scripts/dcm2bids*'), - install_requires=['future'], - ) + name=DISTNAME, + version=VERSION, + packages=[DISTNAME], + scripts=glob.glob("scripts/dcm2bids*"), + entry_points={ + "console_scripts": [ + "dcm2bids = dcm2bids.dcm2bids:main", + "dcm2bids_helper = dcm2bids.helper:main", + "dcm2bids_scaffold = dcm2bids.scaffold:main", + ], + # "configurations": [], + }, + python_requires=">=3.5", + install_requires=install_requires(), + package_data={"": ["README.md", "LICENSE.txt"]}, + author=AUTHOR, + author_email=AUTHOR_EMAIL, + description=DESCRIPTION, + long_description=LONG_DESCRIPTION, + long_description_content_type="text/markdown", + # keywords="", + license=LICENSE, + project_urls=PROJECT_URLS, + classifiers=CLASSIFIERS, + ) diff --git a/tox.ini b/tox.ini index 77b54e35..a505b368 100644 --- a/tox.ini +++ b/tox.ini @@ -4,13 +4,23 @@ # and then run "tox" from this directory. [tox] -envlist = py27, py35, py36, py37 +envlist = clean, py35, py36, py37, report [testenv] -deps = - pybids - pytest-cov - pytest - backports.tempfile +deps = -rrequirements-test.txt +commands = pytest --cov --cov-append --black --flake8 --pylint +depends = + {py35, py36, py37}: clean + report: py35, py36, py37 + +[testenv:report] +deps = coverage +skip_install = true commands = - pytest --cov=dcm2bids --cov-report html + coverage html + coverage report + +[testenv:clean] +deps = coverage +skip_install = true +commands = coverage erase