Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
1108430
CI: Drop Python 2 tests
effigies Jul 25, 2018
4a84a02
RF: Remove builtins
effigies Jul 25, 2018
9e47ec0
RF: Drop one-line __future__ imports
effigies Jul 25, 2018
06ecbe4
RF: Remove two-line __future__ imports
effigies Jul 25, 2018
b90f7d5
MAINT: Update version, supported Python versions
effigies Jul 25, 2018
b5ef915
FIX: Dangling import
effigies Jul 25, 2018
e968b8d
RF: Drop imports in checkspecs
effigies Jul 25, 2018
7a0e638
MAINT: make specs
effigies Jul 25, 2018
fa347ae
CI: Drop 2.7, add 3.7-dev on Travis
effigies Jul 25, 2018
f25cfc0
RF: Purge PY2/PY3 indicators
effigies Jul 25, 2018
323663f
RF: Purge "from io import open"
effigies Jul 25, 2018
e2dc9f8
DOC: Suggest raise from syntax
effigies Jul 25, 2018
9517c5a
TEST: Drop legacy auto tests
effigies Jul 26, 2018
f4f7865
Merge remote-tracking branch 'upstream/master' into dev/2.0
effigies Jul 30, 2018
421600b
Merge remote-tracking branch 'upstream/master' into dev/2.0
effigies Aug 13, 2018
1e5344e
CI: Build Python 3 wheels only
effigies Aug 13, 2018
055a59f
FIX: Run decode on bytes, not tuple
effigies Aug 13, 2018
938cdf4
CI: Do not install future, remove futures check
effigies Aug 13, 2018
f31416a
Merge remote-tracking branch 'upstream/master' into dev/2.0
effigies Aug 30, 2018
e990c69
Merge remote-tracking branch 'upstream/master' into dev/2.0
effigies Sep 24, 2018
2cfcd5a
Merge remote-tracking branch 'upstream/master' into dev/2.0
effigies Oct 11, 2018
dbfaf7e
Merge remote-tracking branch 'upstream/master' into dev/2.0
effigies Nov 14, 2018
9880669
Merge branch 'master' into dev/2.0
effigies Dec 17, 2018
83e4dc9
PY3: Drop future/builtins imports
effigies Dec 17, 2018
e057971
MAINT: Minimum python version > 3.2
effigies Dec 17, 2018
b0d464c
RF: Drop various remaining compatibilities for Python < 3.5
effigies Dec 17, 2018
be2d8c5
RF: Drop to_str, makedirs compatibility functions
effigies Dec 17, 2018
5ab2fa0
FIX: import os - mistakenly dropped
effigies Dec 17, 2018
dc89681
FIX: os.makedirs does not return directory
effigies Dec 17, 2018
80ed64d
Merge pull request #2831 from effigies/dev/2/min_version
effigies Jan 1, 2019
f112c58
Merge remote-tracking branch 'upstream/master' into dev/2.0
effigies Jan 28, 2019
d997694
Merge remote-tracking branch 'upstream/master' into dev/2.0
effigies Feb 25, 2019
375d00f
Merge branch 'master' into dev/2.0
effigies May 9, 2019
08cd3d3
MAINT: Sort dependencies
effigies Aug 21, 2019
f464954
Merge remote-tracking branch 'upstream/master' into dev/2.0
effigies Aug 21, 2019
7baa6d3
PY3: Remove PY2 str hack
effigies Aug 21, 2019
797841b
Merge branch 'master' into dev/2.0
effigies Oct 8, 2019
72ac8a5
MNT: Missed Py2 cleanups
effigies Oct 8, 2019
7b9c639
MNT: Drop Py2 compatibility for tools/
effigies Oct 8, 2019
497b44d
STY: Black files pre-merge
effigies Nov 12, 2019
49cc0a7
Merge remote-tracking branch 'upstream/master' into dev/2.0
effigies Nov 12, 2019
39fbd54
FIX: Missed merge issue
effigies Nov 12, 2019
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
RF: Drop various remaining compatibilities for Python < 3.5
  • Loading branch information
