Skip to content

Instantly share code, notes, and snippets.

@Ja7ad
Created December 2, 2020 12:38
Show Gist options
  • Save Ja7ad/de893adb1bdfafbb71bf1a6ca1a92c3e to your computer and use it in GitHub Desktop.
Save Ja7ad/de893adb1bdfafbb71bf1a6ca1a92c3e to your computer and use it in GitHub Desktop.
An pyd file installer for installed python3 in windows and linux
import sys, site, shutil, os, platform
pyMajorVersion = sys.version_info.major
pyMinorVersion = sys.version_info.minor
pyVersion = str(pyMajorVersion) + "." + str(pyMinorVersion)
print("This Python version " + pyVersion)
if not os.path.exists(pyVersion):
print("This Python version does not match the downloaded License Module.\n")
exit()
# system can be Linux, Darwin, Windows, SunOS
mySystem = platform.system()
print("This system: " + mySystem)
# machine can be x86_64, i686, i386, AMD64, sun4u, ia64, ppc64, armv6l
# sun4u is a SPARC, ia64 is Itanium, ppc64 is PowerPC
myMachine = platform.machine()
print("This processor: " + myMachine)
# coalesce all ARM architectures into "arm"
if "arm" in myMachine:
myMachine = "arm"
if myMachine == "AMD64":
myMachine = "x86_64"
if myMachine == "i386":
myMachine = "i686"
# If this is a 64-bit Windows machine, skip the architecture check because
# 32-bit Python could be used.
skipArchCheck = False
if (mySystem == "Windows") and (myMachine == "x86_64"):
skipArchCheck = True
if not skipArchCheck:
if not os.path.exists(myMachine):
print("This processor architecture does not match the downloaded License Module.\n")
exit()
# Make sure this Chilkat download is for the correct operating systemif not os.path.exists(mySystem):
print("This operating system does not match the downloaded License Module.\n")
exit()
bGlobalInstall = False
if len(sys.argv) > 1:
opt = sys.argv[1]
if opt == '-g':
bGlobalInstall = True
print("Installing globally...\n")
if bGlobalInstall:
spList = site.getsitepackages()
print(spList)
spDir = spList[0]
if not "site-packages" in spDir:
# prefer the first directory having "site-packages" in the name.
for d in spList:
if "site-packages" in d:
spDir = d
break
else:
spDir = site.getusersitepackages()
print("Installing to site-packages directory: " + spDir)
# if the spDir does not exist, create it.
if not os.path.exists(spDir):
print("creating directory " + spDir)
os.makedirs(spDir)
if mySystem == "Windows":
print("copying FileName.pyd to " + spDir)
shutil.copy("FileName.pyd",spDir)
else:
print("copying FileName.so to " + spDir)
shutil.copy("FileName.so",spDir)
print("The License Module Python module is ready to be used.")
print("Success.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment