Skip to content

Commit

Permalink
Merge pull request #152 from oesteban/py3/setup.py
Browse files Browse the repository at this point in the history
[FIX] setup.py in python 3
  • Loading branch information
rwblair committed Sep 19, 2016
2 parents 4047f0f + 5893b8f commit 0b303f7
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 79 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ RUN pip install -r requirements.txt

COPY . fmriprep/
RUN cd fmriprep && \
pip install -e .
pip install -e .[all]

WORKDIR /root/
COPY build/files/run_* /usr/bin/
Expand Down
45 changes: 44 additions & 1 deletion fmriprep/info.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
"""
Base module variables
"""
from __future__ import unicode_literals

__version__ = '0.1.1a3'
__author__ = 'The CRN developers'
Expand Down Expand Up @@ -39,3 +39,46 @@
implementation for each state of preprocessing, and will be updated as newer and better neuroimaging software
become available.
"""

DOWNLOAD_URL = ('https://pypi.python.org/packages/source/f/fmriprep/' +
'fmriprep-%s.tar.gz').format('__version__')

REQUIRES = [
'numpy',
'lockfile',
'future',
'scikit-learn',
'matplotlib',
'nilearn',
'sklearn',
'nibabel',
'niworkflows>=0.0.3a3',
'grabbit'
]

LINKS_REQUIRES = [
'git+https://github.com/nipy/nipype.git@master#egg=nipype',
'git+https://github.com/incf/pybids.git@master#egg=pybids'
]

TESTS_REQUIRES = [
"mock",
"codecov"
]

EXTRA_REQUIRES = {
'doc': ['sphinx'],
'tests': TESTS_REQUIRES,
'duecredit': ['duecredit']
}

# Enable a handle to install all extra dependencies at once
EXTRA_REQUIRES['all'] = [val for _, val in list(EXTRA_REQUIRES.items())]
CLASSIFIERS = [
'Development Status :: 3 - Alpha',
'Intended Audience :: MRI processing',
'Topic :: Scientific/Engineering :: Biomedical Imaging',
'License :: OSI Approved :: 3-clause BSD License',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.5'
]
34 changes: 15 additions & 19 deletions fmriprep/run_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,26 @@
# @Author: oesteban
# @Date: 2015-11-19 16:44:27
# @Last Modified by: oesteban
# @Last Modified time: 2016-08-30 16:52:12
# @Last Modified time: 2016-09-13 13:37:43
"""
fMRI preprocessing workflow
=====
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import absolute_import, division, print_function, unicode_literals

import os
import os.path as op
import glob
from argparse import ArgumentParser
from argparse import RawTextHelpFormatter
from multiprocessing import cpu_count
from lockfile import LockFile

import logging
from multiprocessing import cpu_count
import os
import os.path as op
import glob


def main():
"""Entry point"""
from nipype import config as ncfg
from nipype.pipeline import engine as pe
from fmriprep import __version__
from fmriprep.workflows import base as fwb
from fmriprep.workflows.base import base_workflow_enumerator
parser = ArgumentParser(description='fMRI Preprocessing workflow',
formatter_class=RawTextHelpFormatter)

Expand Down Expand Up @@ -74,6 +67,14 @@ def main():
help='use ANTs-based skull-stripping')

opts = parser.parse_args()
create_workflow(opts)


def create_workflow(opts):
import logging
from nipype import config as ncfg
from fmriprep.workflows import base as fwb
from fmriprep.workflows.base import base_workflow_enumerator

