Skip to content

Commit

Permalink
Salt should not do any logic to include/exclude requirements. That's …
Browse files Browse the repository at this point in the history
…pip's job.

Refs saltstack#62386
Fixes saltstack#62392

Signed-off-by: Pedro Algarvio <[email protected]>
  • Loading branch information
s0undt3ch authored and Megan Wilhite committed Jul 28, 2022
1 parent 90c6471 commit 04fbfd3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 85 deletions.
1 change: 1 addition & 0 deletions changelog/62392.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
All of the requirements provided in the requirements files are now included. The job of evaluating platform markers is not Salt's it's pip's.
85 changes: 0 additions & 85 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import contextlib
import distutils.dist
import glob
import operator
import os
import platform
import sys
Expand Down Expand Up @@ -175,77 +174,6 @@
# ----- Helper Functions -------------------------------------------------------------------------------------------->


def _parse_op(op):
"""
>>> _parse_op('>')
'gt'
>>> _parse_op('>=')
'ge'
>>> _parse_op('=>')
'ge'
>>> _parse_op('=> ')
'ge'
>>> _parse_op('<')
'lt'
>>> _parse_op('<=')
'le'
>>> _parse_op('==')
'eq'
>>> _parse_op(' <= ')
'le'
"""
op = op.strip()
if ">" in op:
if "=" in op:
return "ge"
else:
return "gt"
elif "<" in op:
if "=" in op:
return "le"
else:
return "lt"
elif "!" in op:
return "ne"
else:
return "eq"


def _parse_ver(ver):
"""
>>> _parse_ver("'3.4' # pyzmq 17.1.0 stopped building wheels for python3.4")
'3.4'
>>> _parse_ver('"3.4"')
'3.4'
>>> _parse_ver('"2.6.17"')
'2.6.17'
"""
if "#" in ver:
ver, _ = ver.split("#", 1)
ver = ver.strip()
return ver.strip("'").strip('"')


def _check_ver(pyver, op, wanted):
"""
>>> _check_ver('2.7.15', 'gt', '2.7')
True
>>> _check_ver('2.7.15', 'gt', '2.7.15')
False
>>> _check_ver('2.7.15', 'ge', '2.7.15')
True
>>> _check_ver('2.7.15', 'eq', '2.7.15')
True
"""
pyver = distutils.version.LooseVersion(pyver)
wanted = distutils.version.LooseVersion(wanted)
if not isinstance(pyver, str):
pyver = str(pyver)
if not isinstance(wanted, str):
wanted = str(wanted)
return getattr(operator, "__{}__".format(op))(pyver, wanted)


def _parse_requirements_file(requirements_file):
parsed_requirements = []
with open(requirements_file) as rfh:
Expand All @@ -256,19 +184,6 @@ def _parse_requirements_file(requirements_file):
if IS_WINDOWS_PLATFORM:
if "libcloud" in line:
continue
try:
pkg, pyverspec = line.rsplit(";", 1)
except ValueError:
pkg, pyverspec = line, ""
pyverspec = pyverspec.strip()
if pyverspec and (
not pkg.startswith("pycrypto") or pkg.startswith("pycryptodome")
):
_, op, ver = pyverspec.split(" ", 2)
if not _check_ver(
platform.python_version(), _parse_op(op), _parse_ver(ver)
):
continue
parsed_requirements.append(line)
return parsed_requirements

Expand Down

0 comments on commit 04fbfd3

Please sign in to comment.