mirror of
https://github.com/gsi-upm/senpy
synced 2024-11-22 08:12:27 +00:00
Added option to install dependencies in CLI
This commit is contained in:
parent
0d511ad3c3
commit
07b5dd3823
@ -1,3 +1,5 @@
|
|||||||
from python:{{PYVERSION}}-onbuild
|
from python:{{PYVERSION}}-onbuild
|
||||||
|
|
||||||
|
RUN pip install .
|
||||||
|
|
||||||
ENTRYPOINT ["python", "-m", "senpy", "-f", ".", "--host", "0.0.0.0"]
|
ENTRYPOINT ["python", "-m", "senpy", "-f", ".", "--host", "0.0.0.0"]
|
||||||
|
10
Makefile
10
Makefile
@ -34,9 +34,13 @@ upload-%: test-%
|
|||||||
|
|
||||||
upload: testall $(addprefix upload-,$(PYVERSIONS))
|
upload: testall $(addprefix upload-,$(PYVERSIONS))
|
||||||
docker tag '$(REPO)/$(NAME):$(VERSION)-python$(PYMAIN)' '$(REPO)/$(NAME):$(VERSION)'
|
docker tag '$(REPO)/$(NAME):$(VERSION)-python$(PYMAIN)' '$(REPO)/$(NAME):$(VERSION)'
|
||||||
docker tag '$(REPO)/$(NAME):$(VERSION)-python$(PYVERSIONS)' '$(REPO)/$(NAME)'
|
docker tag '$(REPO)/$(NAME):$(VERSION)-python$(PYMAIN)' '$(REPO)/$(NAME)'
|
||||||
docker push '$(REPO)/$(NAME):$(VERSION)' docker push '$(REPO)/$(NAME)'
|
docker push '$(REPO)/$(NAME):$(VERSION)'
|
||||||
python setup.py sdist upload
|
|
||||||
|
clean:
|
||||||
|
@docker ps -a | awk '/$(REPO)\/$(NAME)/{ split($$2, vers, "-"); if(vers[1] != "${VERSION}"){ print $$1;}}' | xargs docker rm 2>/dev/null|| true
|
||||||
|
@docker images | awk '/$(REPO)\/$(NAME)/{ split($$2, vers, "-"); if(vers[1] != "${VERSION}"){ print $$1":"$$2;}}' | xargs docker rmi 2>/dev/null|| true
|
||||||
|
|
||||||
|
|
||||||
pip_upload:
|
pip_upload:
|
||||||
python setup.py sdist upload ;
|
python setup.py sdist upload ;
|
||||||
|
@ -1 +1 @@
|
|||||||
0.6.0
|
0.6.1
|
||||||
|
@ -65,6 +65,11 @@ def main():
|
|||||||
type=str,
|
type=str,
|
||||||
default='plugins',
|
default='plugins',
|
||||||
help='Where to look for plugins.')
|
help='Where to look for plugins.')
|
||||||
|
parser.add_argument('--only-install',
|
||||||
|
'-i',
|
||||||
|
action='store_true',
|
||||||
|
default=False,
|
||||||
|
help='Do not run a server, only install the dependencies of the plugins.')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
logging.basicConfig()
|
logging.basicConfig()
|
||||||
rl = logging.getLogger()
|
rl = logging.getLogger()
|
||||||
@ -72,6 +77,9 @@ def main():
|
|||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.debug = args.debug
|
app.debug = args.debug
|
||||||
sp = Senpy(app, args.plugins_folder, default_plugins=args.default_plugins)
|
sp = Senpy(app, args.plugins_folder, default_plugins=args.default_plugins)
|
||||||
|
if args.only_install:
|
||||||
|
sp.install_deps()
|
||||||
|
return
|
||||||
sp.activate_all()
|
sp.activate_all()
|
||||||
http_server = WSGIServer((args.host, args.port), app)
|
http_server = WSGIServer((args.host, args.port), app)
|
||||||
try:
|
try:
|
||||||
|
@ -204,6 +204,21 @@ class Senpy(object):
|
|||||||
def validate_info(cls, info):
|
def validate_info(cls, info):
|
||||||
return all(x in info for x in ('name', 'module', 'version'))
|
return all(x in info for x in ('name', 'module', 'version'))
|
||||||
|
|
||||||
|
def install_deps(self):
|
||||||
|
for i in self.plugins.values():
|
||||||
|
self._install_deps(i._info)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _install_deps(cls, info=None):
|
||||||
|
requirements = info.get('requirements', [])
|
||||||
|
if requirements:
|
||||||
|
pip_args = []
|
||||||
|
pip_args.append('install')
|
||||||
|
for req in requirements:
|
||||||
|
pip_args.append( req )
|
||||||
|
logger.info('Installing requirements: ' + str(requirements))
|
||||||
|
pip.main(pip_args)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _load_plugin_from_info(cls, info, root):
|
def _load_plugin_from_info(cls, info, root):
|
||||||
if not cls.validate_info(info):
|
if not cls.validate_info(info):
|
||||||
@ -215,13 +230,7 @@ class Senpy(object):
|
|||||||
sys.path.append(root)
|
sys.path.append(root)
|
||||||
(fp, pathname, desc) = imp.find_module(module, [root, ])
|
(fp, pathname, desc) = imp.find_module(module, [root, ])
|
||||||
try:
|
try:
|
||||||
if requirements:
|
cls._install_deps(info)
|
||||||
pip_args = []
|
|
||||||
pip_args.append('install')
|
|
||||||
for req in requirements:
|
|
||||||
pip_args.append( req )
|
|
||||||
logger.info('Installing requirements: ' + str(requirements))
|
|
||||||
pip.main(pip_args)
|
|
||||||
tmp = imp.load_module(module, fp, pathname, desc)
|
tmp = imp.load_module(module, fp, pathname, desc)
|
||||||
sys.path.remove(root)
|
sys.path.remove(root)
|
||||||
candidate = None
|
candidate = None
|
||||||
|
Loading…
Reference in New Issue
Block a user