[edk2-devel] [edk2-staging/EdkRepo] [PATCH] EdkRepo: Support uninstalling packages with '_' in their name.

Nate DeSimone posted 1 patch 4 years, 4 months ago
Failed in applying to current master (apply log)
edkrepo_installer/linux-scripts/install.py | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
[edk2-devel] [edk2-staging/EdkRepo] [PATCH] EdkRepo: Support uninstalling packages with '_' in their name.
Posted by Nate DeSimone 4 years, 4 months ago
pip does not support '_' in package names and converts them to
'-' after installing the wheel. In order to uninstall affected
packages the '_' needs to be converted to a '-' when calculating
the package name.

Cc: Ashley DeSimone <ashley.e.desimone@intel.com>
Cc: Puja Pandya <puja.pandya@intel.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Signed-off-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
---
 edkrepo_installer/linux-scripts/install.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/edkrepo_installer/linux-scripts/install.py b/edkrepo_installer/linux-scripts/install.py
index a05ce6a..66421ba 100755
--- a/edkrepo_installer/linux-scripts/install.py
+++ b/edkrepo_installer/linux-scripts/install.py
@@ -93,8 +93,9 @@ def get_required_wheels():
             continue
         installed_modules[name] = version
     for name in ret_val:
-        if name in installed_modules:
-            version = installed_modules[name]
+        #pip doesn't understand the difference between '_' and '-'
+        if name.replace('_','-') in installed_modules:
+            version = installed_modules[name.replace('_','-')]
             if _check_version(version, ret_val[name]['version']) >= 0 and not ret_val[name]['uninstall']:
                 ret_val[name]['install'] = False
             else:
@@ -294,9 +295,8 @@ def do_install():
             log.info('- Missing wheel file directory')
             return 1
         for whl_name in wheels_to_install:
-            whl = wheels_to_install[whl_name]['wheel']
-            install_whl = wheels_to_install[whl_name]['install']
             uninstall_whl = wheels_to_install[whl_name]['uninstall']
+            whl_name = whl_name.replace('_','-')  #pip doesn't understand the difference between '_' and '-'
             if uninstall_whl:
                 try:
                     res = default_run(['python3', '-m', 'pip', 'uninstall', '--yes', whl_name])
@@ -304,6 +304,9 @@ def do_install():
                     log.info('- Failed to uninstall {}'.format(whl_name))
                     return 1
                 log.info('+ Uninstalled {}'.format(whl_name))
+        for whl_name in wheels_to_install:
+            whl = wheels_to_install[whl_name]['wheel']
+            install_whl = wheels_to_install[whl_name]['install']
             if install_whl:
                 install_cmd = ['python3', '-m', 'pip', 'install']
                 if args.local:
--
2.20.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#52080): https://edk2.groups.io/g/devel/message/52080
Mute This Topic: https://groups.io/mt/67968737/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [edk2-staging/EdkRepo] [PATCH] EdkRepo: Support uninstalling packages with '_' in their name.
Posted by Desimone, Ashley E 4 years, 4 months ago
Reviewed-by: Ashley DeSimone <ashley.e.desimone@intel.com>

-----Original Message-----
From: Desimone, Nathaniel L 
Sent: Tuesday, December 10, 2019 1:56 AM
To: devel@edk2.groups.io
Cc: Desimone, Ashley E <ashley.e.desimone@intel.com>; Pandya, Puja <puja.pandya@intel.com>; Bret Barkelew <Bret.Barkelew@microsoft.com>
Subject: [edk2-staging/EdkRepo] [PATCH] EdkRepo: Support uninstalling packages with '_' in their name.

pip does not support '_' in package names and converts them to '-' after installing the wheel. In order to uninstall affected packages the '_' needs to be converted to a '-' when calculating the package name.

Cc: Ashley DeSimone <ashley.e.desimone@intel.com>
Cc: Puja Pandya <puja.pandya@intel.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Signed-off-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
---
 edkrepo_installer/linux-scripts/install.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/edkrepo_installer/linux-scripts/install.py b/edkrepo_installer/linux-scripts/install.py
index a05ce6a..66421ba 100755
--- a/edkrepo_installer/linux-scripts/install.py
+++ b/edkrepo_installer/linux-scripts/install.py
@@ -93,8 +93,9 @@ def get_required_wheels():
             continue
         installed_modules[name] = version
     for name in ret_val:
-        if name in installed_modules:
-            version = installed_modules[name]
+        #pip doesn't understand the difference between '_' and '-'
+        if name.replace('_','-') in installed_modules:
+            version = installed_modules[name.replace('_','-')]
             if _check_version(version, ret_val[name]['version']) >= 0 and not ret_val[name]['uninstall']:
                 ret_val[name]['install'] = False
             else:
@@ -294,9 +295,8 @@ def do_install():
             log.info('- Missing wheel file directory')
             return 1
         for whl_name in wheels_to_install:
-            whl = wheels_to_install[whl_name]['wheel']
-            install_whl = wheels_to_install[whl_name]['install']
             uninstall_whl = wheels_to_install[whl_name]['uninstall']
+            whl_name = whl_name.replace('_','-')  #pip doesn't understand the difference between '_' and '-'
             if uninstall_whl:
                 try:
                     res = default_run(['python3', '-m', 'pip', 'uninstall', '--yes', whl_name]) @@ -304,6 +304,9 @@ def do_install():
                     log.info('- Failed to uninstall {}'.format(whl_name))
                     return 1
                 log.info('+ Uninstalled {}'.format(whl_name))
+        for whl_name in wheels_to_install:
+            whl = wheels_to_install[whl_name]['wheel']
+            install_whl = wheels_to_install[whl_name]['install']
             if install_whl:
                 install_cmd = ['python3', '-m', 'pip', 'install']
                 if args.local:
--
2.20.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#52135): https://edk2.groups.io/g/devel/message/52135
Mute This Topic: https://groups.io/mt/67968737/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-