equal
deleted
inserted
replaced
953 # the location of data files matching the source code |
953 # the location of data files matching the source code |
954 if mainfrozen() and getattr(sys, 'frozen', None) != 'macosx_app': |
954 if mainfrozen() and getattr(sys, 'frozen', None) != 'macosx_app': |
955 # executable version (py2exe) doesn't support __file__ |
955 # executable version (py2exe) doesn't support __file__ |
956 datapath = os.path.dirname(pycompat.sysexecutable) |
956 datapath = os.path.dirname(pycompat.sysexecutable) |
957 else: |
957 else: |
958 datapath = os.path.dirname(__file__) |
958 datapath = os.path.dirname(pycompat.fsencode(__file__)) |
959 |
|
960 if not isinstance(datapath, bytes): |
|
961 datapath = pycompat.fsencode(datapath) |
|
962 |
959 |
963 i18n.setdatapath(datapath) |
960 i18n.setdatapath(datapath) |
964 |
961 |
965 _hgexecutable = None |
962 _hgexecutable = None |
966 |
963 |
978 if getattr(sys, 'frozen', None) == 'macosx_app': |
975 if getattr(sys, 'frozen', None) == 'macosx_app': |
979 # Env variable set by py2app |
976 # Env variable set by py2app |
980 _sethgexecutable(encoding.environ['EXECUTABLEPATH']) |
977 _sethgexecutable(encoding.environ['EXECUTABLEPATH']) |
981 else: |
978 else: |
982 _sethgexecutable(pycompat.sysexecutable) |
979 _sethgexecutable(pycompat.sysexecutable) |
983 elif os.path.basename(getattr(mainmod, '__file__', '')) == 'hg': |
980 elif (os.path.basename( |
984 _sethgexecutable(mainmod.__file__) |
981 pycompat.fsencode(getattr(mainmod, '__file__', ''))) == 'hg'): |
|
982 _sethgexecutable(pycompat.fsencode(mainmod.__file__)) |
985 else: |
983 else: |
986 exe = findexe('hg') or os.path.basename(sys.argv[0]) |
984 exe = findexe('hg') or os.path.basename(sys.argv[0]) |
987 _sethgexecutable(exe) |
985 _sethgexecutable(exe) |
988 return _hgexecutable |
986 return _hgexecutable |
989 |
987 |