Skip to content

Commit da6b48d

Browse files
authored
Merge pull request #774 from jmchilton/py3_full
Enable full test suite with Python 3.
2 parents 99d5847 + 75da607 commit da6b48d

17 files changed

Lines changed: 52 additions & 46 deletions

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ install:
2020

2121
matrix:
2222
allow_failures:
23-
- env: TOX_ENV=py34
2423
- env: TOX_ENV=py27-lint-docstrings
2524

2625
script: PLANEMO_ENABLE_POSTGRES_TESTS=1 PLANEMO_SKIP_CWLTOOL_TESTS=1 PLANEMO_TEST_WORKFLOW_RUN_PROFILE=travisworkflowtests tox -e $TOX_ENV

planemo/commands/cmd_project_init.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from planemo import options
99
from planemo.cli import command_function
1010
from planemo.io import (
11-
shell,
1211
untar_to,
1312
warn,
1413
)
@@ -43,11 +42,7 @@ def cli(ctx, path, template=None, **kwds):
4342
untar_args = UNTAR_ARGS % (tempdir)
4443
untar_to(DOWNLOAD_URL, tempdir, untar_args)
4544
template_dir = os.path.join(tempdir, template)
46-
shell("ls '%s'" % (template_dir))
47-
shell("mv '%s'/* '%s'" % (template_dir, path))
48-
dot_files = [os.path.join(template_dir, f) for f in os.listdir(template_dir) if f.startswith(".")]
49-
if len(dot_files) > 0:
50-
dot_files_quoted = "'" + "' '".join(dot_files) + "'"
51-
shell("mv %s '%s'" % (dot_files_quoted, path))
45+
for entry in os.listdir(template_dir):
46+
shutil.move(os.path.join(template_dir, entry), path)
5247
finally:
5348
shutil.rmtree(tempdir)

planemo/commands/cmd_travis_before_install.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,8 @@
88
from planemo.io import shell
99

1010
SETUP_FILE_NAME = "setup_custom_dependencies.bash"
11-
SAMTOOLS_URL = (
12-
"http://archive.ubuntu.com/ubuntu/pool/universe/"
13-
"s/samtools/samtools_0.1.19-1_amd64.deb"
14-
)
15-
16-
FIX_EGGS_DIR = 'mkdir -p "$HOME/.python-eggs"; chmod 700 "$HOME/.python-eggs"'
17-
# samtools essentially required by Galaxy
18-
INSTALL_SAMTOOLS = (
19-
"wget %s; "
20-
"sudo dpkg -i samtools_0.1.19-1_amd64.deb"
21-
) % SAMTOOLS_URL
11+
SAMTOOLS_DEB = 'samtools_0.1.19-1_amd64.deb'
12+
SAMTOOLS_URL = "http://archive.ubuntu.com/ubuntu/pool/universe/s/samtools/%s" % SAMTOOLS_DEB
2213

