INNER CODE UNIT · Python

__ValidatePackage

Ershany/Arcane-Engine · Setup/PythonSetup.py:28

	def __ValidatePackage(config, packageName):
		if importlib_util.find_spec(packageName) is None:
			return config.__InstallPackage(packageName)
		return True

	@classmethod
	def __InstallPackage(config, packageName):
		permissionGranted = False
		while not permissionGranted:
			reply = str(input("Would you like to install Python package '{0:s}'? [Y/N]: ".format(packageName))).lower().strip()[:1]
			if reply == 'n':
				return False
			permissionGranted = (reply == 'y')
		
		print(f"Installing {packageName} module..")
		subprocess.check_call(['python', '-m', 'pip', 'install', packageName])
		
		return config.__ValidatePackage(packageName)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…