effigies committed Dec 17, 2018
commit b0d464c7c7ba7bd557fb8f7daa059f462eccab63
4 changes: 0 additions & 4 deletions nipype/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
settings in setup.py, the nipy top-level docstring, and for building the
docs. In setup.py in particular, we exec this file, so it cannot import nipy
"""
import sys

# nipype version information. An empty version_extra corresponds to a
# full release. '.dev' as a version_extra string means this is a development
Expand Down Expand Up @@ -152,9 +151,6 @@ def get_nipype_gitversion():
'futures; python_version == "2.7"',
]

if sys.version_info <= (3, 4):
REQUIRES.append('configparser')

TESTS_REQUIRES = ['pytest-cov', 'codecov', 'pytest-env', 'coverage<5']

EXTRA_REQUIRES = {
Expand Down
8 changes: 0 additions & 8 deletions nipype/interfaces/tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
import copy
import simplejson
import glob
import shutil
import os.path as op
import sys
from subprocess import Popen
import hashlib
from collections import namedtuple
Expand Down Expand Up @@ -577,8 +575,6 @@ def test_jsonsink(tmpdir, inputs_attributes):
# There are three reasons these tests will be skipped:
@pytest.mark.skipif(not have_pybids,
reason="Pybids is not installed")
@pytest.mark.skipif(sys.version_info < (3, 0),
reason="Pybids no longer supports Python 2")
@pytest.mark.skipif(not dist_is_editable('pybids'),
reason="Pybids is not installed in editable mode")
def test_bids_grabber(tmpdir):
Expand All @@ -594,8 +590,6 @@ def test_bids_grabber(tmpdir):

@pytest.mark.skipif(not have_pybids,
reason="Pybids is not installed")
@pytest.mark.skipif(sys.version_info < (3, 0),
reason="Pybids no longer supports Python 2")
@pytest.mark.skipif(not dist_is_editable('pybids'),
reason="Pybids is not installed in editable mode")
def test_bids_fields(tmpdir):
Expand All @@ -610,8 +604,6 @@ def test_bids_fields(tmpdir):

@pytest.mark.skipif(not have_pybids,
reason="Pybids is not installed")
@pytest.mark.skipif(sys.version_info < (3, 0),
reason="Pybids no longer supports Python 2")
@pytest.mark.skipif(not dist_is_editable('pybids'),
reason="Pybids is not installed in editable mode")
def test_bids_infields_outfields(tmpdir):
Expand Down
7 changes: 0 additions & 7 deletions nipype/pipeline/engine/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"""Tests for the engine utils module
"""
import os
import sys
from copy import deepcopy
import pytest

Expand Down Expand Up @@ -159,8 +158,6 @@ def dummy_func(value):
return value + 1


@pytest.mark.skipif(
sys.version_info < (3, 0), reason="the famous segfault #1788")
def test_mapnode_crash(tmpdir):
"""Test mapnode crash when stop_on_first_crash is True"""
cwd = os.getcwd()
Expand All @@ -180,8 +177,6 @@ def test_mapnode_crash(tmpdir):
os.chdir(cwd)


@pytest.mark.skipif(
sys.version_info < (3, 0), reason="the famous segfault #1788")
def test_mapnode_crash2(tmpdir):
"""Test mapnode crash when stop_on_first_crash is False"""
cwd = os.getcwd()
Expand All @@ -200,8 +195,6 @@ def test_mapnode_crash2(tmpdir):
os.chdir(cwd)


@pytest.mark.skipif(
sys.version_info < (3, 0), reason="the famous segfault #1788")
def test_mapnode_crash3(tmpdir):
"""Test mapnode crash when mapnode is embedded in a workflow"""
tmpdir.chdir()
Expand Down
3 changes: 1 addition & 2 deletions nipype/pipeline/plugins/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ def create_pyscript(node, updatehash=False, store_exception=True):
batchdir = '%s'
from nipype.utils.filemanip import loadpkl, savepkl
try:
if not sys.version_info < (2, 7):
from collections import OrderedDict
from collections import OrderedDict
config_dict=%s
config.update_config(config_dict)
## Only configure matplotlib if it was successfully imported,
Expand Down
19 changes: 1 addition & 18 deletions nipype/sphinxext/plot_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,23 +144,6 @@ def format_template(template, **kw):



def _mkdirp(folder):
"""
Equivalent to bash's mkdir -p
"""
if sys.version_info > (3, 4, 1):
os.makedirs(folder, exist_ok=True)
return folder

try:
os.makedirs(folder)
except OSError as exc:
if exc.errno != EEXIST or not os.path.isdir(folder):
raise

return folder


def wf_directive(name, arguments, options, content, lineno, content_offset,
block_text, state, state_machine):
if len(missing_imports) == 0:
Expand Down Expand Up @@ -737,7 +720,7 @@ def run(arguments, content, options, state_machine, state, lineno):
state_machine.insert_input(total_lines, source=source_file_name)

# copy image files to builder's output directory, if necessary
_mkdirp(dest_dir)
os.makedirs(dest_dir, exist_ok=True)
for code_piece, images in results:
for img in images:
for fn in img.filenames():
Expand Down
76 changes: 4 additions & 72 deletions nipype/utils/filemanip.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,56 +91,7 @@ def to_str(value):
Manipulates ordered dicts before they are hashed (Py2/3 compat.)

"""
if sys.version_info[0] > 2:
retval = str(value)
else:
retval = to_str_py27(value)
return retval