settings = {
'bids_root': op.abspath(opts.bids_dir),
Expand Down Expand Up @@ -115,10 +116,6 @@ def main():

logger.addHandler(logging.FileHandler(op.join(log_dir, 'run_workflow')))

# Warn for default work/output directories
if settings['work_dir'] == parser.get_default('work_dir'):
logger.info('Using default working directory (%s)', settings['work_dir'])

# Set nipype config
ncfg.update_config({
'logging': {'log_directory': log_dir, 'log_to_file': True},
Expand Down Expand Up @@ -157,6 +154,5 @@ def main():
if opts.write_graph:
preproc_wf.write_graph()


if __name__ == '__main__':
main()
9 changes: 0 additions & 9 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,2 @@
-e git+https://github.com/nipy/nipype.git@master#egg=nipype
-e git+https://github.com/incf/pybids.git@master#egg=pybids
numpy
lockfile
future
scikit-learn
matplotlib
nilearn
sklearn
nibabel
niworkflows>=0.0.3a3
81 changes: 32 additions & 49 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,70 +2,53 @@
# -*- coding: utf-8 -*-
# @Author: oesteban
# @Date: 2015-11-19 16:44:27
# @Last Modified by: oesteban
# @Last Modified time: 2016-08-29 18:50:54
""" fmriprep setup script """
import os
import sys


def main():
""" Install entry-point """
from io import open
from os import path as op
from glob import glob
from inspect import getfile, currentframe
from setuptools import setup, find_packages

this_path = os.path.dirname(os.path.abspath(getfile(currentframe())))
# Read vars from info file
module_file =os.path.join(this_path, 'fmriprep', 'info.py')
with open(module_file) as fvars:
exec(compile(fvars.read(), module_file, 'exec'))
this_path = op.dirname(op.abspath(getfile(currentframe())))

REQ_LINKS = []
with open('requirements.txt', 'r') as rfile:
REQUIREMENTS = [line.strip() for line in rfile.readlines()]

for i, req in enumerate(REQUIREMENTS):
if req.startswith('-e'):
REQUIREMENTS[i] = req.split('=')[1]
REQ_LINKS.append(req.split()[1])

if REQUIREMENTS is None:
REQUIREMENTS = []
# Python 3: use a locals dictionary
# http://stackoverflow.com/a/1463370/6820620
ldict = locals()
# Get version and release info, which is all stored in fmriprep/info.py
module_file = op.join(this_path, 'fmriprep', 'info.py')
with open(module_file) as infofile:
pythoncode = [line for line in infofile.readlines() if not line.strip().startswith('#')]
exec('\n'.join(pythoncode), globals(), ldict)

setup(
name=__packagename__,
version=__version__,
description=__description__,
long_description=__longdesc__,
author=__author__,
author_email='cmoodie@stanford.edu',
email=__email__,
maintainer=__maintainer__,
maintainer_email=__email__,
url=__url__,
download_url='https://pypi.python.org/packages/source/f/fmriprep/'
'fmriprep-%s.tar.gz' % __version__,
license=__license__,
name=ldict['__packagename__'],
version=ldict['__version__'],
description=ldict['__description__'],
long_description=ldict['__longdesc__'],
author=ldict['__author__'],
author_email=ldict['__email__'],
email=ldict['__email__'],
maintainer=ldict['__maintainer__'],
maintainer_email=ldict['__email__'],
url=ldict['__url__'],
license=ldict['__license__'],
classifiers=ldict['CLASSIFIERS'],
download_url=ldict['DOWNLOAD_URL'],
# Dependencies handling
setup_requires=[],
install_requires=ldict['REQUIRES'],
tests_require=ldict['TESTS_REQUIRES'],
extras_require=ldict['EXTRA_REQUIRES'],
dependency_links=ldict['LINKS_REQUIRES'],
package_data={'fmriprep': ['data/*.json']},
entry_points={'console_scripts': ['fmriprep=fmriprep.run_workflow:main',]},
packages=find_packages(),
package_data={'fmriprep': ['data/*.json']},
install_requires=REQUIREMENTS,
dependency_links=REQ_LINKS,
zip_safe=False,
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: MRI processing',
'Topic :: Scientific/Engineering :: Biomedical Imaging',
'License :: OSI Approved :: 3-clause BSD License',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.5'
],
zip_safe=False
)

if __name__ == '__main__':
LOCAL_PATH = os.path.dirname(os.path.abspath(sys.argv[0]))
os.chdir(LOCAL_PATH)
sys.path.insert(0, LOCAL_PATH)

main()

0 comments on commit 0b303f7

Please sign in to comment.