diff --git a/.pep8speaks.yml b/.pep8speaks.yml index 828d9ad5..54107c45 100644 --- a/.pep8speaks.yml +++ b/.pep8speaks.yml @@ -1,23 +1,40 @@ -# File : .pep8speaks.yml - scanner: diff_only: True # If False, the entire file touched by the Pull Request is scanned for errors. If True, only the diff is scanned. - linter: flake8 # Other option is pycodestyle + linter: pycodestyle # Alternative option - flake8 + +pycodestyle: # Valid if scanner.linter is pycodestyle + max-line-length: 79 + ignore: [] # Errors and warnings to ignore + exclude: [] # File path patterns to exclude + count: False + first: False + show-pep8: False + show-source: False + statistics: False + hang-closing: False + filename: [] + select: [] -flake8: # Same as scanner.linter value. Other option is pycodestyle - max-line-length: 79 # Default is 79 in PEP 8 +flake8: # Valid if scanner.linter is flake8 + max-line-length: 79 + ignore: [] + exclude: [] + count: False + show-source: False + statistics: False + hang-closing: False + filename: [] + select: [] -descending_issues_order: False # If True, PEP 8 issues in message will be displayed in descending order of line numbers in the file. no_blank_comment: False # If True, no comment is made on PR without any errors. -only_mention_files_with_errors: True # If False, a separate status comment for each file is made. +descending_issues_order: False # If True, PEP 8 issues in message will be displayed in descending order of line numbers in the file +only_mention_files_with_errors: True # If False, a separate status section for each file is made in the comment. -message: # Customize the comment made by the bot, +message: # Customize the comment made by the bot opened: # Messages when a new PR is submitted - header: "Hello @{name}! Thanks for opening this PR. " - # The keyword {name} is converted into the author's username + header: "Hello @{name}, Thank you for submitting the Pull Request !" footer: "Do see the [PEP 8 -- Style Guide for Python Code](https://www.python.org/dev/peps/pep-0008/)" - # The messages can be written as they would over GitHub - updated: # Messages when new commits are added to the PR - header: "Hello @{name}! Thanks for updating this PR. " - footer: "" # Why to comment the link to the style guide everytime? :) - no_errors: "There are currently no PEP 8 issues detected in this Pull Request. Cheers! :rocket: " + updated: # Messages when a PR is updated + header: "Hello @{name}, Thank you for updating !" + footer: "" + no_errors: "There are currently no PEP 8 issues detected in this Pull Request. Cheers! :beers: " \ No newline at end of file diff --git a/.python-version b/.python-version new file mode 100644 index 00000000..7c7a975f --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.10 \ No newline at end of file diff --git a/Makefile b/Makefile index b9c655ef..a9814368 100644 --- a/Makefile +++ b/Makefile @@ -1,20 +1,10 @@ -# Minimal makefile for Sphinx documentation -# +flake8: + @if command -v flake8 > /dev/null; then \ + echo "Running flake8"; \ + flake8 flake8 --ignore N802,N806 `find . -name \*.py | grep -v setup.py | grep -v /doc/`; \ + else \ + echo "flake8 not found, please install it!"; \ + exit 1; \ + fi; + @echo "flake8 passed" -# You can set these variables from the command line, and also -# from the environment for the first two. -SPHINXOPTS ?= -SPHINXBUILD ?= sphinx-build -SOURCEDIR = doc -BUILDDIR = build - -# Put it first so that "make" without argument is like "make help". -help: - @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) - -.PHONY: help Makefile - -# Catch-all target: route all unknown targets to Sphinx using the new -# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). -%: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/dwi_ml/info.py b/dwi_ml/info.py deleted file mode 100644 index 5ec0bacc..00000000 --- a/dwi_ml/info.py +++ /dev/null @@ -1,55 +0,0 @@ -"""This file contains defines parameters for DWI_ML that we use to fill -settings in `setup.py`, the DWI_ML top-level docstring, and for building the -docs. -""" - -# DWI_ML version information. An empty _version_extra corresponds to a -# full release. '.dev' as a _version_extra string means this is a development -# version -_version_major = 0 -_version_minor = 1 -_version_micro = 0 -_version_extra = 'dev' -# _version_extra = '' - -# Format expected by setup.py and doc/conf.py: string of form "X.Y.Z" -__version__ = '%s.%s.%s%s' % (_version_major, - _version_minor, - _version_micro, - _version_extra) - -classifiers = ['Development Status :: 3 - Alpha', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python :: 3', - 'Topic :: Scientific/Engineering', - 'Topic :: Scientific/Engineering ::Neuroimaging'] - -description = 'Diffusion Magnetic Resonance Imaging analysis toolkit ' + \ - 'using machine learning and deep learning methods.' - -keywords = 'dwi-ml DWI DL ML neuroimaging tractography' - -# Main setup parameters -NAME = 'dwi_ml' -MAINTAINER = 'scil-vital' -MAINTAINER_EMAIL = '' -DESCRIPTION = description -URL = 'https://github.com/scil-vital/dwi_ml' -DOWNLOAD_URL = '' -BUG_TRACKER = 'https://github.com/scil-vital/dwi_ml/issues', -DOCUMENTATION = 'https://dwi-ml.readthedocs.io/en/latest/', -SOURCE_CODE = 'https://github.com/scil-vital/dwi_ml', -LICENSE = 'MIT license' -CLASSIFIERS = classifiers -KEYWORDS = keywords -AUTHOR = 'scil-vital' -AUTHOR_EMAIL = '' -PLATFORMS = '' -MAJOR = _version_major -MINOR = _version_minor -MICRO = _version_micro -ISRELEASE = _version_extra == '' -VERSION = __version__ -PROVIDES = ['dwi_ml'] -REQUIRES = [] diff --git a/dwi_ml/version.py b/dwi_ml/version.py new file mode 100644 index 00000000..bda89965 --- /dev/null +++ b/dwi_ml/version.py @@ -0,0 +1,87 @@ +# -*- coding: utf-8 -*- + +import glob + +# Format expected by setup.py and doc/source/conf.py: string of form "X.Y.Z" +_version_major = 1 +_version_minor = 0 +_version_micro = 0 +_version_extra = '' + +# Construct full version string from these. +_ver = [_version_major, _version_minor] +if _version_micro: + _ver.append(_version_micro) +if _version_extra: + _ver.append(_version_extra) + +__version__ = '.'.join(map(str, _ver)) + +CLASSIFIERS = ["Development Status :: 3 - Alpha", + "Environment :: Console", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Topic :: Scientific/Engineering", + 'Topic :: Scientific/Engineering ::Neuroimaging'] + +PYTHON_VERSION = "" +with open('.python-version') as f: + py_version = f.readline().strip("\n").split(".") + py_major = py_version[0] + py_minor = py_version[1] + py_micro = "*" + py_extra = None + if len(py_version) > 2: + py_micro = py_version[2] + if len(py_version) > 3: + py_extra = py_version[3] + + PYTHON_VERSION = ".".join([py_major, py_minor, py_micro]) + if py_extra: + PYTHON_VERSION = ".".join([PYTHON_VERSION, py_extra]) + + PYTHON_VERSION = "".join(["==", PYTHON_VERSION]) + +# Description should be a one-liner: +description = 'Diffusion Magnetic Resonance Imaging analysis toolkit ' + \ + 'using machine learning and deep learning methods.' + +# Long description will go up on the pypi page +long_description = """ +DWI_ML +====== + +SCIL and VITAL research labs' code for machine learning in medical data. + +License +======= +``dwi_ml`` is licensed under the terms of the MIT license. See the file +"LICENSE" for information on the history of this software, terms & conditions +for usage, and a DISCLAIMER OF ALL WARRANTIES. + +All trademarks referenced herein are property of their respective holders. + +Copyright (c) 2012--, Sherbrooke Connectivity Imaging Lab [SCIL], +Université de Sherbrooke. +""" + +NAME = "dwi_ml" +MAINTAINER = "Emmanuelle Renauld (@EmmaRenauld)" +MAINTAINER_EMAIL = "" +DESCRIPTION = description +LONG_DESCRIPTION = long_description +URL = "https://github.com/scil-vital/dwi_ml" +DOWNLOAD_URL = "" +LICENSE = "MIT" +AUTHOR = "The SCIL developers" +AUTHOR_EMAIL = "" +PLATFORMS = "OS Independent" +MAJOR = _version_major +MINOR = _version_minor +MICRO = _version_micro +VERSION = __version__ +SCRIPTS = glob.glob("scripts_python/*.py") + +PREVIOUS_MAINTAINERS=[] diff --git a/make.bat b/make.bat deleted file mode 100644 index 93c2ece3..00000000 --- a/make.bat +++ /dev/null @@ -1,35 +0,0 @@ -@ECHO OFF - -pushd %~dp0 - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=sphinx-build -) -set SOURCEDIR=source -set BUILDDIR=build - -if "%1" == "" goto help - -%SPHINXBUILD% >NUL 2>NUL -if errorlevel 9009 ( - echo. - echo.The 'sphinx-build' command was not found. Make sure you have Sphinx - echo.installed, then set the SPHINXBUILD environment variable to point - echo.to the full path of the 'sphinx-build' executable. Alternatively you - echo.may add the Sphinx directory to PATH. - echo. - echo.If you don't have Sphinx installed, grab it from - echo.http://sphinx-doc.org/ - exit /b 1 -) - -%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% -goto end - -:help -%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% - -:end -popd diff --git a/setup.py b/setup.py index de40e5d0..463ad088 100644 --- a/setup.py +++ b/setup.py @@ -1,46 +1,47 @@ -#!/usr/bin/env python -"""Installation script for the DWI_ML package.""" +import os -from setuptools import setup, find_packages -# To use a consistent encoding -from codecs import open -from os import path -from os.path import join as pjoin -import glob +from setuptools import setup, find_packages, Extension +from setuptools.command.build_ext import build_ext -from setup_helpers import read_vars_from +with open('requirements.txt') as f: + required_dependencies = f.read().splitlines() + external_dependencies = [] + for dependency in required_dependencies: + if dependency[0:2] == '-e': + repo_name = dependency.split('=')[-1] + repo_url = dependency[3:] + external_dependencies.append('{} @ {}'.format(repo_name, repo_url)) + else: + external_dependencies.append(dependency) -# Read package information -info = read_vars_from(pjoin('dwi_ml', 'info.py')) -this_directory = path.abspath(path.dirname(__file__)) +# Get version and release info, which is all stored in version.py +ver_file = os.path.join('dwi_ml', 'version.py') +with open(ver_file) as f: + exec(f.read()) +opts = dict(name=NAME, + maintainer=MAINTAINER, + maintainer_email=MAINTAINER_EMAIL, + description=DESCRIPTION, + long_description=LONG_DESCRIPTION, + url=URL, + download_url=DOWNLOAD_URL, + license=LICENSE, + classifiers=CLASSIFIERS, + author=AUTHOR, + author_email=AUTHOR_EMAIL, + platforms=PLATFORMS, + version=VERSION, + packages=find_packages(), + python_requires=PYTHON_VERSION, + setup_requires=['numpy'], + install_requires=external_dependencies, + entry_points={ + 'console_scripts': ["{}=scripts_python.{}:main".format( + os.path.basename(s), + os.path.basename(s).split(".")[0]) for s in SCRIPTS] + }, + data_files=[], + include_package_data=True) -dwi_ml_readme_path = pjoin(this_directory, 'README.rst') -with open(dwi_ml_readme_path, encoding='utf-8') as f: - long_description = f.read() - -setup( - name=info.NAME, - version=info.VERSION, - description=info.DESCRIPTION, - long_description=long_description, - long_description_content_type='text/x-rst', - url=info.URL, - project_urls={'Bug tracker': info.BUG_TRACKER, - 'Documentation': info.DOCUMENTATION, - 'Source code': info.SOURCE_CODE}, - license=info.LICENSE, - author=info.AUTHOR, - author_email=info.AUTHOR_EMAIL, - classifiers=info.CLASSIFIERS, - keywords=info.KEYWORDS, - maintainer=info.MAINTAINER, - provides=info.PROVIDES, - packages=find_packages(exclude=['contrib', 'doc', 'tests']), - install_requires=[], - requires=info.REQUIRES, - package_data={}, - data_files=[], - entry_points={}, - scripts=glob.glob("scripts_python/*.py") + glob.glob("bash_utilities/*.sh") + glob.glob("scripts_python/tests/scripts_on_test_model/*.py") -) +setup(**opts) diff --git a/setup_helpers.py b/setup_helpers.py deleted file mode 100644 index 5cc336ae..00000000 --- a/setup_helpers.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python -"""distutils / setuptools helpers. -""" - - -class Bunch(object): - def __init__(self, vars): - for key, name in vars.items(): - if key.startswith('__'): - continue - self.__dict__[key] = name - - -def read_vars_from(info_file): - """Read variables from Python text file. - - Parameters - ---------- - info_file : str - Filename of file to read. - - Returns - ------- - info_vars : Bunch instance - Bunch object where variables read from `info_file` appear as - attributes. - """ - - # Use exec for compabibility with Python 3 - ns = {} - with open(info_file, 'rt') as fobj: - exec(fobj.read(), ns) - - return Bunch(ns)