Removed the support for the deprecated distutils package. eric7

Fri, 30 Jul 2021 20:13:09 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 30 Jul 2021 20:13:09 +0200
branch
eric7
changeset 8501
7b5f10581c35
parent 8500
e7814dd19115
child 8503
3241dbe918ef

Removed the support for the deprecated distutils package.

eric7/DebugClients/Python/DebugBase.py file | annotate | diff | comparison | revisions
eric7/DebugClients/Python/eric7dbgstub.py file | annotate | diff | comparison | revisions
eric7/Globals/__init__.py file | annotate | diff | comparison | revisions
eric7/Plugins/WizardPlugins/SetupWizard/SetupWizardDialog.py file | annotate | diff | comparison | revisions
eric7/Plugins/WizardPlugins/SetupWizard/SetupWizardDialog.ui file | annotate | diff | comparison | revisions
eric7/eric7.py file | annotate | diff | comparison | revisions
scripts/install-debugclients.py file | annotate | diff | comparison | revisions
scripts/install.py file | annotate | diff | comparison | revisions
scripts/uninstall-debugclients.py file | annotate | diff | comparison | revisions
scripts/uninstall.py file | annotate | diff | comparison | revisions
--- a/eric7/DebugClients/Python/DebugBase.py	Fri Jul 30 17:40:58 2021 +0200
+++ b/eric7/DebugClients/Python/DebugBase.py	Fri Jul 30 20:13:09 2021 +0200
@@ -60,8 +60,6 @@
 
     Provides methods for the 'owning' client to call to step etc.
     """
-    # Don't thrust distutils.sysconfig.get_python_lib: possible case mismatch
-    #  on Windows
     lib = os.path.dirname(inspect.__file__)
     # tuple required because it's accessed a lot of times by startswith method
     pathsToSkip = ('<', os.path.dirname(__file__), inspect.__file__[:-1])
--- a/eric7/DebugClients/Python/eric7dbgstub.py	Fri Jul 30 17:40:58 2021 +0200
+++ b/eric7/DebugClients/Python/eric7dbgstub.py	Fri Jul 30 20:13:09 2021 +0200
@@ -9,14 +9,14 @@
 
 import os
 import sys
-import distutils.sysconfig
+import sysconfig
 
 from eric7config import getConfig
 
 debugger = None
 __scriptname = None
 
-modDir = distutils.sysconfig.get_python_lib(True)
+modDir = sysconfig.get_path('platlib')
 ericpath = os.getenv('ERICDIR', getConfig('ericDir'))
 
 if ericpath not in sys.path:
--- a/eric7/Globals/__init__.py	Fri Jul 30 17:40:58 2021 +0200
+++ b/eric7/Globals/__init__.py	Fri Jul 30 20:13:09 2021 +0200
@@ -11,10 +11,10 @@
 # Note: Do not import any eric stuff in here!!!!!!!
 #
 
-import sys
+import contextlib
 import os
 import re
-import contextlib
+import sys
 
 from PyQt6.QtCore import (
     QDir, QByteArray, QCoreApplication, QT_VERSION, QProcess, qVersion
@@ -245,8 +245,8 @@
     @return path to the Python library directory
     @rtype str
     """
-    import distutils.sysconfig
-    return distutils.sysconfig.get_python_lib(True)
+    import sysconfig
+    return sysconfig.get_path('platlib')
 
 
 def getPyQt6ModulesDirectory():
@@ -256,9 +256,9 @@
     @return path to the PyQt6 modules directory
     @rtype str
     """
-    import distutils.sysconfig
+    import sysconfig
     
-    pyqtPath = os.path.join(distutils.sysconfig.get_python_lib(True), "PyQt6")
+    pyqtPath = os.path.join(sysconfig.get_path('platlib'), "PyQt6")
     if os.path.exists(pyqtPath):
         return pyqtPath
     
--- a/eric7/Plugins/WizardPlugins/SetupWizard/SetupWizardDialog.py	Fri Jul 30 17:40:58 2021 +0200
+++ b/eric7/Plugins/WizardPlugins/SetupWizard/SetupWizardDialog.py	Fri Jul 30 20:13:09 2021 +0200
@@ -19,7 +19,6 @@
 from EricWidgets.EricApplication import ericApp
 from EricWidgets import EricMessageBox, EricFileDialog
 from EricWidgets.EricCompleters import EricDirCompleter
-from EricGui.EricOverrideCursor import EricOverrideCursor
 
 from .Ui_SetupWizardDialog import Ui_SetupWizardDialog
 
@@ -58,10 +57,6 @@
         self.packageDirButton.setIcon(UI.PixmapCache.getIcon("open"))
         self.sourceDirectoryButton.setIcon(UI.PixmapCache.getIcon("open"))
         
-        self.variantComboBox.addItem(self.tr("distutils"), "distutils.core")
-        self.variantComboBox.addItem(self.tr("setuptools"), "setuptools")
-        self.variantComboBox.setCurrentIndex(1)
-        
         self.__mandatoryStyleSheet = "QLineEdit {border: 2px solid;}"
         for lineEdit in [self.nameEdit, self.versionEdit,
                          self.homePageUrlEdit, self.authorEdit,
@@ -288,14 +283,9 @@
             code += os.linesep
         
         if self.importCheckBox.isChecked():
-            variant = self.variantComboBox.itemData(
-                self.variantComboBox.currentIndex())
-            if variant == "setuptools":
-                additionalImport = ", find_packages"
-            else:
-                additionalImport = ""
-            code += "from {0} import setup{1}{2}".format(
-                variant, additionalImport, os.linesep)
+            additionalImport = ", find_packages"
+            code += "from setuptools import setup{0}{1}".format(
+                additionalImport, os.linesep)
         if code:
             code += "{0}{0}".format(os.linesep)
         
@@ -394,47 +384,32 @@
             code += '{0}keywords="{1}",{2}'.format(
                 istring, self.keywordsEdit.text(), os.linesep)
         
-        if self.variantComboBox.currentIndex() == 0:
-            # distutils
-            packages = []
-            for row in range(self.packagesList.count()):
-                packages.append(self.packagesList.item(row).text())
-            if packages:
-                code += '{0}packages=[{1}'.format(istring, os.linesep)
-                code += '{0}"{1}"{2}'.format(
-                    i1string,
-                    '",{0}{1}"'.format(os.linesep, i1string).join(packages),
-                    os.linesep)
-                code += '{0}],{1}'.format(istring, os.linesep)
-            del packages
-        elif self.variantComboBox.currentIndex() == 1:
-            # setuptools
-            code += '{0}packages=find_packages('.format(istring)
-            src = Utilities.fromNativeSeparators(
-                self.sourceDirectoryEdit.text())
-            excludePatterns = []
-            for row in range(self.excludePatternList.count()):
-                excludePatterns.append(
-                    self.excludePatternList.item(row).text())
-            if src:
-                code += '{0}{1}"{2}"'.format(os.linesep, i1string, src)
-                if excludePatterns:
-                    code += ','
-                else:
-                    code += '{0}{1}'.format(os.linesep, istring)
+        code += '{0}packages=find_packages('.format(istring)
+        src = Utilities.fromNativeSeparators(
+            self.sourceDirectoryEdit.text())
+        excludePatterns = []
+        for row in range(self.excludePatternList.count()):
+            excludePatterns.append(
+                self.excludePatternList.item(row).text())
+        if src:
+            code += '{0}{1}"{2}"'.format(os.linesep, i1string, src)
             if excludePatterns:
-                code += '{0}{1}exclude=[{0}'.format(os.linesep, i1string)
-                code += '{0}"{1}"{2}'.format(
-                    i2string,
-                    '",{0}{1}"'.format(os.linesep, i2string)
-                    .join(excludePatterns),
-                    os.linesep)
-                code += '{0}]{1}{2}'.format(i1string, os.linesep, istring)
-            code += '),{0}'.format(os.linesep)
-            
-            if self.includePackageDataCheckBox.isChecked():
-                code += '{0}include_package_data = True,{1}'.format(
-                    istring, os.linesep)
+                code += ','
+            else:
+                code += '{0}{1}'.format(os.linesep, istring)
+        if excludePatterns:
+            code += '{0}{1}exclude=[{0}'.format(os.linesep, i1string)
+            code += '{0}"{1}"{2}'.format(
+                i2string,
+                '",{0}{1}"'.format(os.linesep, i2string)
+                .join(excludePatterns),
+                os.linesep)
+            code += '{0}]{1}{2}'.format(i1string, os.linesep, istring)
+        code += '),{0}'.format(os.linesep)
+        
+        if self.includePackageDataCheckBox.isChecked():
+            code += '{0}include_package_data = True,{1}'.format(
+                istring, os.linesep)
         
         modules = []
         for row in range(self.modulesList.count()):
@@ -496,82 +471,6 @@
         self.projectButton.setEnabled(False)
     
     @pyqtSlot()
-    def on_packagesList_itemSelectionChanged(self):
-        """
-        Private slot to handle a change of selected items of the
-        packages list.
-        """
-        self.deletePackageButton.setEnabled(
-            len(self.packagesList.selectedItems()) > 0)
-    
-    @pyqtSlot()
-    def on_deletePackageButton_clicked(self):
-        """
-        Private slot to delete the selected package items.
-        """
-        for itm in self.packagesList.selectedItems():
-            self.packagesList.takeItem(
-                self.packagesList.row(itm))
-            del itm
-    
-    @pyqtSlot()
-    def on_addPackageButton_clicked(self):
-        """
-        Private slot to add a package to the list.
-        """
-        pkg = Utilities.toNativeSeparators(self.packageEdit.text())
-        self.__addPackage(pkg)
-    
-    @pyqtSlot()
-    def on_packageEdit_returnPressed(self):
-        """
-        Private slot handling a press of the return button of the
-        package edit.
-        """
-        self.on_addPackageButton_clicked()
-    
-    @pyqtSlot(str)
-    def on_packageEdit_textChanged(self, txt):
-        """
-        Private slot to handle a change of the package text.
-        
-        @param txt text of the line edit (string)
-        """
-        self.addPackageButton.setEnabled(bool(txt))
-    
-    @pyqtSlot()
-    def on_packageDirButton_clicked(self):
-        """
-        Private slot to select a package directory via a directory
-        selection dialog.
-        """
-        startDir = self.packageEdit.text()
-        if not startDir:
-            startDir = self.packageRootEdit.text() or self.__getStartDir()
-        packageDir = EricFileDialog.getExistingDirectory(
-            self,
-            self.tr("Package Directory"),
-            Utilities.fromNativeSeparators(startDir))
-        if packageDir:
-            self.packageEdit.setText(
-                Utilities.toNativeSeparators(packageDir))
-    
-    @pyqtSlot()
-    def on_autodiscoverPackagesButton_clicked(self):
-        """
-        Private slot to discover packages automatically.
-        """
-        with EricOverrideCursor():
-            self.autodiscoverPackagesButton.setEnabled(False)
-            startDir = self.packageRootEdit.text() or self.__getStartDir()
-            if startDir:
-                self.packagesList.clear()
-                for dirpath, _dirnames, filenames in os.walk(startDir):
-                    if "__init__.py" in filenames:
-                        self.__addPackage(dirpath)
-            self.autodiscoverPackagesButton.setEnabled(True)
-    
-    @pyqtSlot()
     def on_packageRootDirButton_clicked(self):
         """
         Private slot to select the packages root directory via a
