Show More
@@ -30,7 +30,7 b' def mainfrozen():' | |||
|
30 | 30 | |
|
31 | 31 | |
|
32 | 32 | # the location of data files matching the source code |
|
33 |
if mainfrozen() and getattr(sys, |
|
|
33 | if mainfrozen() and getattr(sys, "frozen", None) != "macosx_app": | |
|
34 | 34 | # executable version (py2exe) doesn't support __file__ |
|
35 | 35 | datapath = os.path.dirname(pycompat.sysexecutable) |
|
36 | 36 | _rootpath = datapath |
@@ -41,16 +41,18 b" if mainfrozen() and getattr(sys, 'frozen" | |||
|
41 | 41 | # pseudo resources are found in their directory next to the |
|
42 | 42 | # executable. |
|
43 | 43 | def _package_path(package): |
|
44 |
dirs = package.split(b |
|
|
45 |
assert dirs[0] == b |
|
|
44 | dirs = package.split(b".") | |
|
45 | assert dirs[0] == b"mercurial" | |
|
46 | 46 | return os.path.join(_rootpath, *dirs[1:]) |
|
47 | 47 | |
|
48 | ||
|
48 | 49 | else: |
|
49 | 50 | datapath = os.path.dirname(os.path.dirname(pycompat.fsencode(__file__))) |
|
50 | 51 | _rootpath = os.path.dirname(datapath) |
|
51 | 52 | |
|
52 | 53 | def _package_path(package): |
|
53 |
return os.path.join(_rootpath, *package.split(b |
|
|
54 | return os.path.join(_rootpath, *package.split(b".")) | |
|
55 | ||
|
54 | 56 | |
|
55 | 57 | try: |
|
56 | 58 | from importlib import resources |
@@ -79,7 +81,7 b' except (ImportError, AttributeError):' | |||
|
79 | 81 | |
|
80 | 82 | def open_resource(package, name): |
|
81 | 83 | path = os.path.join(_package_path(package), name) |
|
82 |
return open(path, |
|
|
84 | return open(path, "rb") | |
|
83 | 85 | |
|
84 | 86 | def is_resource(package, name): |
|
85 | 87 | path = os.path.join(_package_path(package), name) |
General Comments 0
You need to be logged in to leave comments.
Login now