Commit c5a92c2c authored by Recteur LP's avatar Recteur LP
parent 78393860
......@@ -13,6 +13,7 @@ import tarfile
import requests
import io
import cherrypy
import subprocess
from ._log import log, __version__
from .tools import *
......@@ -103,14 +104,23 @@ class Plugins():
plugin_root_path = os.path.join(self.plugins_path, plugin_name)
plugin_req = os.path.join(plugin_root_path, 'requirements.txt')
plugin_setup = os.path.join(plugin_root_path, 'setup.py')
try:
from pip import main as pipmain
except:
from pip._internal import main as pipmain
if os.path.isfile(plugin_setup):
pipmain(['install', '-e', plugin_root_path])
subprocess.check_call([
sys.executable,
'-m',
'pip',
'install',
'-e',
plugin_root_path
])
elif os.path.isfile(plugin_req):
[pipmain(['install', line.rstrip()]) for line in open(plugin_req)]
[subprocess.check_call([
sys.executable,
'-m',
'pip',
'install',
line.rstrip()
]) for line in open(plugin_req)]
plugin = self.get(plugin_name)
if hasattr(plugin, 'update'):
plugin.update()
......@@ -143,24 +153,30 @@ class Plugins():
try:
Rfile.extractall(self.plugins_path)
os.rename(os.path.join(self.plugins_path, Rfile.getnames()[0]), os.path.join(self.plugins_path, name))
os.rename(
os.path.join(self.plugins_path, Rfile.getnames()[0]),
os.path.join(self.plugins_path, name)
)
plugin_root_path = os.path.join(self.plugins_path, name)
plugin_req = os.path.join(plugin_root_path, 'requirements.txt')
self.add(name)
if os.path.isfile(os.path.join(plugin_root_path, 'setup.py')):
try:
from pip import main as pipmain
except:
from pip._internal import main as pipmain
pipmain(['install', '-e', plugin_root_path])
subprocess.check_call([
sys.executable,
'-m',
'pip',
'install',
'-e',
plugin_root_path
])
elif os.path.isfile(plugin_req):
try:
from pip import main as pipmain
except:
from pip._internal import main as pipmain
packages = [line.rstrip() for line in open(plugin_req)]
packages.insert(0, 'install')
pipmain(packages)
[subprocess.check_call([
sys.executable,
'-m',
'pip',
'install',
line.rstrip()
]) for line in open(plugin_req)]
plugin = self.get(name)
if hasattr(plugin, 'install'):
plugin.install()
......@@ -187,13 +203,13 @@ class Plugins():
def reinstall(self, plugin_name):
plugin_req = os.path.join(self.plugins_path, plugin_name, 'requirements.txt')
if os.path.isfile(plugin_req):
try:
from pip import main as pipmain
except:
from pip._internal import main as pipmain
packages = [line.rstrip() for line in open(plugin_req)]
packages.insert(0, 'install')
pipmain(packages)
[subprocess.check_call([
sys.executable,
'-m',
'pip',
'install',
line.rstrip()
]) for line in open(plugin_req)]
plugin = self.get(plugin_name)
if hasattr(plugin, 'install'):
plugin.install()
......
......@@ -10,4 +10,3 @@ cherrypy
requests
six
redis
pip<18
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment