Salt is not Py2 compatible since Sodium

This commit is contained in:
Pedro Algarvio 2020-09-14 08:29:38 +01:00
parent 7efd60131b
commit d773dfc85f
No known key found for this signature in database
GPG key ID: BB36BF6584A298FF

View file

@ -3,22 +3,18 @@
The setup script for salt
"""
# pylint: disable=file-perms,ungrouped-imports,wrong-import-order,wrong-import-position,repr-flag-used-in-string
# pylint: disable=3rd-party-local-module-not-gated,resource-leakage,blacklisted-module
# pylint: disable=C0111,E1101,E1103,F0401,W0611,W0201,W0232,R0201,R0902,R0903
# For Python 2.5. A no-op on 2.6 and above.
# pylint: disable=file-perms,resource-leakage
import contextlib
import distutils.dist
import glob
import inspect
import operator
import os
import platform
import sys
from ctypes.util import find_library
from datetime import datetime
# pylint: disable=no-name-in-module
from distutils import log
from distutils.cmd import Command
from distutils.command.build import build
@ -27,15 +23,16 @@ from distutils.command.install_lib import install_lib
from distutils.errors import DistutilsArgError
from distutils.version import LooseVersion # pylint: disable=blacklisted-module
# pylint: disable=E0611
import setuptools
from setuptools import setup
from setuptools.command.bdist_egg import bdist_egg
from setuptools.command.develop import develop
from setuptools.command.egg_info import egg_info
from setuptools.command.install import install
from setuptools.command.sdist import sdist
# pylint: enable=no-name-in-module
try:
from urllib2 import urlopen
except ImportError:
@ -48,7 +45,6 @@ try:
HAS_BDIST_WHEEL = True
except ImportError:
HAS_BDIST_WHEEL = False
# pylint: enable=E0611
try:
import zmq
@ -96,15 +92,12 @@ else:
)
# Store a reference whether if we're running under Python 3 and above
IS_PY3 = sys.version_info > (3,)
try:
# Add the esky bdist target if the module is available
# may require additional modules depending on platform
from esky import bdist_esky
# bbfreeze chosen for its tight integration with distutils
import bbfreeze
import bbfreeze # pylint: disable=unused-import
from esky import bdist_esky # pylint: disable=unused-import
HAS_ESKY = True
except ImportError:
@ -213,11 +206,8 @@ def _check_ver(pyver, op, wanted):
"""
pyver = distutils.version.LooseVersion(pyver)
wanted = distutils.version.LooseVersion(wanted)
if IS_PY3:
if not isinstance(pyver, str):
pyver = str(pyver)
if not isinstance(wanted, str):
wanted = str(wanted)
return getattr(operator, "__{}__".format(op))(pyver, wanted)
@ -231,10 +221,6 @@ def _parse_requirements_file(requirements_file):
if IS_WINDOWS_PLATFORM:
if "libcloud" in line:
continue
if IS_PY3 and "futures" in line.lower():
# Python 3 already has futures, installing it will only break
# the current python installation whenever futures is imported
continue
try:
pkg, pyverspec = line.rsplit(";", 1)
except ValueError:
@ -514,20 +500,12 @@ class DownloadWindowsDlls(Command):
if req.getcode() == 200:
with open(fdest, "wb") as wfh:
if IS_PY3:
while True:
chunk = req.read(4096)
if not chunk:
break
wfh.write(chunk)
wfh.flush()
else:
while True:
for chunk in req.read(4096):
if not chunk:
break
wfh.write(chunk)
wfh.flush()
else:
log.error(
"Failed to download {}.dll to {} from {}".format(
@ -543,10 +521,6 @@ class Sdist(sdist):
self.run_command("write_salt_ssh_packaging_file")
self.filelist.files.append(os.path.basename(PACKAGED_FOR_SALT_SSH_FILE))
if not IS_PY3 and not isinstance(base_dir, str):
# Work around some bad code in distutils which logs unicode paths
# against a str format string.
base_dir = base_dir.encode("utf-8")
sdist.make_release_tree(self, base_dir, files)
# Let's generate salt/_version.py to include in the sdist tarball
@ -999,10 +973,7 @@ class SaltDistribution(distutils.dist.Distribution):
self.name = "salt-ssh" if PACKAGED_FOR_SALT_SSH else "salt"
self.salt_version = __version__ # pylint: disable=undefined-variable
self.description = "Portable, distributed, remote execution and configuration management system"
kwargs = {}
if IS_PY3:
kwargs["encoding"] = "utf-8"
with open(SALT_LONG_DESCRIPTION_FILE, **kwargs) as f:
with open(SALT_LONG_DESCRIPTION_FILE, encoding="utf-8") as f:
self.long_description = f.read()
self.long_description_content_type = "text/x-rst"
self.author = "Thomas S Hatch"
@ -1357,7 +1328,7 @@ class SaltDistribution(distutils.dist.Distribution):
elif sys.platform.startswith("linux"):
freezer_includes.append("spwd")
try:
import yum # pylint: disable=unused-variable
import yum # pylint: disable=unused-import
freezer_includes.append("yum")
except ImportError: