Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update fixate-requirements.py to cope with PIP 20.3.3 #5123

Merged
merged 44 commits into from
Mar 18, 2021
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
82d774c
Update fixate-requirements.py to cope with PIP 20.3.3
amanda11 Jan 25, 2021
ab3bc0c
Update simplejson as earlier not python 3 supported
amanda11 Jan 25, 2021
9e7a23f
Update rednose so py2 versions do not get attempted
amanda11 Jan 25, 2021
b71eec3
Pin min RandomWords version if use newer pip for build
amanda11 Jan 25, 2021
16432b0
Set min for python-json-logger
amanda11 Jan 25, 2021
1948b0b
ipaddr is python2 only module, picked up by new pip when build. Updat…
amanda11 Jan 25, 2021
7d8e511
Update min versions to what used in a previous CI build for the new v…
amanda11 Jan 25, 2021
95a893b
Update a few more requirements where pip considers multiple versions
amanda11 Jan 25, 2021
034408a
Update more versions
amanda11 Jan 25, 2021
143523d
Pin some requirements that have multiple versions, and are getting pu…
amanda11 Jan 25, 2021
e1cdd3d
Pin some requirements that have multiple versions, and are getting pu…
amanda11 Jan 25, 2021
ddf0f38
Pin some requirements that have multiple versions, and are getting pu…
amanda11 Jan 25, 2021
bad16d6
Pin some requirements that have multiple versions, and are getting pu…
amanda11 Jan 25, 2021
cfe51d3
Pin some requirements that have multiple versions, and are getting pu…
amanda11 Jan 25, 2021
72b4091
Update pip version
amanda11 Jan 25, 2021
56c2b3a
Merge branch 'master' into amanda_tmp_virtualenv
blag Jan 26, 2021
128d385
Install libyaml-dev for PyYAML
blag Jan 26, 2021
2094ca8
Set min pyparsing
amanda11 Jan 27, 2021
e94913a
Put import of internal_req into try/except
amanda11 Jan 27, 2021
3ed3841
Modify fixate-requirements to work with older and new pips
amanda11 Jan 27, 2021
b2bcfac
vine requirement clashing with amqp
amanda11 Jan 28, 2021
9093213
Remove vine completely to prevent pip clash with amqp
amanda11 Jan 28, 2021
aa2d4ec
Remove explicit vine
amanda11 Jan 28, 2021
fff7b5a
If using legacy resolver then have to either not specify versions of …
amanda11 Jan 28, 2021
9d9fbcf
Specifying urllib3 conflicts with requests[security]
amanda11 Jan 28, 2021
f2fa7e7
Specifying urllib3 conflicts with requests[security]
amanda11 Jan 28, 2021
65473c1
Update version on st2tests
amanda11 Jan 28, 2021
eb40242
Update isort
amanda11 Jan 29, 2021
5fd8392
Update to use virtualenv 20.2.2
amanda11 Jan 29, 2021
c15d75b
Re-instate setuptools upgrade but with version used by virtualenv
amanda11 Jan 29, 2021
ddfc8aa
Update to newest virtualenv to match pip 20.3.3
amanda11 Jan 29, 2021
40dda02
Merge branch 'master' into amanda_tmp_virtualenv
amanda11 Feb 12, 2021
636e2d5
Fix lint
amanda11 Feb 12, 2021
6cccab9
Merge branch 'amanda_tmp_virtualenv' of https://github.com/StackStorm…
amanda11 Feb 12, 2021
4efc99a
Update pip in run-pack-tests
amanda11 Feb 15, 2021
dfa17d0
Merge branch 'master' into amanda_tmp_virtualenv
amanda11 Mar 11, 2021
ee0fa53
Apply suggestions from code review
amanda11 Mar 11, 2021
1c435b2
Merge branch 'master' into amanda_tmp_virtualenv
amanda11 Mar 11, 2021
c7248c4
Black formatting
amanda11 Mar 12, 2021
2b064a4
Remove trailing space for lint
amanda11 Mar 12, 2021
53622b9
Merge branch 'master' into amanda_tmp_virtualenv
amanda11 Mar 16, 2021
2814730
Update CHANGELOG.rst
amanda11 Mar 16, 2021
b201768
Update on requirements
amanda11 Mar 16, 2021
686c14a
Update CHANGELOG.rst to force re-run of checks
amanda11 Mar 16, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ jobs:
${{ runner.os }}-${{ matrix.python }}-
- name: Install apt depedencies
run: |
# install dev dependencies for Python LDAP module
# install dev dependencies for Python YAML and LDAP packages
# https://github.com/StackStorm/st2-auth-ldap
sudo apt-get -y update
sudo apt-get -f -y install libldap2-dev libsasl2-dev libssl-dev ldap-utils
sudo apt-get -f -y install libldap2-dev libsasl2-dev libssl-dev libyaml-dev ldap-utils
- name: Install virtualenv
run: |
# Note: Use the verison of virtualenv pinned in fixed-requirements.txt so we
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ Changed

