Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/utils/resourceutil.py @ 43713:9fb85668ee15
util: move definition of datapath to resourceutil
Since this means moving the function into a subdirectory, we have to
compensate by adding another layer of os.path.dirname().
Differential Revision: https://phab.mercurial-scm.org/D7434
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 14 Nov 2019 12:33:10 -0800 |
parents | 664e24207728 |
children | 5606e1cb4685 |
comparison
equal
deleted
inserted
replaced
43712:664e24207728 | 43713:9fb85668ee15 |
---|---|
8 # GNU General Public License version 2 or any later version. | 8 # GNU General Public License version 2 or any later version. |
9 | 9 |
10 from __future__ import absolute_import | 10 from __future__ import absolute_import |
11 | 11 |
12 import imp | 12 import imp |
13 import os | |
13 import sys | 14 import sys |
14 | 15 |
15 from .. import pycompat | 16 from .. import pycompat |
16 | 17 |
17 | 18 |
24 return ( | 25 return ( |
25 pycompat.safehasattr(sys, "frozen") | 26 pycompat.safehasattr(sys, "frozen") |
26 or pycompat.safehasattr(sys, "importers") # new py2exe | 27 or pycompat.safehasattr(sys, "importers") # new py2exe |
27 or imp.is_frozen("__main__") # old py2exe | 28 or imp.is_frozen("__main__") # old py2exe |
28 ) # tools/freeze | 29 ) # tools/freeze |
30 | |
31 | |
32 # the location of data files matching the source code | |
33 if mainfrozen() and getattr(sys, 'frozen', None) != 'macosx_app': | |
34 # executable version (py2exe) doesn't support __file__ | |
35 datapath = os.path.dirname(pycompat.sysexecutable) | |
36 else: | |
37 datapath = os.path.dirname(os.path.dirname(pycompat.fsencode(__file__))) |