File tree Expand file tree Collapse file tree 4 files changed +28
-12
lines changed
Expand file tree Collapse file tree 4 files changed +28
-12
lines changed Original file line number Diff line number Diff line change 3838
3939import logging
4040import logging .handlers
41- from pkg_resources import resource_filename
4241
4342from Bio import SeqIO
4443
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 ):
Original file line number Diff line number Diff line change 4242import sys
4343
4444
45+ use_pkg_resources = False ;
4546all_dirs = os .path .abspath (__file__ ).split (os .sep )
4647base_dir = os .sep .join (all_dirs [:- all_dirs [::- 1 ].index ('shorah' )])
4748version_fname = os .path .join (base_dir , '.version' )
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
6265parent_dir = os .path .join (base_dir , 'src' )
Original file line number Diff line number Diff line change 4444
4545import 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
Original file line number Diff line number Diff line change 3535import sys
3636import shlex
3737import logging
38- from pkg_resources import resource_filename
3938import re
4039import shutil
4140
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 ):
You can’t perform that action at this time.
0 commit comments