Contributed by @nmaludy, @winem, and @blag

* Updated fixate-requirements to work with PIP 20.3.3 #512
Contributed by Amanda McGuinness (@amanda11 Ammeon Solutions)

Fixed
~~~~~~~~~
* Pin chardet version as newest version was incompatible with pinned requests version #5101
Expand Down
10 changes: 2 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ REQUIREMENTS := test-requirements.txt requirements.txt

# Pin common pip version here across all the targets
# Note! Periodic maintenance pip upgrades are required to be up-to-date with the latest pip security fixes and updates
PIP_VERSION ?= 20.0.2
#PIP_VERSION ?= 20.0.2
PIP_VERSION ?= 20.3.4
PIP_OPTIONS := $(ST2_PIP_OPTIONS)

ifndef PYLINT_CONCURRENCY
Expand Down Expand Up @@ -394,11 +395,7 @@ flake8: requirements .flake8
touch $(VIRTUALENV_ST2CLIENT_DIR)/bin/activate
chmod +x $(VIRTUALENV_ST2CLIENT_DIR)/bin/activate

# NOTE We need to upgrade setuptools to avoid bug with dependency resolving in old versions
# Setuptools 42 added support for python_requires, which is used by the configparser package,
# which is required by the importlib-metadata package
$(VIRTUALENV_ST2CLIENT_DIR)/bin/pip install --upgrade "pip==$(PIP_VERSION)"
$(VIRTUALENV_ST2CLIENT_DIR)/bin/pip install --upgrade "setuptools==44.1.0"

$(VIRTUALENV_ST2CLIENT_DIR)/bin/activate; cd st2client ; ../$(VIRTUALENV_ST2CLIENT_DIR)/bin/python setup.py install ; cd ..
$(VIRTUALENV_ST2CLIENT_DIR)/bin/st2 --version
Expand Down Expand Up @@ -531,9 +528,6 @@ requirements: virtualenv .requirements .sdist-requirements install-runners insta
# only have to update it one place when we change the version
$(VIRTUALENV_DIR)/bin/pip install --upgrade $(shell grep "^virtualenv" fixed-requirements.txt)

# setuptools >= 41.0.1 is required for packs.install in dev envs
# setuptools >= 42 is required so setup.py install respects dependencies' python_requires
$(VIRTUALENV_DIR)/bin/pip install --upgrade "setuptools==44.1.0"
$(VIRTUALENV_DIR)/bin/pip install --upgrade "pbr==5.4.3" # workaround for pbr issue