2314
BUILD_ENVIRONMENT_TEMPLATE = """
2415
export PATH=$PATH:${BUILD_BIN_DIR}
@@ -56,8 +47,14 @@ def cli(ctx):
5647
)
5748
open(build_env_path, "a").write(build_env)
5849

59-
shell(FIX_EGGS_DIR)
60-
shell(INSTALL_SAMTOOLS)
50+
eggs_dir = os.path.join(os.getenv('HOME'), '.python-eggs')
51+
if not os.path.exists(eggs_dir):
52+
os.makedirs(eggs_dir, 0o700)
53+
else:
54+
os.chmod(eggs_dir, 0o700)
55+
# samtools essentially required by Galaxy
56+
shell(['wget', SAMTOOLS_URL])
57+
shell(['sudo', 'dpkg', '-i', SAMTOOLS_DEB])
6158
setup_file = os.path.join(build_travis_dir, SETUP_FILE_NAME)
6259
if os.path.exists(setup_file):
6360
shell(

planemo/commands/cmd_travis_init.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import os
33

44
import click
5-
from galaxy.tools.deps.commands import shell
65

76
from planemo import options
87
from planemo import RAW_CONTENT_URL
@@ -71,15 +70,17 @@ def cli(ctx, path):
7170
# TODO: Option --verbose_travis_yaml to unroll travis_test.sh line by line
7271
# and place all but last in 'install' section and last in 'script'. Would
7372
# require a yaml dependency though.
74-
shell("mkdir -p '%s/.travis'" % path)
73+
dot_travis_dir = os.path.join(path, '.travis')
74+
if not os.path.exists(dot_travis_dir):
75+
os.makedirs(dot_travis_dir)
7576
travis_yml = os.path.join(path, ".travis.yml")
76-
setup_sh = os.path.join(path, ".travis", "setup_custom_dependencies.bash")
77+
setup_sh = os.path.join(dot_travis_dir, "setup_custom_dependencies.bash")
7778
if not os.path.exists(travis_yml):
7879
open(travis_yml, "w").write(TRAVIS_YML)
7980
else:
8081
warn(".travis.yml file already exists, not overwriting.")
8182
if not os.path.exists(setup_sh):
8283
open(setup_sh, "w").write(TRAVIS_SETUP)
8384
else:
84-
warn(".travis/setup_custom_dependencies.bash already exists, not overwriting.")
85+
warn("%s already exists, not overwriting." % setup_sh)
8586
info(PREPARE_MESSAGE)

planemo/cwl/run.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ def run_cwltool(ctx, path, job_path, **kwds):
6161

6262
args.extend([path, job_path])
6363
ctx.vlog("Calling cwltool with arguments %s" % args)
64-
with tempfile.NamedTemporaryFile() as tmp_stdout, \
65-
tempfile.NamedTemporaryFile() as tmp_stderr:
64+
with tempfile.NamedTemporaryFile("w") as tmp_stdout, \
65+
tempfile.NamedTemporaryFile("w") as tmp_stderr:
6666
# cwltool passes sys.stderr to subprocess.Popen - ensure it has
6767
# and actual fileno.
6868
with real_io():

planemo/galaxy/config.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import click
1414
from galaxy.tools.deps import docker_util
1515
from galaxy.tools.deps.commands import argv_to_str
16+
from galaxy.util import unicodify
1617
from six import (
1718
add_metaclass,
1819
iteritems
@@ -571,11 +572,11 @@ def _user_email(kwds):
571572
@contextlib.contextmanager
572573
def _config_directory(ctx, **kwds):
573574
config_directory = kwds.get("config_directory", None)
574-
ctx.vlog("Created directory for Galaxy configuration [%s]" % config_directory)
575575
created_config_directory = False
576576
if not config_directory:
577577
created_config_directory = True
578578
config_directory = os.path.realpath(mkdtemp())
579+
ctx.vlog("Created directory for Galaxy configuration [%s]" % config_directory)
579580
try:
580581
yield config_directory
581582
finally:
@@ -967,7 +968,8 @@ def _download_database_template(
967968
return True
968969

969970
if latest or not galaxy_root:
970-
template_url = DOWNLOADS_URL + urlopen(LATEST_URL).read()
971+
symlink_target = unicodify(urlopen(LATEST_URL).read())
972+
template_url = DOWNLOADS_URL + symlink_target
971973
urlretrieve(template_url, database_location)
972974
return True
973975

planemo/io.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@
2828

2929
def communicate(cmds, **kwds):
3030
if isinstance(cmds, list):
31-
cmds = commands.argv_to_str(cmds)
32-
info(cmds)
31+
cmd_string = commands.argv_to_str(cmds)
32+
else:
33+
cmd_string = cmds
34+
info(cmd_string)
3335
p = commands.shell_process(cmds, **kwds)
3436
if kwds.get("stdout", None) is None and commands.redirecting_io(sys=sys):
3537
output = commands.redirect_aware_commmunicate(p)
@@ -38,13 +40,17 @@ def communicate(cmds, **kwds):
3840

3941
if p.returncode != 0:
4042
template = "Problem executing commands {0} - ({1}, {2})"
41-
msg = template.format(cmds, output[0], output[1])
43+
msg = template.format(cmd_string, output[0], output[1])
4244
raise RuntimeError(msg)
4345
return output
4446

4547

4648
def shell(cmds, **kwds):
47-
info(cmds)
49+
if isinstance(cmds, list):
50+
cmd_string = commands.argv_to_str(cmds)
51+
else:
52+
cmd_string = cmds
53+
info(cmd_string)
4854
return commands.shell(cmds, **kwds)
4955

5056

planemo/linters/biocontainer_registered.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def lint_biocontainer_registered(tool_source, lint_ctx):
2020
lint_ctx.warn(MESSAGE_WARN_NO_REQUIREMENTS)
2121
return
2222

23-
mulled_targets = map(lambda c: build_target(c.package, c.version), conda_targets)
23+
mulled_targets = [build_target(c.package, c.version) for c in conda_targets]
2424
name = mulled_container_name("biocontainers", mulled_targets)
2525
if name:
2626
lint_ctx.info(MESSAGE_INFO_FOUND_BIOCONTAINER % name)

planemo/mulled.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818

1919

2020
def conda_to_mulled_targets(conda_targets):
21-
return map(lambda c: build_target(c.package, c.version), conda_targets)
21+
return list(map(lambda c: build_target(c.package, c.version), conda_targets))
2222

2323

2424
def collect_mulled_target_lists(ctx, paths, recursive=False):
25-
return map(conda_to_mulled_targets, collect_conda_target_lists(ctx, paths, recursive=recursive))
25+
return list(map(conda_to_mulled_targets, collect_conda_target_lists(ctx, paths, recursive=recursive)))
2626

2727

2828
def build_involucro_context(ctx, **kwds):

planemo/runnable.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def for_path(path):
9393

9494
def for_paths(paths):
9595
"""Return a specialized list of Runnable objects for paths."""
96-
return map(for_path, paths)
96+
return list(map(for_path, paths))
9797

9898

9999
def cases(runnable):

0 commit comments

Comments
 (0)