@@ -601,44 +500,6 @@
         self.autodiscoverPackagesButton.setEnabled(
             projectOpen or validPackagesRoot)
     
-    def __addPackage(self, pkgDir):
-        """
-        Private method to add a package to the list.
-        
-        @param pkgDir name of the package directory (string)
-        """
-        if pkgDir:
-            if "\\" in pkgDir or "/" in pkgDir:
-                # It is a directory. Check for an __init__.py file.
-                if os.path.isabs(pkgDir):
-                    prefix = ""
-                else:
-                    prefix = self.packageRootEdit.text()
-                initName = os.path.join(
-                    prefix,
-                    Utilities.toNativeSeparators(pkgDir),
-                    "__init__.py")
-                if not os.path.exists(initName):
-                    res = EricMessageBox.information(
-                        self,
-                        self.tr("Add Package"),
-                        self.tr("""<p>The directory <b>{0}</b> is not"""
-                                """ a Python package.</p>""")
-                        .format(pkgDir),
-                        EricMessageBox.Ignore | EricMessageBox.Ok)
-                    if res == EricMessageBox.Ok:
-                        return
-            
-            pkg = pkgDir.replace(
-                Utilities.toNativeSeparators(self.packageRootEdit.text()), "")
-            if pkg.startswith(("\\", "/")):
-                pkg = pkg[1:]
-            if pkg:
-                QListWidgetItem(
-                    pkg.replace("\\", ".").replace("/", "."),
-                    self.packagesList)
-                self.packageEdit.clear()
-    
     def __getStartDir(self):
         """
         Private method to get the start directory for selection dialogs.
@@ -727,15 +588,6 @@
                                 .replace("\\", ".").replace("/", "."),
                                 self.modulesList)
     
-    @pyqtSlot(int)
-    def on_variantComboBox_currentIndexChanged(self, index):
-        """
-        Private slot handling a change of the setup variant.
-        
-        @param index index of the selected entry (integer)
-        """
-        self.packagesStackedWidget.setCurrentIndex(index)
-    
     @pyqtSlot()
     def on_excludePatternList_itemSelectionChanged(self):
         """
