fix for creating venvs on windows

This commit is contained in:
Believethehype
2023-12-20 17:51:14 +01:00
parent 3f434b2711
commit 8bbbef4791

View File

@@ -3,6 +3,7 @@ import os
import subprocess import subprocess
from subprocess import run from subprocess import run
import sys import sys
from sys import platform
from threading import Thread from threading import Thread
from venv import create from venv import create
from nostr_sdk import Keys from nostr_sdk import Keys
@@ -59,15 +60,18 @@ class DVMTaskInterface:
def install_dependencies(self, dvm_config): def install_dependencies(self, dvm_config):
if dvm_config.SCRIPT != "": if dvm_config.SCRIPT != "":
if self.dvm_config.USE_OWN_VENV: if self.dvm_config.USE_OWN_VENV:
dir = r'cache/venvs/' + os.path.basename(dvm_config.SCRIPT).split(".py")[0] dir = r'cache/venvs/' + os.path.basename(dvm_config.SCRIPT).split(".py")[0]
pip_location = 'bin/pip'
if platform == "win32":
pip_location = dir + '/Scripts/pip'
if not os.path.isdir(dir): if not os.path.isdir(dir):
print(dir) print("Creating Venv: " + dir)
create(dir, with_pip=True, upgrade_deps=True) create(dir, with_pip=True, upgrade_deps=True)
self.dependencies.append(("nostr-dvm", "nostr-dvm")) self.dependencies.append(("nostr-dvm", "nostr-dvm"))
for (module, package) in self.dependencies: for (module, package) in self.dependencies:
print("Installing Venv Module: " + module) print("Installing Venv Module: " + module)
run(["bin/pip", "install", "--force-reinstall", package], cwd=dir) run([pip_location, "install", "--force-reinstall", package], cwd=dir)
else: else:
for module, package in self.dependencies: for module, package in self.dependencies:
if module != "nostr-dvm": if module != "nostr-dvm":