Skip to content

Commit 2272023

Browse files
committed
setuptools dependency on Mac OS X
1 parent a0f4b27 commit 2272023

File tree

4 files changed

+28
-12
lines changed

4 files changed

+28
-12
lines changed

src/shorah/amplicon.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838

3939
import logging
4040
import logging.handlers
41-
from pkg_resources import resource_filename
4241

4342
from Bio import SeqIO
4443

@@ -53,10 +52,16 @@
5352
from . import shorah_snv
5453

5554
# Try fetching diri and b2w exe with pkg resources
56-
diri_exe = resource_filename(__name__, 'bin/diri_sampler')
57-
b2w_exe = resource_filename(__name__, 'bin/b2w')
55+
try:
56+
from pkg_resources import resource_filename
57+
except ModuleNotFoundError:
58+
diri_exe = None
59+
b2w_exe = None
60+
else:
61+
diri_exe = resource_filename(__name__, 'bin/diri_sampler')
62+
b2w_exe = resource_filename(__name__, 'bin/b2w')
5863
# Try fetching diri and b2w exe with bash 'which'
59-
if not (os.path.exists(diri_exe) and os.path.exists(b2w_exe)):
64+
if not (diri_exe and b2w_exe) or not (os.path.exists(diri_exe) and os.path.exists(b2w_exe)):
6065
diri_exe = shutil.which('diri_sampler')
6166
b2w_exe = shutil.which('b2w')
6267
if not (diri_exe and b2w_exe):

src/shorah/cli.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import sys
4343

4444

45+
use_pkg_resources = False;
4546
all_dirs = os.path.abspath(__file__).split(os.sep)
4647
base_dir = os.sep.join(all_dirs[:-all_dirs[::-1].index('shorah')])
4748
version_fname = os.path.join(base_dir, '.version')
@@ -57,6 +58,8 @@
5758
except DistributionNotFound:
5859
__version__ = 'unknown'
5960
print("cannot find version", file=sys.stderr)
61+
else:
62+
use_pkg_resources = True;
6063

6164
# manipulate path to import functions
6265
parent_dir = os.path.join(base_dir, 'src')

src/shorah/shorah_snv.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,15 @@
4444

4545
import logging
4646

47-
from pkg_resources import resource_filename
48-
4947
# Try fetching fil exe with pkg resources
50-
fil_exe = resource_filename(__name__, 'bin/fil')
48+
try:
49+
from pkg_resources import resource_filename
50+
except ModuleNotFoundError:
51+
fil_exe = None
52+
else:
53+
fil_exe = resource_filename(__name__, 'bin/fil')
5154
# Try fetching fil exe with bash 'which'
52-
if not os.path.exists(fil_exe):
55+
if not fil_exe or not os.path.exists(fil_exe):
5356
fil_exe = shutil.which('fil')
5457
if not fil_exe:
5558
# Try fetching fil exe based on directory structure

src/shorah/shotgun.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import sys
3636
import shlex
3737
import logging
38-
from pkg_resources import resource_filename
3938
import re
4039
import shutil
4140

@@ -52,10 +51,16 @@
5251
from . import shorah_snv
5352

5453
# Try fetching diri and b2w exe with pkg resources
55-
diri_exe = resource_filename(__name__, 'bin/diri_sampler')
56-
b2w_exe = resource_filename(__name__, 'bin/b2w')
54+
try:
55+
from pkg_resources import resource_filename
56+
except ModuleNotFoundError:
57+
diri_exe = None
58+
b2w_exe = None
59+
else:
60+
diri_exe = resource_filename(__name__, 'bin/diri_sampler')
61+
b2w_exe = resource_filename(__name__, 'bin/b2w')
5762
# Try fetching diri and b2w exe with bash 'which'
58-
if not (os.path.exists(diri_exe) and os.path.exists(b2w_exe)):
63+
if not (diri_exe and b2w_exe) or not (os.path.exists(diri_exe) and os.path.exists(b2w_exe)):
5964
diri_exe = shutil.which('diri_sampler')
6065
b2w_exe = shutil.which('b2w')
6166
if not (diri_exe and b2w_exe):

0 commit comments

Comments
 (0)