2021-01-19 13:56:00 +00:00
|
|
|
import sys
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
|
2022-04-14 02:10:25 +00:00
|
|
|
class Install:
|
2021-01-19 13:56:00 +00:00
|
|
|
@staticmethod
|
|
|
|
def is_venv():
|
2022-03-23 02:50:12 +00:00
|
|
|
return hasattr(sys, "real_prefix") or (
|
|
|
|
hasattr(sys, "base_prefix") and sys.base_prefix != sys.prefix
|
|
|
|
)
|
2021-01-19 13:56:00 +00:00
|
|
|
|
|
|
|
def do_install(self):
|
|
|
|
|
|
|
|
# are we in a venv?
|
|
|
|
if not self.is_venv():
|
|
|
|
print("Crafty Requires a venv to install")
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
# do our pip install
|
2022-03-23 02:50:12 +00:00
|
|
|
subprocess.check_call(
|
|
|
|
[sys.executable, "-m", "pip", "install", "-r", "requirements.txt"]
|
|
|
|
)
|
2021-01-19 13:56:00 +00:00
|
|
|
print("Crafty has installed it's dependencies, please restart Crafty")
|
|
|
|
sys.exit(0)
|
|
|
|
|
2022-03-23 02:50:12 +00:00
|
|
|
|
2022-04-14 02:10:25 +00:00
|
|
|
installer = Install()
|