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