Skip to content

Commit

Permalink
setuptools dependency on Mac OS X
Browse files Browse the repository at this point in the history
  • Loading branch information
DrYak committed Jul 27, 2020
1 parent a0f4b27 commit 2272023
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
13 changes: 9 additions & 4 deletions src/shorah/amplicon.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@

import logging
import logging.handlers
from pkg_resources import resource_filename

from Bio import SeqIO

Expand All @@ -53,10 +52,16 @@
from . import shorah_snv

# Try fetching diri and b2w exe with pkg resources
diri_exe = resource_filename(__name__, 'bin/diri_sampler')
b2w_exe = resource_filename(__name__, 'bin/b2w')
try:
from pkg_resources import resource_filename
except ModuleNotFoundError:
diri_exe = None
b2w_exe = None
else:
diri_exe = resource_filename(__name__, 'bin/diri_sampler')
b2w_exe = resource_filename(__name__, 'bin/b2w')
# Try fetching diri and b2w exe with bash 'which'
if not (os.path.exists(diri_exe) and os.path.exists(b2w_exe)):
if not (diri_exe and b2w_exe) or not (os.path.exists(diri_exe) and os.path.exists(b2w_exe)):
diri_exe = shutil.which('diri_sampler')
b2w_exe = shutil.which('b2w')
if not (diri_exe and b2w_exe):
Expand Down
3 changes: 3 additions & 0 deletions src/shorah/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import sys


use_pkg_resources = False;
all_dirs = os.path.abspath(__file__).split(os.sep)
base_dir = os.sep.join(all_dirs[:-all_dirs[::-1].index('shorah')])
version_fname = os.path.join(base_dir, '.version')
Expand All @@ -57,6 +58,8 @@
except DistributionNotFound:
__version__ = 'unknown'
print("cannot find version", file=sys.stderr)
else:
use_pkg_resources = True;

# manipulate path to import functions
parent_dir = os.path.join(base_dir, 'src')
Expand Down
11 changes: 7 additions & 4 deletions src/shorah/shorah_snv.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,15 @@

import logging

from pkg_resources import resource_filename

# Try fetching fil exe with pkg resources
fil_exe = resource_filename(__name__, 'bin/fil')
try:
from pkg_resources import resource_filename
except ModuleNotFoundError:
fil_exe = None
else:
fil_exe = resource_filename(__name__, 'bin/fil')
# Try fetching fil exe with bash 'which'
if not os.path.exists(fil_exe):
if not fil_exe or not os.path.exists(fil_exe):
fil_exe = shutil.which('fil')
if not fil_exe:
# Try fetching fil exe based on directory structure
Expand Down
13 changes: 9 additions & 4 deletions src/shorah/shotgun.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import sys
import shlex
import logging
from pkg_resources import resource_filename
import re
import shutil

Expand All @@ -52,10 +51,16 @@
from . import shorah_snv

# Try fetching diri and b2w exe with pkg resources
diri_exe = resource_filename(__name__, 'bin/diri_sampler')
b2w_exe = resource_filename(__name__, 'bin/b2w')
try:
from pkg_resources import resource_filename
except ModuleNotFoundError:
diri_exe = None
b2w_exe = None
else:
diri_exe = resource_filename(__name__, 'bin/diri_sampler')
b2w_exe = resource_filename(__name__, 'bin/b2w')
# Try fetching diri and b2w exe with bash 'which'
if not (os.path.exists(diri_exe) and os.path.exists(b2w_exe)):
if not (diri_exe and b2w_exe) or not (os.path.exists(diri_exe) and os.path.exists(b2w_exe)):
diri_exe = shutil.which('diri_sampler')
b2w_exe = shutil.which('b2w')
if not (diri_exe and b2w_exe):
Expand Down

0 comments on commit 2272023

Please sign in to comment.