--- a/eric7/Plugins/WizardPlugins/SetupWizard/SetupWizardDialog.ui	Fri Jul 30 17:40:58 2021 +0200
+++ b/eric7/Plugins/WizardPlugins/SetupWizard/SetupWizardDialog.ui	Fri Jul 30 20:13:09 2021 +0200
@@ -71,37 +71,6 @@
     </layout>
    </item>
    <item>
-    <layout class="QHBoxLayout" name="horizontalLayout_2">
-     <item>
-      <widget class="QLabel" name="label_13">
-       <property name="text">
-        <string>Setup Variant:</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QComboBox" name="variantComboBox">
-       <property name="toolTip">
-        <string>Select the setup variant</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <spacer name="horizontalSpacer_2">
-       <property name="orientation">
-        <enum>Qt::Horizontal</enum>
-       </property>
-       <property name="sizeHint" stdset="0">
-        <size>
-         <width>40</width>
-         <height>20</height>
-        </size>
-       </property>
-      </spacer>
-     </item>
-    </layout>
-   </item>
-   <item>
     <layout class="QHBoxLayout" name="horizontalLayout_5">
      <item>
       <widget class="QLabel" name="label_15">
@@ -532,91 +501,8 @@
        <item>
         <widget class="QStackedWidget" name="packagesStackedWidget">
          <property name="currentIndex">
-          <number>1</number>
+          <number>0</number>
          </property>
-         <widget class="QWidget" name="distutilsPage">
-          <layout class="QVBoxLayout" name="verticalLayout_5">
-           <property name="leftMargin">
-            <number>0</number>
-           </property>
-           <property name="topMargin">
-            <number>0</number>
-           </property>
-           <property name="rightMargin">
-            <number>0</number>
-           </property>
-           <property name="bottomMargin">
-            <number>0</number>
-           </property>
-           <item>
-            <widget class="QListWidget" name="packagesList">
-             <property name="alternatingRowColors">
-              <bool>true</bool>
-             </property>
-             <property name="selectionMode">
-              <enum>QAbstractItemView::ExtendedSelection</enum>
-             </property>
-             <property name="sortingEnabled">
-              <bool>true</bool>
-             </property>
-            </widget>
-           </item>
-           <item>
-            <layout class="QHBoxLayout" name="horizontalLayout_4">
-             <item>
-              <widget class="QPushButton" name="deletePackageButton">
-               <property name="enabled">
-                <bool>false</bool>
-               </property>
-               <property name="toolTip">
-                <string>Press to delete the selected entries</string>
-               </property>
-               <property name="text">
-                <string>Delete</string>
-               </property>
-              </widget>
-             </item>
-             <item>
-              <widget class="QPushButton" name="addPackageButton">
-               <property name="enabled">
-                <bool>false</bool>
-               </property>
-               <property name="toolTip">
-                <string>Add the package</string>
-               </property>
-               <property name="text">
-                <string>Add</string>
-               </property>
-              </widget>
-             </item>
-             <item>
-              <widget class="QLineEdit" name="packageEdit">
-               <property name="toolTip">
-                <string>Enter a package name to be added</string>
-               </property>
-              </widget>
-             </item>
-             <item>
-              <widget class="QToolButton" name="packageDirButton">
-               <property name="toolTip">
-                <string>Press to select a package directory via a directory selection dialog</string>
-               </property>
-              </widget>
-             </item>
-            </layout>
-           </item>
-           <item>
-            <widget class="QPushButton" name="autodiscoverPackagesButton">
-             <property name="toolTip">
-              <string>Press to discover packages of a project automatically</string>
-             </property>
-             <property name="text">
-              <string>Autodiscover Packages</string>
-             </property>
-            </widget>
-           </item>
-          </layout>
-         </widget>
          <widget class="QWidget" name="setuptoolsPage">
           <layout class="QGridLayout" name="gridLayout_5">
            <property name="leftMargin">
@@ -655,11 +541,14 @@
              </property>
             </widget>
            </item>
-           <item row="1" column="0" alignment="Qt::AlignTop">
+           <item row="1" column="0">
             <widget class="QLabel" name="label_18">
              <property name="text">
               <string>Exclude Patterns:</string>
              </property>
+             <property name="alignment">
+              <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+             </property>
             </widget>
            </item>
            <item row="1" column="1" colspan="2">
@@ -900,7 +789,6 @@
   <tabstop>introCheckBox</tabstop>
   <tabstop>importCheckBox</tabstop>
   <tabstop>metaDataCheckBox</tabstop>
-  <tabstop>variantComboBox</tabstop>
   <tabstop>packageRootEdit</tabstop>
   <tabstop>packageRootDirButton</tabstop>
   <tabstop>dataTabWidget</tabstop>
@@ -937,12 +825,6 @@
   <tabstop>deleteScriptButton</tabstop>
   <tabstop>addScriptButton</tabstop>
   <tabstop>projectButton</tabstop>
-  <tabstop>autodiscoverPackagesButton</tabstop>
-  <tabstop>deletePackageButton</tabstop>
-  <tabstop>addPackageButton</tabstop>
-  <tabstop>packageEdit</tabstop>
-  <tabstop>packageDirButton</tabstop>
-  <tabstop>packagesList</tabstop>
  </tabstops>
  <resources/>
  <connections>
--- a/eric7/eric7.py	Fri Jul 30 17:40:58 2021 +0200
+++ b/eric7/eric7.py	Fri Jul 30 20:13:09 2021 +0200
@@ -11,9 +11,13 @@
 of the IDE and starts the Qt event loop.
 """
 
-import sys
+import contextlib
+import io
+import logging
 import os
-import contextlib
+import sys
+import traceback
+import time
 
 originalPathString = os.getenv("PATH")
 
@@ -25,11 +29,6 @@
 
 sys.path.insert(1, os.path.dirname(__file__))
 
-import traceback
-import time
-import logging
-import io
-
 try:
     from PyQt6.QtCore import qWarning, QLibraryInfo, QTimer, QCoreApplication
 except ImportError:
--- a/scripts/install-debugclients.py	Fri Jul 30 17:40:58 2021 +0200
+++ b/scripts/install-debugclients.py	Fri Jul 30 20:13:09 2021 +0200
@@ -11,14 +11,14 @@
 Installation script for the eric debug clients.
 """
 
+import compileall
+import contextlib
+import fnmatch
 import io
-import sys
 import os
 import re
-import compileall
 import shutil
-import fnmatch
-import contextlib
+import sys
 
 # Define the globals.
 progName = None
@@ -86,13 +86,9 @@
     """
     global modDir, pyModDir
     
-    try:
-        import distutils.sysconfig
-    except ImportError:
-        print("Please install the 'distutils' package first.")
-        exit(5)
+    import sysconfig
 
-    modDir = distutils.sysconfig.get_python_lib(True)
+    modDir = sysconfig.get_path('platlib')
     pyModDir = modDir
 
 
--- a/scripts/install.py	Fri Jul 30 17:40:58 2021 +0200
+++ b/scripts/install.py	Fri Jul 30 20:13:09 2021 +0200
@@ -9,22 +9,22 @@
 Installation script for the eric IDE and all eric related tools.
 """
 
-import sys
+import compileall
+import contextlib
+import datetime
+import fnmatch
+import getpass
+import glob
+import io
+import json
 import os
+import py_compile
 import re
-import compileall
-import py_compile
-import glob
+import shlex
 import shutil
-import fnmatch
 import subprocess               # secok
 import time
-import io
-import json
-import shlex
-import datetime
-import getpass
-import contextlib
+import sys
 
 # Define the globals.
 progName = None
@@ -190,11 +190,7 @@
     """
     global platBinDir, modDir, pyModDir, apisDir, platBinDirOld
     
-    try:
-        import distutils.sysconfig
-    except ImportError:
-        print("Please install the 'distutils' package first.")
-        exit(5)
+    import sysconfig
     
     if sys.platform.startswith(("win", "cygwin")):
         platBinDir = sys.exec_prefix
@@ -218,7 +214,7 @@
         ):
             platBinDirOld = "/usr/local/bin"
 
-    modDir = distutils.sysconfig.get_python_lib(True)
+    modDir = sysconfig.get_path('platlib')
     pyModDir = modDir
     
     pyqtDataDir = os.path.join(modDir, "PyQt6")
--- a/scripts/uninstall-debugclients.py	Fri Jul 30 17:40:58 2021 +0200
+++ b/scripts/uninstall-debugclients.py	Fri Jul 30 20:13:09 2021 +0200
@@ -10,11 +10,11 @@
 Unnstallation script for the eric debug clients.
 """
 
-import sys
+import contextlib
 import os
 import shutil
-import distutils.sysconfig
-import contextlib
+import sys
+import sysconfig
 
 # Define the globals.
 progName = None
@@ -64,7 +64,7 @@
     """
     global modDir, pyModDir
 
-    modDir = distutils.sysconfig.get_python_lib(True)
+    modDir = sysconfig.get_path('platlib')
     pyModDir = modDir
 
 
--- a/scripts/uninstall.py	Fri Jul 30 17:40:58 2021 +0200
+++ b/scripts/uninstall.py	Fri Jul 30 20:13:09 2021 +0200
@@ -10,12 +10,12 @@
 Uninstallation script for the eric IDE and all eric related tools.
 """
 
-import sys
+import contextlib
+import glob
 import os
 import shutil
-import glob
-import distutils.sysconfig
-import contextlib
+import sys
+import sysconfig
 
 # Define the globals.
 progName = None
@@ -86,7 +86,7 @@
     """
     global pyModDir
 
-    pyModDir = distutils.sysconfig.get_python_lib(True)
+    pyModDir = sysconfig.get_path('platlib')
 
 
 def wrapperNames(dname, wfile):

eric ide

mercurial