scripts/install.py

branch
eric7
changeset 9420
92810aebc909
parent 9402
f5d9aa5c62db
child 9425
b1707793e213
equal deleted inserted replaced
9419:175ec2fe27ca 9420:92810aebc909
21 import py_compile 21 import py_compile
22 import re 22 import re
23 import shlex 23 import shlex
24 import shutil 24 import shutil
25 import subprocess # secok 25 import subprocess # secok
26 import sys
27 import sysconfig
26 import time 28 import time
27 import sys
28 29
29 # Define the globals. 30 # Define the globals.
30 progName = None 31 progName = None
31 currDir = os.getcwd() 32 currDir = os.getcwd()
32 modDir = None 33 modDir = None
33 pyModDir = None 34 pyModDir = None
34 platBinDir = None 35 platBinDir = None
35 platBinDirOld = None
36 distDir = None 36 distDir = None
37 apisDir = None 37 apisDir = None
38 installApis = True 38 installApis = True
39 doCleanup = True 39 doCleanup = True
40 doCleanDesktopLinks = False 40 doCleanDesktopLinks = False
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")
489 477
490 def cleanUp(): 478 def cleanUp():
491 """ 479 """
492 Uninstall the old eric files. 480 Uninstall the old eric files.
493 """ 481 """
494 global platBinDir, platBinDirOld 482 global platBinDir
495 483
496 try: 484 try:
497 from eric7config import getConfig 485 from eric7config import getConfig
498 except ImportError: 486 except ImportError:
499 # eric wasn't installed previously 487 # eric wasn't installed previously
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

eric ide

mercurial