Skip to content

Commit

Permalink
Merge pull request #121 from epruesse/development
Browse files Browse the repository at this point in the history
Fix Python 3.8 compatability
  • Loading branch information
epruesse authored Aug 17, 2020
2 parents af0e68f + dd31741 commit 6e82744
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
15 changes: 8 additions & 7 deletions src/ymp/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@

from ruamel.yaml import YAML

try:
import snakemake.conda as snakemake_conda
except ModuleNotFoundError:
import snakemake.deployment.conda as snakemake_conda
import snakemake.deployment.conda as snakemake_conda

from snakemake.rules import Rule

Expand Down Expand Up @@ -340,11 +337,15 @@ def run(self, command):
Returns exit code of command run.
"""
command = " ".join(command)
command = snakemake_conda.Conda().shellcmd(self.path, command)
cfg = ymp.get_config()
command = "source activate {}; {}".format(self.path, " ".join(command))
log.debug("Running: %s", command)
return subprocess.run(command,
shell=True, executable=cfg.shell).returncode
return subprocess.run(
command,
shell=True,
executable=cfg.shell
).returncode

def export(self, stream, typ='yml'):
"""Freeze environment"""
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions src/ymp/stage/expander.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def get_value(self, key, args, kwargs):
def get_value_(self, key, args, kwargs):
stage = Stage.active
if "(" in key:
args = list(args)
if key[-1] != ")":
raise YmpRuleError(
stage,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def test_env_run(invoker, demo_dir, mock_conda, mock_downloader, capfd):
res = invoker.call("env", "run", "bbmap", "true")
assert res.exit_code == 0
cap = capfd.readouterr()
assert "Not a conda environment" in cap.err
assert "bin/activate: No such file " in cap.err


@pytest.mark.parametrize(
Expand Down

0 comments on commit 6e82744

Please sign in to comment.