# Fix for Travis CI race
Expand Down
9 changes: 4 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ argcomplete
bcrypt==3.1.7
chardet<3.1.0
cryptography==3.2
dnspython<2.0.0,>=1.16.0
dnspython>=1.16.0,<2.0.0
eventlet==0.25.1
flex==6.14.0
git+https://github.com/StackStorm/logshipper.git@stackstorm_patched#egg=logshipper
Expand All @@ -23,7 +23,6 @@ git+https://github.com/StackStorm/st2-rbac-backend.git@master#egg=st2-rbac-backe
gitpython==2.1.15
greenlet==0.4.15
gunicorn==19.9.0
ipaddr
jinja2==2.10.3
jsonpath-rw==1.4.0
jsonschema==2.6.0
Expand All @@ -36,14 +35,14 @@ networkx==1.11
nose
nose-parallel==0.3.1
nose-timer==0.7.5
oslo.config<1.13,>=1.12.1
oslo.config>=1.12.1,<1.13
oslo.utils<5.0,>=4.0.0
paramiko==2.7.1
passlib==1.7.1
prettytable
prompt-toolkit==1.0.15
psutil==5.6.6
pyinotify==0.9.6 ; platform_system == "Linux"
pyinotify==0.9.6; platform_system=="Linux"
pymongo==3.10.0
pyrabbit
python-dateutil==2.8.0
Expand All @@ -68,4 +67,4 @@ unittest2
webob==1.8.5
webtest
zake==0.2.2
zipp<=1.0.0,>=0.5
zipp>=0.5,<=1.0.0
87 changes: 65 additions & 22 deletions scripts/fixate-requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@
print('Using pip: %s' % (str(pip_version)))
sys.exit(1)

try:
from pip._internal.req.constructors import parse_req_from_line
except ImportError as e:
# Do not error, as will only use on pip >= 20
pass


def parse_args():
parser = argparse.ArgumentParser(description='Tool for requirements.txt generation.')
Expand Down Expand Up @@ -117,19 +123,34 @@ def merge_source_requirements(sources):
merged_requirements = []
for infile_path in (locate_file(p, must_exist=True) for p in sources):
for req in load_requirements(infile_path):
# Requirements starting with project name "project ..."
if req.req:
# Skip already added project name
if req.name in projects:
continue
projects.add(req.name)
merged_requirements.append(req)

# Requirements lines like "vcs+proto://url"
elif req.link:
merged_requirements.append(req)
if hasattr(req, "requirement"):
# Requirements starting with project name "project ..."
parsedreq = parse_req_from_line(req.requirement, req.line_source)
if parsedreq.requirement:
# Skip already added project name
if parsedreq.requirement.name in projects:
continue
projects.add(parsedreq.requirement.name)
merged_requirements.append(req)

# Requirements lines like "vcs+proto://url"
elif parsedreq.link:
amanda11 marked this conversation as resolved.
Show resolved Hide resolved
merged_requirements.append(req)
else:
raise RuntimeError('Unexpected requirement {0}'.format(req))
else:
raise RuntimeError('Unexpected requirement {0}'.format(req))
if req.req:
# Skip already added project name
if req.name in projects:
continue
projects.add(req.name)
merged_requirements.append(req)

# Requirements lines like "vcs+proto://url"
elif req.link:
amanda11 marked this conversation as resolved.
Show resolved Hide resolved
merged_requirements.append(req)
else:
raise RuntimeError('Unexpected requirement {0}'.format(req))

return merged_requirements

