From 0fe8fc4a64b8aa10c5ccbf96e4adf0e869f126c1 Mon Sep 17 00:00:00 2001 From: the-cobalt <63935981+the-cobalt@users.noreply.github.com> Date: Mon, 31 Aug 2020 18:52:41 -0500 Subject: [PATCH 1/4] Add pip pmm support (draft) --- .../share/pmm/package_managers/pip | 131 ++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 src/slash-bedrock/share/pmm/package_managers/pip diff --git a/src/slash-bedrock/share/pmm/package_managers/pip b/src/slash-bedrock/share/pmm/package_managers/pip new file mode 100644 index 00000000..472b57ba --- /dev/null +++ b/src/slash-bedrock/share/pmm/package_managers/pip @@ -0,0 +1,131 @@ +#!/bedrock/libexec/busybox awk -f +# +# Package Manager Manager pip support script +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# version 2 as published by the Free Software Foundation. +# +# Copyright (c) 2013-2020 Daniel Thau + +system_package_managers["pip"] +package_manager_canary_executables["pip"] = "pip" + +# +# General, operation independent flags. +# +# Unlike operations, flags should not have implementations[]. +# +user_interfaces["pip", "assume-no"] = "" +user_interfaces["pip", "assume-yes"] = "" +user_interfaces["pip", "confirm"] = "" +user_interfaces["pip", "quiet"] = "-q/--quiet" +user_interfaces["pip", "verbose"] = "-v/--verbose" + +# +# Operations which directly forward the underlying command output. +# +user_interfaces["pip", "install-packages"] = "pmm install " +user_interfaces["pip", "reinstall-packages"] = "" # None that I am aware of +user_interfaces["pip", "remove-packages-limited"] = "pmm uninstall " +user_interfaces["pip", "remove-packages-full"] = "" # No difference between full and limited +user_interfaces["pip", "verify-packages"] = "pmm check " +user_interfaces["pip", "verify-all-packages"] = "pmm check" +user_interfaces["pip", "mark-packages-explicit"] = "" # No way to change +user_interfaces["pip", "mark-packages-implicit"] = "" # explicit and implicit installation +user_interfaces["pip", "show-package-information"] = "pmm show " +user_interfaces["pip", "clear-cache"] = "" +user_interfaces["pip", "remove-orphans"] = "" +user_interfaces["pip", "update-package-database"] = "" +user_interfaces["pip", "update-file-database"] = "" +user_interfaces["pip", "upgrade-packages-limited"] = "" +user_interfaces["pip", "upgrade-packages-full"] = "" + +implementations["pip", "install-packages"] = "strat -r ${stratum} pip ${flags} install ${items}" +implementations["pip", "reinstall-packages"] = "" +implementations["pip", "remove-packages-limited"] = "strat -r ${stratum} pip ${flags} remove ${items}" +implementations["pip", "remove-packages-full"] = "" +implementations["pip", "verify-packages"] = "strat -r ${stratum} pip check ${items}" +implementations["pip", "verify-all-packages"] = "strat -r ${stratum} pip check" +implementations["pip", "mark-packages-explicit"] = "" +implementations["pip", "mark-packages-implicit"] = "" +implementations["pip", "show-package-information"] = "strat -r ${stratum} pip ${flags} show ${items}" +implementations["pip", "clear-cache"] = "" +implementations["pip", "remove-orphans"] = "" +implementations["pip", "update-package-database"] = "" +implementations["pip", "update-file-database"] = "" +implementations["pip", "upgrade-packages-limited"] = "" +implementations["pip", "upgrade-packages-full"] = "" + +# +# Combine operations. +# +user_interfaces["pip", "clear-cache,remove-orphans"] = "" +user_interfaces["pip", "mark-packages-implicit,remove-orphans"] = "" +user_interfaces["pip", "remove-packages-limited,remove-orphans"] = "" +user_interfaces["pip", "remove-packages-full,remove-orphans"] = "" +user_interfaces["pip", "update-package-database,update-file-database"] = "" +user_interfaces["pip", "update-package-database,upgrade-packages-partial"] = "" +user_interfaces["pip", "update-package-database,upgrade-packages-full"] = "" +user_interfaces["pip", "update-package-database,update-file-database,upgrade-packages-partial"] = "" +user_interfaces["pip", "update-package-database,update-file-database,upgrade-packages-full"] = "" +user_interfaces["pip", "update-package-database,install-packages"] = "" +user_interfaces["pip", "update-package-database,update-file-database,install-packages"] = "" +user_interfaces["pip", "upgrade-packages-limited,install-packages"] = "" +user_interfaces["pip", "upgrade-packages-full,install-packages"] = "" +user_interfaces["pip", "update-package-database,upgrade-packages-partial,install-packages"] = "" +user_interfaces["pip", "update-package-database,upgrade-packages-full,install-packages"] = "" +user_interfaces["pip", "update-package-database,update-file-database,upgrade-packages-partial,install-packages"] = "" +user_interfaces["pip", "update-package-database,update-file-database,upgrade-packages-full,install-packages"] = "" + +implementations["pip", "clear-cache,remove-orphans"] = "" +implementations["pip", "mark-packages-implicit,remove-orphans"] = "" +implementations["pip", "remove-packages-limited,remove-orphans"] = "" +implementations["pip", "remove-packages-full,remove-orphans"] = "" +implementations["pip", "update-package-database,update-file-database"] = "" +implementations["pip", "update-package-database,upgrade-packages-partial"] = "" +implementations["pip", "update-package-database,upgrade-packages-full"] = "" +implementations["pip", "update-package-database,update-file-database,upgrade-packages-partial"] = "" +implementations["pip", "update-package-database,update-file-database,upgrade-packages-full"] = "" +implementations["pip", "update-package-database,install-packages"] = "" +implementations["pip", "update-package-database,update-file-database,install-packages"] = "" +implementations["pip", "upgrade-packages-limited,install-packages"] = "" +implementations["pip", "upgrade-packages-full,install-packages"] = "" +implementations["pip", "update-package-database,upgrade-packages-partial,install-packages"] = "" +implementations["pip", "update-package-database,upgrade-packages-full,install-packages"] = "" +implementations["pip", "update-package-database,update-file-database,upgrade-packages-partial,install-packages"] = "" +implementations["pip", "update-package-database,update-file-database,upgrade-packages-full,install-packages"] = "" + +# +# Operations which have a standardized output format. +# +user_interfaces["pip", "list-installed-package-files"] = "" +user_interfaces["pip", "list-installed-explicit"] = "" +user_interfaces["pip", "list-installed-implicit"] = "" +user_interfaces["pip", "list-installed-packages"] = "pmm list" +user_interfaces["pip", "list-available-packages"] = "" +user_interfaces["pip", "search-for-package-by-name"] = "" +user_interfaces["pip", "search-for-package-by-all"] = "" +user_interfaces["pip", "which-package-owns-file"] = "" +user_interfaces["pip", "which-packages-provide-file"] = "" + +implementations["pip", "list-installed-package-files"] = "" +implementations["pip", "list-installed-explicit"] = "" +implementations["pip", "list-installed-implicit"] = "" +implementations["pip", "list-installed-packages"] = "strat -r ${stratum} pip list | awk '{print $1}' | tail -n+3" +implementations["pip", "list-available-packages"] = "" # Not sure how to do this +implementations["pip", "search-for-package-by-name"] = "" # Can't figure out how to +implementations["pip", "search-for-package-by-all"] = "" # differentiate between the two +implementations["pip", "which-package-owns-file"] = "" +implementations["pip", "which-packages-provide-file"] = "" + +# +# Internal pmm operations. +# +implementations["pip", "is-package-installed"] = "strat -r ${stratum} pip show ${items} >/dev/null" +implementations["pip", "is-package-available"] = "" # Obviously required, can't find a clean way to do this right now. (grep " ${items} "?) +implementations["pip", "is-file-db-available"] = "" +implementations["pip", "print-file-db-install-instructions"] = "" +implementations["pip", "print-package-version"] = "strat -r ${stratum} pip show ${items} |\ + awk '$1 == \"Version:\" {sub(/^[0-9]*:/, \"\"); sub(/[~+-].*$/, \"\"); print $2}'" +implementations["pip", "cache-package-db"] = "" From a5d002ebe04101a69d3977efc1176307e6f6386a Mon Sep 17 00:00:00 2001 From: the-cobalt <63935981+the-cobalt@users.noreply.github.com> Date: Wed, 2 Sep 2020 20:09:09 -0500 Subject: [PATCH 2/4] Update with suggestions from paradigm --- src/slash-bedrock/share/pmm/package_managers/pip | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/slash-bedrock/share/pmm/package_managers/pip b/src/slash-bedrock/share/pmm/package_managers/pip index 472b57ba..61d8323c 100644 --- a/src/slash-bedrock/share/pmm/package_managers/pip +++ b/src/slash-bedrock/share/pmm/package_managers/pip @@ -28,7 +28,7 @@ user_interfaces["pip", "verbose"] = "-v/--verbose" user_interfaces["pip", "install-packages"] = "pmm install " user_interfaces["pip", "reinstall-packages"] = "" # None that I am aware of user_interfaces["pip", "remove-packages-limited"] = "pmm uninstall " -user_interfaces["pip", "remove-packages-full"] = "" # No difference between full and limited +user_interfaces["pip", "remove-packages-full"] = "strat -r ${stratum} pip ${flags} remove ${items}" user_interfaces["pip", "verify-packages"] = "pmm check " user_interfaces["pip", "verify-all-packages"] = "pmm check" user_interfaces["pip", "mark-packages-explicit"] = "" # No way to change @@ -44,7 +44,7 @@ user_interfaces["pip", "upgrade-packages-full"] = "" implementations["pip", "install-packages"] = "strat -r ${stratum} pip ${flags} install ${items}" implementations["pip", "reinstall-packages"] = "" implementations["pip", "remove-packages-limited"] = "strat -r ${stratum} pip ${flags} remove ${items}" -implementations["pip", "remove-packages-full"] = "" +implementations["pip", "remove-packages-full"] = "strat -r ${stratum} pip ${flags} remove ${items}" implementations["pip", "verify-packages"] = "strat -r ${stratum} pip check ${items}" implementations["pip", "verify-all-packages"] = "strat -r ${stratum} pip check" implementations["pip", "mark-packages-explicit"] = "" @@ -114,8 +114,8 @@ implementations["pip", "list-installed-explicit"] = "" implementations["pip", "list-installed-implicit"] = "" implementations["pip", "list-installed-packages"] = "strat -r ${stratum} pip list | awk '{print $1}' | tail -n+3" implementations["pip", "list-available-packages"] = "" # Not sure how to do this -implementations["pip", "search-for-package-by-name"] = "" # Can't figure out how to -implementations["pip", "search-for-package-by-all"] = "" # differentiate between the two +implementations["pip", "search-for-package-by-name"] = "strat -r ${stratum} pip search ${items} | awk '{print$1}'" +implementations["pip", "search-for-package-by-all"] = "strat -r ${stratum} pip search ${items} | awk '{print$1}' | grep ${items}" implementations["pip", "which-package-owns-file"] = "" implementations["pip", "which-packages-provide-file"] = "" From 2330ad7e81f771fc27bee36b9bb8f795e5f5d999 Mon Sep 17 00:00:00 2001 From: the-cobalt <63935981+the-cobalt@users.noreply.github.com> Date: Wed, 2 Sep 2020 20:43:38 -0500 Subject: [PATCH 3/4] Update pip --- src/slash-bedrock/share/pmm/package_managers/pip | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/slash-bedrock/share/pmm/package_managers/pip b/src/slash-bedrock/share/pmm/package_managers/pip index 61d8323c..1a725ba6 100644 --- a/src/slash-bedrock/share/pmm/package_managers/pip +++ b/src/slash-bedrock/share/pmm/package_managers/pip @@ -113,7 +113,8 @@ implementations["pip", "list-installed-package-files"] = "" implementations["pip", "list-installed-explicit"] = "" implementations["pip", "list-installed-implicit"] = "" implementations["pip", "list-installed-packages"] = "strat -r ${stratum} pip list | awk '{print $1}' | tail -n+3" -implementations["pip", "list-available-packages"] = "" # Not sure how to do this +implementations["pip", "list-available-packages"] = "curl https://pypi.org/simple/ 2>/dev/null | grep ">." | sed -r 's/\>/\t/g' | awk -F'\t' '{print $4}' | tail -n +2 | cut -c2- | sort | uniq -u +" # ouch, this was the best I could do for now, definitly will improve later. implementations["pip", "search-for-package-by-name"] = "strat -r ${stratum} pip search ${items} | awk '{print$1}'" implementations["pip", "search-for-package-by-all"] = "strat -r ${stratum} pip search ${items} | awk '{print$1}' | grep ${items}" implementations["pip", "which-package-owns-file"] = "" @@ -123,7 +124,7 @@ implementations["pip", "which-packages-provide-file"] = "" # Internal pmm operations. # implementations["pip", "is-package-installed"] = "strat -r ${stratum} pip show ${items} >/dev/null" -implementations["pip", "is-package-available"] = "" # Obviously required, can't find a clean way to do this right now. (grep " ${items} "?) +implementations["pip", "is-package-available"] = "strat -r ${stratum} pip search '${items}' | grep -q '^${items} ('" # Not very clean, but the best way I could find implementations["pip", "is-file-db-available"] = "" implementations["pip", "print-file-db-install-instructions"] = "" implementations["pip", "print-package-version"] = "strat -r ${stratum} pip show ${items} |\ From 9d8666ae8b2c4493bb2f3050d82888666af28d83 Mon Sep 17 00:00:00 2001 From: the-cobalt <63935981+the-cobalt@users.noreply.github.com> Date: Wed, 2 Sep 2020 20:45:41 -0500 Subject: [PATCH 4/4] Add reinstall --- src/slash-bedrock/share/pmm/package_managers/pip | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/slash-bedrock/share/pmm/package_managers/pip b/src/slash-bedrock/share/pmm/package_managers/pip index 1a725ba6..090feae9 100644 --- a/src/slash-bedrock/share/pmm/package_managers/pip +++ b/src/slash-bedrock/share/pmm/package_managers/pip @@ -42,9 +42,9 @@ user_interfaces["pip", "upgrade-packages-limited"] = "" user_interfaces["pip", "upgrade-packages-full"] = "" implementations["pip", "install-packages"] = "strat -r ${stratum} pip ${flags} install ${items}" -implementations["pip", "reinstall-packages"] = "" -implementations["pip", "remove-packages-limited"] = "strat -r ${stratum} pip ${flags} remove ${items}" -implementations["pip", "remove-packages-full"] = "strat -r ${stratum} pip ${flags} remove ${items}" +implementations["pip", "reinstall-packages"] = "strat -r ${stratum} pip ${flags} install ${items} && strat -r ${stratum} pip ${flags} uninstall ${items}" +implementations["pip", "remove-packages-limited"] = "strat -r ${stratum} pip ${flags} uninstall ${items}" +implementations["pip", "remove-packages-full"] = "strat -r ${stratum} pip ${flags} uninstall ${items}" implementations["pip", "verify-packages"] = "strat -r ${stratum} pip check ${items}" implementations["pip", "verify-all-packages"] = "strat -r ${stratum} pip check" implementations["pip", "mark-packages-explicit"] = ""