Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAINT: Switch to a setup.cfg-style of installation #24

Merged
merged 6 commits into from
Jul 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
command: |
pyenv global 3.5.2
virtualenv venv
pytest -vsx /tmp/src/templateflow/templateflow/conf/tests/test_conf.py
pytest /tmp/src/templateflow/templateflow/conf/tests/test_conf.py

- run:
name: Run tests (w/ DataLad)
Expand All @@ -70,7 +70,7 @@ jobs:
unset TEMPLATEFLOW_HOME
pyenv global 3.5.2
virtualenv venv
pytest -vsx --doctest-modules /tmp/src/templateflow/templateflow --ignore=/tmp/src/templateflow/templateflow/conf/test_conf.py
pytest --doctest-modules /tmp/src/templateflow/templateflow --ignore=/tmp/src/templateflow/templateflow/conf/test_conf.py

- run:
name: Update TemplateFlow skeleton
Expand All @@ -95,7 +95,7 @@ jobs:
pyenv global 3.5.2
virtualenv venv
export TEMPLATEFLOW_HOME="/tmp/data/templateflow"
pytest -vsx --doctest-modules /tmp/src/templateflow/templateflow --ignore=/tmp/src/templateflow/templateflow/conf/test_conf.py
pytest --doctest-modules /tmp/src/templateflow/templateflow --ignore=/tmp/src/templateflow/templateflow/conf/test_conf.py

- run:
name: Run tests (pulling from S3)
Expand All @@ -105,7 +105,7 @@ jobs:
command: |
pyenv global 3.5.2
virtualenv venv
pytest -vsx --doctest-modules /tmp/src/templateflow/templateflow --ignore=/tmp/src/templateflow/templateflow/conf/test_conf.py
pytest --doctest-modules /tmp/src/templateflow/templateflow --ignore=/tmp/src/templateflow/templateflow/conf/test_conf.py

- run:
name: Run tests (w/ DataLad, bypassed via S3)
Expand All @@ -119,7 +119,7 @@ jobs:
pip install -e .
python -c "from templateflow import api"
export TEMPLATEFLOW_USE_DATALAD=0
pytest -vsx --doctest-modules /tmp/src/templateflow/templateflow --ignore=/tmp/src/templateflow/templateflow/conf/test_conf.py
pytest --doctest-modules /tmp/src/templateflow/templateflow --ignore=/tmp/src/templateflow/templateflow/conf/test_conf.py

- run:
name: Test packaging
Expand Down
9 changes: 9 additions & 0 deletions long_description.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Group inference and reporting of neuroimaging studies require that individual's
features are spatially aligned into a common frame where their location can be
called standard.
To that end, a multiplicity of brain templates with anatomical annotations
(i.e., atlases) have been published.
However, a centralized resource that allows programmatic access to templates is
lacking.
TemplateFlow is a modular, version-controlled resource that allows researchers
to use templates "off-the-shelf" and share new ones.
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build-system]
requires = ["setuptools >= 30.3.0", "wheel"]
7 changes: 5 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
pybids>=0.9.0,<0.10.0a0
pytest
pybids~=0.9.2
requests
tqdm
pytest
pytest-xdist
pytest-cov==2.5.1
coverage
64 changes: 64 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,67 @@
[metadata]
url = https://github.com/poldracklab/templateflow
author = The CRN developers
author_email = code@oscaresteban.es
maintainer = Oscar Esteban
maintainer_email = code@oscaresteban.es
description = TemplateFlow Python Client - TemplateFlow is the Zone of neuroimaging templates.
long_description = file:long_description.rst
long_description_content_type = text/x-rst; charset=UTF-8
license = Apache-2.0
classifiers =
Development Status :: 3 - Alpha
Intended Audience :: Science/Research
Topic :: Scientific/Engineering :: Image Recognition
License :: OSI Approved :: Apache Software License
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7

[options]
python_requires = >= 3.5
install_requires =
pybids ~= 0.9.2
requests
tqdm
test_requires =
pytest
pytest-xdist
pytest-cov == 2.5.1
coverage
packages = find:
include_package_data = True

[options.package_data]
templateflow =
conf/config.json
conf/templateflow-skel.zip

[options.packages.find]
exclude =
*.tests

[options.extras_require]
datalad =
datalad

doc =
sphinx >= 1.5.3
pydot >= 1.2.3
pydotplus
docs =
%(doc)s
test =
pytest
pytest-xdist
pytest-cov == 2.5.1
coverage
tests =
%(test)s
all =
%(datalad)s
%(doc)s
%(test)s

[versioneer]
VCS = git
style = pep440
Expand Down
61 changes: 13 additions & 48 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" templateflow setup script """
import sys
from setuptools import setup
import versioneer
from setuptools.command.install import install
from setuptools.command.develop import develop

# Give setuptools a hint to complain if it's too old a version
# 30.3.0 allows us to put most metadata in setup.cfg
# Should match pyproject.toml
SETUP_REQUIRES = ['setuptools >= 30.3.0']
# This enables setuptools to install wheel on-the-fly
SETUP_REQUIRES += ['wheel'] if 'bdist_wheel' in sys.argv else []


def make_cmdclass(basecmd):
"""Decorate setuptools commands."""
Expand All @@ -29,55 +38,11 @@ class CheckHomeProdCommand(install):

if __name__ == '__main__':
""" Install entry-point """
from setuptools import setup, find_packages
from versioneer import get_cmdclass, get_version

from templateflow.__about__ import (
__packagename__,
__author__,
__email__,
__maintainer__,
__license__,
__description__,
__longdesc__,
__url__,
DOWNLOAD_URL,
CLASSIFIERS,
REQUIRES,
SETUP_REQUIRES,
LINKS_REQUIRES,
TESTS_REQUIRES,
EXTRA_REQUIRES,
)

setup(
name=__packagename__,
version=get_version(),
description=__description__,
long_description=__longdesc__,
author=__author__,
author_email=__email__,
maintainer=__maintainer__,
maintainer_email=__email__,
license=__license__,
url=__url__,
download_url=DOWNLOAD_URL,
classifiers=CLASSIFIERS,
packages=find_packages(exclude=['*.tests']),
zip_safe=False,
# Dependencies handling
name='templateflow',
version=versioneer.get_version(),
setup_requires=SETUP_REQUIRES,
install_requires=list(set(REQUIRES)),
dependency_links=LINKS_REQUIRES,
tests_require=TESTS_REQUIRES,
extras_require=EXTRA_REQUIRES,
# Data
include_package_data=True,
package_data={__packagename__: [
'conf/config.json',
'conf/templateflow-skel.zip'
]},
cmdclass=get_cmdclass(cmdclass={
cmdclass=versioneer.get_cmdclass(cmdclass={
'develop': CheckHomeDevCommand,
'install': CheckHomeProdCommand,
}),
Expand Down
64 changes: 4 additions & 60 deletions templateflow/__about__.py
Original file line number Diff line number Diff line change
@@ -1,68 +1,12 @@
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
"""\
Group inference and reporting of neuroimaging studies require that individual's \
features are spatially aligned into a common frame where their location can be \
called standard. \
To that end, a multiplicity of brain templates with anatomical annotations \
(i.e., atlases) have been published. \
However, a centralized resource that allows programmatic access to templates is \
lacking. \
TemplateFlow is a modular, version-controlled resource that allows researchers \
to use templates "off-the-shelf" and share new ones. \
"""
Templateflow
"""
from ._version import get_versions
__version__ = get_versions()['version']
del get_versions

__packagename__ = 'templateflow'
__author__ = 'The CRN developers'
__copyright__ = 'Copyright 2019, Center for Reproducible Neuroscience, Stanford University'
__credits__ = ['Oscar Esteban']
__license__ = '3-clause BSD'
__maintainer__ = 'Oscar Esteban'
__email__ = 'code@oscaresteban.es'
__status__ = 'Prototype'

__description__ = """\
TemplateFlow's Python Client - TemplateFlow is the Zone of neuroimaging templates.
"""
__longdesc__ = __doc__
__url__ = 'https://github.com/poldracklab/{}'.format(__packagename__)

DOWNLOAD_URL = (
'https://pypi.python.org/packages/source/{name[0]}/{name}/{name}-{ver}.tar.gz'.format(
name=__packagename__, ver=__version__))
CLASSIFIERS = [
'Development Status :: 3 - Alpha',
'Intended Audience :: Science/Research',
'Topic :: Scientific/Engineering :: Image Recognition',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
]

REQUIRES = [
'pybids>=0.9.0,<0.10.0a0',
'requests',
'tqdm',
]

SETUP_REQUIRES = []
REQUIRES += SETUP_REQUIRES

LINKS_REQUIRES = []
TESTS_REQUIRES = [
'pytest',
'pytest-xdist',
]

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

# Enable a handle to install all extra dependencies at once
EXTRA_REQUIRES['all'] = list(EXTRA_REQUIRES.values())
__credits__ = ['Oscar Esteban', 'Chris Markiewicz', 'Rastko Ciric', 'Yaroslav O. Halchenko',
'Chris Gorgolewski', 'Russell Poldrack']
17 changes: 1 addition & 16 deletions templateflow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,10 @@
The Zone of Templates
=====================
"""
from .__about__ import (
__version__, __packagename__, __author__, __copyright__,
__credits__, __license__, __maintainer__, __email__, __status__,
__description__, __longdesc__)
from .__about__ import __version__, __copyright__, __credits__

__all__ = [
'__version__',
'__packagename__',
'__author__',
'__copyright__',
'__credits__',
'__license__',
'__maintainer__',
'__email__',
'__status__',
'__description__',
'__longdesc__',
]

from ._version import get_versions
__version__ = get_versions()['version']
del get_versions
12 changes: 8 additions & 4 deletions templateflow/conf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from warnings import warn
from pathlib import Path
from pkg_resources import resource_filename
from .bids import Layout

TF_DEFAULT_HOME = Path.home() / '.cache' / 'templateflow'
TF_HOME = Path(getenv('TEMPLATEFLOW_HOME', str(TF_DEFAULT_HOME)))
Expand Down Expand Up @@ -76,6 +75,11 @@ def update_home(force=False):
return False


TF_LAYOUT = Layout(
str(TF_HOME), validate=False, config='templateflow',
ignore=['.git', '.datalad', '.gitannex', '.gitattributes', 'scripts'])
TF_LAYOUT = None
try:
from .bids import Layout
TF_LAYOUT = Layout(
TF_HOME, validate=False, config='templateflow',
ignore=['.git', '.datalad', '.gitannex', '.gitattributes', 'scripts'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These may be automatically ignored these days... I might flag them for review in a future PR, though not worth the trouble for this PR, IMO.

except ImportError:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What condition should this happen under? You've got pybids ~= 0.9.2 in your install_requires.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason pybids is not available when running the update script during install - could dig more into this, but I'm not sure it's worthy.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you could add pybids to setup_requires and pyproject.toml. Very heavy lifts, though...

pass
13 changes: 13 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[flake8]
max-line-length = 99
doctests = False
exclude=*build/

[pytest]
norecursedirs = .git
addopts = -svx
doctest_optionflags = ALLOW_UNICODE NORMALIZE_WHITESPACE
env =
PYTHONHASHSEED=0
filterwarnings =
ignore::DeprecationWarning