Expand All @@ -147,10 +168,17 @@ def write_requirements(sources=None, fixed_requirements=None, output_file=None,
# Make sure there are no duplicate / conflicting definitions
fixedreq_hash = {}
for req in fixed:
project_name = req.name
if hasattr(req, "requirement"):
parsedreq = parse_req_from_line(req.requirement, req.line_source)
project_name = parsedreq.requirement.name

if not req.req:
continue
if not req.requirement:
continue
else:
project_name = req.name

if not req.req:
continue

if project_name in fixedreq_hash:
raise ValueError('Duplicate definition for dependency "%s"' % (project_name))
Expand All @@ -160,22 +188,37 @@ def write_requirements(sources=None, fixed_requirements=None, output_file=None,
lines_to_write = []
links = set()
for req in requirements:
if req.name in skip:
if hasattr(req, "requirement"):
parsedreq = parse_req_from_line(req.requirement, req.line_source)
project_name = parsedreq.requirement.name
linkreq = parsedreq
else:
project_name = req.name
linkreq = req
if project_name in skip:
continue

# we don't have any idea how to process links, so just add them
if req.link and req.link not in links:
links.add(req.link)
rline = str(req.link)
if linkreq.link and linkreq.link not in links:
links.add(linkreq.link)
rline = str(linkreq.link)

if req.editable:
if (hasattr(req, "is_editable") and req.is_editable) or \
(hasattr(req, "editable") and req.editable):
rline = '-e %s' % (rline)
elif req.req:
elif hasattr(req, "requirement") and req.requirement:
project = parsedreq.requirement.name
req_obj = fixedreq_hash.get(project, req)

rline = str(req_obj.requirement)

# Markers are included in req_obj.requirement, so no
# special processing required
elif hasattr(req, "req") and req.req:
project = req.name
req_obj = fixedreq_hash.get(project, req)

rline = str(req_obj.req)

# Also write out environment markers
if req_obj.markers:
rline += " ; {}".format(str(req_obj.markers))
Expand Down
4 changes: 2 additions & 2 deletions st2actions/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ gitpython==2.1.15
jinja2==2.10.3
kombu==4.6.6
lockfile==0.12.2
oslo.config<1.13,>=1.12.1
oslo.config>=1.12.1,<1.13
oslo.utils<5.0,>=4.0.0
pyinotify==0.9.6 ; platform_system == "Linux"
pyinotify==0.9.6; platform_system=="Linux"
python-dateutil==2.8.0
python-json-logger
pyyaml==5.1.2
Expand Down
2 changes: 1 addition & 1 deletion st2api/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ gunicorn==19.9.0
jsonschema==2.6.0
kombu==4.6.6
mongoengine==0.18.2
oslo.config<1.13,>=1.12.1
oslo.config>=1.12.1,<1.13
oslo.utils<5.0,>=4.0.0
pymongo==3.10.0
simplejson
Expand Down
2 changes: 1 addition & 1 deletion st2auth/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ eventlet==0.25.1
git+https://github.com/StackStorm/st2-auth-backend-flat-file.git@master#egg=st2-auth-backend-flat-file
git+https://github.com/StackStorm/st2-auth-ldap.git@master#egg=st2-auth-ldap
gunicorn==19.9.0
oslo.config<1.13,>=1.12.1
oslo.config>=1.12.1,<1.13
passlib==1.7.1
pymongo==3.10.0
six==1.13.0
Expand Down
2 changes: 1 addition & 1 deletion st2client/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ pyyaml==5.1.2
requests[security]==2.23.0
six==1.13.0
sseclient-py==1.7
zipp<=1.0.0,>=0.5
zipp>=0.5,<=1.0.0
1 change: 0 additions & 1 deletion st2common/in-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ tooz
# Required by tooz - on new versions of tooz, all the backend dependencies need
# to be installed manually
zake
ipaddr
routes
flex
webob
Expand Down
5 changes: 2 additions & 3 deletions st2common/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,21 @@ amqp==2.5.2
apscheduler==3.6.3
chardet<3.1.0
cryptography==3.2
dnspython<2.0.0,>=1.16.0
dnspython>=1.16.0,<2.0.0
eventlet==0.25.1
flex==6.14.0
git+https://github.com/StackStorm/[email protected]#egg=orquesta
git+https://github.com/StackStorm/st2-rbac-backend.git@master#egg=st2-rbac-backend
gitpython==2.1.15
greenlet==0.4.15
ipaddr
jinja2==2.10.3
jsonpath-rw==1.4.0
jsonschema==2.6.0
kombu==4.6.6
lockfile==0.12.2
mongoengine==0.18.2
networkx==1.11
oslo.config<1.13,>=1.12.1
oslo.config>=1.12.1,<1.13
paramiko==2.7.1
pymongo==3.10.0
python-dateutil==2.8.0
Expand Down
6 changes: 3 additions & 3 deletions st2common/st2common/util/ip_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from __future__ import absolute_import
import re

import ipaddr
import ipaddress
from st2common.log import logging

LOG = logging.getLogger(__name__)
Expand Down Expand Up @@ -44,7 +44,7 @@ def is_ipv6(ip_str):
:rtype: ``bool``
"""
try:
addr = ipaddr.IPAddress(ip_str)
addr = ipaddress.ip_address(ip_str)
return addr.version == 6
except:
return False
Expand All @@ -60,7 +60,7 @@ def is_ipv4(ip_str):
:rtype: ``bool``
"""
try:
addr = ipaddr.IPAddress(ip_str)
addr = ipaddress.ip_address(ip_str)
return addr.version == 4
except:
return False
Expand Down
2 changes: 1 addition & 1 deletion st2exporter/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
# update the component requirements.txt
eventlet==0.25.1
kombu==4.6.6
oslo.config<1.13,>=1.12.1
oslo.config>=1.12.1,<1.13
six==1.13.0
2 changes: 1 addition & 1 deletion st2reactor/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ eventlet==0.25.1
jsonpath-rw==1.4.0
jsonschema==2.6.0
kombu==4.6.6
oslo.config<1.13,>=1.12.1
oslo.config>=1.12.1,<1.13
python-dateutil==2.8.0
six==1.13.0
2 changes: 1 addition & 1 deletion st2stream/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ gunicorn==19.9.0
jsonschema==2.6.0
kombu==4.6.6
mongoengine==0.18.2
oslo.config<1.13,>=1.12.1
oslo.config>=1.12.1,<1.13
oslo.utils<5.0,>=4.0.0
pymongo==3.10.0
six==1.13.0
2 changes: 1 addition & 1 deletion st2tests/st2tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
'WorkflowTestCase'
]

__version__ = '3.3dev'
__version__ = '3.4dev'
2 changes: 1 addition & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pylint==2.6.0
pylint-plugin-utils>=0.4
bandit==1.5.1
ipython<6.0.0
isort<=4.0.0
isort>=4.2.5,<5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was there a reason you pinned this to <5.0.0?

According to the changelog for isort v5.0.0:

isort now requires Python 3.6+ to run but continues to support formatting on ALL versions of python including Python 2 code.

Which should be fine for this repo now.

If we do need to keep it pinned to <5.0.0, that would also work fine, but I'd like to start documenting why we pin certain packages to certain versions.

If we keep that pinned to a maximum version, it potentially complicates our life in the future with pylint:

ERROR: Cannot install -r /tmp/st2/test-requirements.txt (line 6) and isort<=4.0.0 because these package versions have conflicting dependencies.

The conflict is caused by:
The user requested isort<=4.0.0
pylint 2.6.0 depends on isort<6 and >=4.2.5

To fix this you could try to:

  1. loosen the range of package versions you've specified
  2. remove package versions to allow pip attempt to solve the dependency conflict

StackStorm/st2-rbac-backend#46 is being held up by this PR due to this, which is not a big deal, it just forces a resolution order as we slowly crawl towards the next major ST2 release.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blag I copied the version that was in st2-auth-ldap that was needed to get the CI working on st2-auth-ldap. And I believe that requirement was for pylint 2.6.0.
BUT that's a bit odd that the same pylint is now saying < 6 not < 5.
I was also seeing the new pip complain if you have one requirement saying packageA >=4.2.5 and packageB say >=4.25 and < 6. I will see if I can get it to pass with isort > 4.2.5, but I think with the new pip that will complain. But I'll double-check in case it was something else.

mock==3.0.5
nose>=1.3.7
tabulate
Expand Down