def to_str_py27(value):
"""
Encode dictionary for python 2
"""

if isinstance(value, dict):
entry = '{}: {}'.format
retval = '{'
for key, val in list(value.items()):
if len(retval) > 1:
retval += ', '
kenc = repr(key)
if kenc.startswith(("u'", 'u"')):
kenc = kenc[1:]
venc = to_str_py27(val)
if venc.startswith(("u'", 'u"')):
venc = venc[1:]
retval += entry(kenc, venc)
retval += '}'
return retval

istuple = isinstance(value, tuple)
if isinstance(value, (tuple, list)):
retval = '(' if istuple else '['
nels = len(value)
for i, v in enumerate(value):
venc = to_str_py27(v)
if venc.startswith(("u'", 'u"')):
venc = venc[1:]
retval += venc

if i < nels - 1:
retval += ', '

if istuple and nels == 1:
retval += ','
retval += ')' if istuple else ']'
return retval

retval = repr(value).decode()
if retval.startswith(("u'", 'u"')):
retval = retval[1:]
return retval
return str(value)


def fname_presuffix(fname, prefix='', suffix='', newpath=None, use_ext=True):
Expand Down Expand Up @@ -593,8 +544,6 @@ def save_json(filename, data):

"""
mode = 'w'
if sys.version_info[0] < 3:
mode = 'wb'
with open(filename, mode) as fp:
json.dump(data, fp, sort_keys=True, indent=4)

Expand Down Expand Up @@ -841,27 +790,10 @@ def which(cmd, env=None, pathext=None):
if env and 'PATH' in env:
path = env.get("PATH")

if sys.version_info >= (3, 3):
for ext in pathext:
filename = shutil.which(cmd + ext, path=path)
if filename:
return filename
return None

def isexec(path):
return os.path.isfile(path) and os.access(path, os.X_OK)

for ext in pathext:
extcmd = cmd + ext
fpath, fname = os.path.split(extcmd)
if fpath:
if isexec(extcmd):
return extcmd
else:
for directory in path.split(os.pathsep):
filename = op.join(directory, extcmd)
if isexec(filename):
return filename
filename = shutil.which(cmd + ext, path=path)
if filename:
return filename
return None


Expand Down
6 changes: 2 additions & 4 deletions nipype/utils/tests/test_functions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
import sys
import pytest
from nipype.utils.functions import (getsource, create_function_from_source)

Expand Down Expand Up @@ -27,7 +26,7 @@ def test_func_to_str_err():

def _print_statement():
try:
exec('print ""')
exec('print("")')
return True
except SyntaxError:
return False
Expand All @@ -41,7 +40,6 @@ def is_string():
assert is_string() == wrapped_func()


@pytest.mark.skipif(sys.version_info[0] > 2, reason="breaks python 3")
def test_func_print_py2():
def test_func_print():
wrapped_func = create_function_from_source(getsource(_print_statement))
assert wrapped_func()