mirror of
https://github.com/eblot/pybootd.git
synced 2024-09-11 22:17:44 +03:00
Fix DistributionNotFound issue
When deploying pybootd using PyInstaller, an exception is raised by pkg_resources preventing the module from being loaded.
This commit is contained in:
parent
a62124c6a9
commit
f5ff5f3825
@ -46,6 +46,7 @@ def pybootd_path(path):
|
||||
elif os.path.exists(path):
|
||||
newpath = path
|
||||
else:
|
||||
from pkg_resources import DistributionNotFound
|
||||
try:
|
||||
from pkg_resources import Requirement, resource_filename
|
||||
newpath = resource_filename(Requirement.parse(PRODUCT_NAME), path)
|
||||
@ -53,6 +54,8 @@ def pybootd_path(path):
|
||||
from pkg_resources import get_distribution
|
||||
localpath = get_distribution(PRODUCT_NAME).location
|
||||
newpath = os.path.join(localpath, path)
|
||||
except DistributionNotFound:
|
||||
newpath = path
|
||||
except KeyError:
|
||||
raise IOError('No such file or directory (resource)')
|
||||
if not os.path.isfile(newpath) and not os.path.isdir(newpath):
|
||||
|
Loading…
Reference in New Issue
Block a user