pluginmanager: Support installing plugins that need --process-dependency-links
This might be necessary when plugins depend on (patched) library versions that are not yet released on PyPI
This commit is contained in:
parent
8353c9bdf5
commit
46711ce365
3 changed files with 42 additions and 7 deletions
|
|
@ -59,7 +59,8 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||||
def get_settings_defaults(self):
|
def get_settings_defaults(self):
|
||||||
return dict(
|
return dict(
|
||||||
repository="http://plugins.octoprint.org/plugins.json",
|
repository="http://plugins.octoprint.org/plugins.json",
|
||||||
pip=None
|
pip=None,
|
||||||
|
dependency_links=False
|
||||||
)
|
)
|
||||||
|
|
||||||
##~~ AssetPlugin
|
##~~ AssetPlugin
|
||||||
|
|
@ -143,7 +144,10 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||||
if command == "install":
|
if command == "install":
|
||||||
url = data["url"]
|
url = data["url"]
|
||||||
plugin_name = data["plugin"] if "plugin" in data else None
|
plugin_name = data["plugin"] if "plugin" in data else None
|
||||||
return self.command_install(url=url, force="force" in data and data["force"] in valid_boolean_trues, reinstall=plugin_name)
|
return self.command_install(url=url,
|
||||||
|
force="force" in data and data["force"] in valid_boolean_trues,
|
||||||
|
dependency_links="dependency_links" in data and data["dependency_links"] in valid_boolean_trues,
|
||||||
|
reinstall=plugin_name)
|
||||||
|
|
||||||
elif command == "uninstall":
|
elif command == "uninstall":
|
||||||
plugin_name = data["plugin"]
|
plugin_name = data["plugin"]
|
||||||
|
|
@ -165,7 +169,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||||
self._repository_available = self._refresh_repository()
|
self._repository_available = self._refresh_repository()
|
||||||
return jsonify(repository=dict(available=self._repository_available, plugins=self._repository_plugins))
|
return jsonify(repository=dict(available=self._repository_available, plugins=self._repository_plugins))
|
||||||
|
|
||||||
def command_install(self, url=None, path=None, force=False, reinstall=None):
|
def command_install(self, url=None, path=None, force=False, reinstall=None, dependency_links=False):
|
||||||
if url is not None:
|
if url is not None:
|
||||||
pip_args = ["install", sarge.shell_quote(url)]
|
pip_args = ["install", sarge.shell_quote(url)]
|
||||||
elif path is not None:
|
elif path is not None:
|
||||||
|
|
@ -173,6 +177,9 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||||
else:
|
else:
|
||||||
raise ValueError("Either url or path must be provided")
|
raise ValueError("Either url or path must be provided")
|
||||||
|
|
||||||
|
if dependency_links or self._settings.get_boolean(["dependency_links"]):
|
||||||
|
pip_args.append("--process-dependency-links")
|
||||||
|
|
||||||
all_plugins_before = self._plugin_manager.find_plugins()
|
all_plugins_before = self._plugin_manager.find_plugins()
|
||||||
|
|
||||||
success_string = "Successfully installed"
|
success_string = "Successfully installed"
|
||||||
|
|
@ -489,6 +496,10 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||||
|
|
||||||
def map_repository_entry(entry):
|
def map_repository_entry(entry):
|
||||||
result = dict(entry)
|
result = dict(entry)
|
||||||
|
|
||||||
|
if not "follow_dependency_links" in result:
|
||||||
|
result["follow_dependency_links"] = False
|
||||||
|
|
||||||
result["is_compatible"] = dict(
|
result["is_compatible"] = dict(
|
||||||
octoprint=True,
|
octoprint=True,
|
||||||
os=True
|
os=True
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,8 @@ $(function() {
|
||||||
self.loglines = ko.observableArray([]);
|
self.loglines = ko.observableArray([]);
|
||||||
self.installedPlugins = ko.observableArray([]);
|
self.installedPlugins = ko.observableArray([]);
|
||||||
|
|
||||||
|
self.followDependencyLinks = ko.observable(false);
|
||||||
|
|
||||||
self.working = ko.observable(false);
|
self.working = ko.observable(false);
|
||||||
self.workingTitle = ko.observable();
|
self.workingTitle = ko.observable();
|
||||||
self.workingDialog = undefined;
|
self.workingDialog = undefined;
|
||||||
|
|
@ -108,6 +110,9 @@ $(function() {
|
||||||
self.uploadButton.unbind("click");
|
self.uploadButton.unbind("click");
|
||||||
self.uploadButton.bind("click", function() {
|
self.uploadButton.bind("click", function() {
|
||||||
self._markWorking(gettext("Installing plugin..."), gettext("Installing plugin from uploaded archive..."));
|
self._markWorking(gettext("Installing plugin..."), gettext("Installing plugin from uploaded archive..."));
|
||||||
|
data.formData = {
|
||||||
|
dependency_links: self.followDependencyLinks()
|
||||||
|
};
|
||||||
data.submit();
|
data.submit();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
@ -213,13 +218,13 @@ $(function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.installed(data)) {
|
if (self.installed(data)) {
|
||||||
self.installPlugin(data.archive, data.title, data.id);
|
self.installPlugin(data.archive, data.title, data.id, data.follow_dependency_links || self.followDependencyLinks());
|
||||||
} else {
|
} else {
|
||||||
self.installPlugin(data.archive, data.title);
|
self.installPlugin(data.archive, data.title, undefined, data.follow_dependency_links || self.followDependencyLinks());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
self.installPlugin = function(url, name, reinstall) {
|
self.installPlugin = function(url, name, reinstall, followDependencyLinks) {
|
||||||
if (!self.loginState.isAdmin()) {
|
if (!self.loginState.isAdmin()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -229,6 +234,10 @@ $(function() {
|
||||||
}
|
}
|
||||||
if (!url) return;
|
if (!url) return;
|
||||||
|
|
||||||
|
if (followDependencyLinks === undefined) {
|
||||||
|
followDependencyLinks = self.followDependencyLinks();
|
||||||
|
}
|
||||||
|
|
||||||
var workTitle, workText;
|
var workTitle, workText;
|
||||||
if (!reinstall) {
|
if (!reinstall) {
|
||||||
workTitle = gettext("Installing plugin...");
|
workTitle = gettext("Installing plugin...");
|
||||||
|
|
@ -244,7 +253,7 @@ $(function() {
|
||||||
self._markWorking(workTitle, workText);
|
self._markWorking(workTitle, workText);
|
||||||
|
|
||||||
var command = "install";
|
var command = "install";
|
||||||
var payload = {url: url};
|
var payload = {url: url, dependency_links: followDependencyLinks};
|
||||||
if (reinstall) {
|
if (reinstall) {
|
||||||
payload["plugin"] = reinstall;
|
payload["plugin"] = reinstall;
|
||||||
payload["force"] = true;
|
payload["force"] = true;
|
||||||
|
|
|
||||||
|
|
@ -138,6 +138,21 @@
|
||||||
</div>
|
</div>
|
||||||
<span class="help-block" data-bind="visible: invalidArchive">{{ _('This does not look like a valid plugin archive. Valid plugin archives should be either zip files or tarballs and have the extension ".zip", ".tar.gz", ".tgz" or ".tar"') }}</span>
|
<span class="help-block" data-bind="visible: invalidArchive">{{ _('This does not look like a valid plugin archive. Valid plugin archives should be either zip files or tarballs and have the extension ".zip", ".tar.gz", ".tgz" or ".tar"') }}</span>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<div><small><a href="#" class="muted" onclick="$(this).children().toggleClass('icon-caret-right icon-caret-down').parent().parent().parent().next().slideToggle('fast')"><i class="icon-caret-right"></i> {{ _('Advanced options') }}</a></small></div>
|
||||||
|
<div class="hide">
|
||||||
|
<form class="form-horizontal">
|
||||||
|
<div class="control-group">
|
||||||
|
<div class="controls">
|
||||||
|
<label class="checkbox">
|
||||||
|
<input type="checkbox" data-bind="checked: followDependencyLinks"> {{ _('Use <code>--process-dependency-links</code> with <code>pip install</code>') }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button class="btn" data-dismiss="modal" aria-hidden="true">{{ _('Close') }}</button>
|
<button class="btn" data-dismiss="modal" aria-hidden="true">{{ _('Close') }}</button>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue