192 def initGlobals(): |
192 def initGlobals(): |
193 """ |
193 """ |
194 Module function to set the values of globals that need more than a |
194 Module function to set the values of globals that need more than a |
195 simple assignment. |
195 simple assignment. |
196 """ |
196 """ |
197 global platBinDir, modDir, pyModDir, apisDir, platBinDirOld |
197 global platBinDir, modDir, pyModDir, apisDir |
198 |
|
199 import sysconfig |
|
200 |
198 |
201 if sys.platform.startswith(("win", "cygwin")): |
199 if sys.platform.startswith(("win", "cygwin")): |
202 platBinDir = sys.exec_prefix |
200 platBinDir = sysconfig.get_path("scripts") |
203 if platBinDir.endswith("\\"): |
|
204 platBinDir = platBinDir[:-1] |
|
205 platBinDirOld = platBinDir |
|
206 platBinDir = os.path.join(platBinDir, "Scripts") |
|
207 if not os.path.exists(platBinDir): |
|
208 platBinDir = platBinDirOld |
|
209 else: |
201 else: |
210 pyBinDir = os.path.normpath(os.path.dirname(sys.executable)) |
202 # install the eric scripts along the python executable |
211 if os.access(pyBinDir, os.W_OK): |
203 platBinDir = sysconfig.get_path("scripts") |
212 # install the eric scripts along the python executable |
204 if not os.access(platBinDir, os.W_OK): |
213 platBinDir = pyBinDir |
|
214 else: |
|
215 # install them in the user's bin directory |
205 # install them in the user's bin directory |
216 platBinDir = os.path.expanduser("~/bin") |
206 platBinDir = os.path.expanduser("~/bin") |
217 if platBinDir != "/usr/local/bin" and os.access("/usr/local/bin", os.W_OK): |
|
218 platBinDirOld = "/usr/local/bin" |
|
219 |
207 |
220 modDir = sysconfig.get_path("platlib") |
208 modDir = sysconfig.get_path("platlib") |
221 pyModDir = modDir |
209 pyModDir = modDir |
222 |
210 |
223 pyqtDataDir = os.path.join(modDir, "PyQt6") |
211 pyqtDataDir = os.path.join(modDir, "PyQt6") |
541 "eric7", |
529 "eric7", |
542 ] |
530 ] |
543 |
531 |
544 try: |
532 try: |
545 dirs = [platBinDir, getConfig("bindir")] |
533 dirs = [platBinDir, getConfig("bindir")] |
546 if platBinDirOld: |
|
547 dirs.append(platBinDirOld) |
|
548 for rem_wname in rem_wnames: |
534 for rem_wname in rem_wnames: |
549 for d in dirs: |
535 for d in dirs: |
550 for rwname in wrapperNames(d, rem_wname): |
536 for rwname in wrapperNames(d, rem_wname): |
551 if os.path.exists(rwname): |
537 if os.path.exists(rwname): |
552 os.remove(rwname) |
538 os.remove(rwname) |
1937 return |
1923 return |
1938 |
1924 |
1939 with contextlib.suppress(OSError): |
1925 with contextlib.suppress(OSError): |
1940 os.rename(fileName, fileName + ".orig") |
1926 os.rename(fileName, fileName + ".orig") |
1941 localHg = ( |
1927 localHg = ( |
1942 os.path.join(sys.exec_prefix, "Scripts", "hg.exe") |
1928 os.path.join(sysconfig.get_path("scripts"), "hg.exe") |
1943 if sys.platform.startswith(("win", "cygwin")) |
1929 if sys.platform.startswith(("win", "cygwin")) |
1944 else os.path.join(sys.exec_prefix, "bin", "hg") |
1930 else os.path.join(sysconfig.get_path("scripts"), "hg") |
1945 ) |
1931 ) |
1946 for hg in (localHg, "hg"): |
1932 for hg in (localHg, "hg"): |
1947 with contextlib.suppress(OSError, subprocess.CalledProcessError): |
1933 with contextlib.suppress(OSError, subprocess.CalledProcessError): |
1948 hgOut = subprocess.run( # secok |
1934 hgOut = subprocess.run( # secok |
1949 [hg, "identify", "-i"], check=True, capture_output=True, text=True |
1935 [hg, "identify", "-i"], check=True, capture_output=True, text=True |