Skip to content

Commit 4022aea

Browse files
amanda11blagcognifloyd
authored
Update fixate-requirements.py to cope with PIP 20.3.3 (#5123)
* Update fixate-requirements.py to cope with PIP 20.3.3 * Update simplejson as earlier not python 3 supported * Update rednose so py2 versions do not get attempted * Pin min RandomWords version if use newer pip for build * Set min for python-json-logger * ipaddr is python2 only module, picked up by new pip when build. Update to use ipaddress built-in python3 module * Update min versions to what used in a previous CI build for the new version files * Update a few more requirements where pip considers multiple versions * Update more versions * Pin some requirements that have multiple versions, and are getting pulled in by other dependencies * Pin some requirements that have multiple versions, and are getting pulled in by other dependencies * Pin some requirements that have multiple versions, and are getting pulled in by other dependencies * Pin some requirements that have multiple versions, and are getting pulled in by other dependencies * Pin some requirements that have multiple versions, and are getting pulled in by other dependencies * Update pip version * Install libyaml-dev for PyYAML * Set min pyparsing * Put import of internal_req into try/except * Modify fixate-requirements to work with older and new pips * vine requirement clashing with amqp * Remove vine completely to prevent pip clash with amqp * Remove explicit vine * If using legacy resolver then have to either not specify versions of inherited dependencies, or have exact version - else it conflicts * Specifying urllib3 conflicts with requests[security] * Specifying urllib3 conflicts with requests[security] * Update version on st2tests * Update isort * Update to use virtualenv 20.2.2 * Re-instate setuptools upgrade but with version used by virtualenv * Update to newest virtualenv to match pip 20.3.3 * Fix lint * Update pip in run-pack-tests * Apply suggestions from code review Co-authored-by: Jacob Floyd <[email protected]> * Black formatting * Remove trailing space for lint * Update CHANGELOG.rst * Update on requirements * Update CHANGELOG.rst to force re-run of checks Co-authored-by: blag <[email protected]> Co-authored-by: Jacob Floyd <[email protected]>
1 parent f48877f commit 4022aea

File tree

17 files changed

+96
-56
lines changed

17 files changed

+96
-56
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ jobs:
123123
${{ runner.os }}-${{ matrix.python }}-
124124
- name: Install apt depedencies
125125
run: |
126-
# install dev dependencies for Python LDAP module
126+
# install dev dependencies for Python YAML and LDAP packages
127127
# https://github.com/StackStorm/st2-auth-ldap
128128
sudo apt-get -y update
129-
sudo apt-get -f -y install libldap2-dev libsasl2-dev libssl-dev ldap-utils
129+
sudo apt-get -f -y install libldap2-dev libsasl2-dev libssl-dev libyaml-dev ldap-utils
130130
- name: Install virtualenv
131131
run: |
132132
# Note: Use the verison of virtualenv pinned in fixed-requirements.txt so we

CHANGELOG.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ Changed
4040
* Import ABC from collections.abc for Python 3.10 compatibility. (#5007)
4141
Contributed by @tirkarthi
4242

43+
* Updated to use virtualenv 20.4.0/PIP20.3.3 and fixate-requirements to work with PIP 20.3.3 #512
44+
Contributed by Amanda McGuinness (@amanda11 Ammeon Solutions)
45+
4346
3.4.0 - March 02, 2021
4447
----------------------
4548

Makefile

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ REQUIREMENTS := test-requirements.txt requirements.txt
5555

5656
# Pin common pip version here across all the targets
5757
# Note! Periodic maintenance pip upgrades are required to be up-to-date with the latest pip security fixes and updates
58-
PIP_VERSION ?= 20.0.2
58+
PIP_VERSION ?= 20.3.3
59+
SETUPTOOLS_VERSION ?= 51.3.3
5960
PIP_OPTIONS := $(ST2_PIP_OPTIONS)
6061

6162
ifndef PYLINT_CONCURRENCY
@@ -461,11 +462,8 @@ flake8: requirements .flake8
461462
touch $(VIRTUALENV_ST2CLIENT_DIR)/bin/activate
462463
chmod +x $(VIRTUALENV_ST2CLIENT_DIR)/bin/activate
463464

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

470468
$(VIRTUALENV_ST2CLIENT_DIR)/bin/activate; cd st2client ; ../$(VIRTUALENV_ST2CLIENT_DIR)/bin/python setup.py install ; cd ..
471469
$(VIRTUALENV_ST2CLIENT_DIR)/bin/st2 --version
@@ -611,9 +609,7 @@ requirements: virtualenv .requirements .sdist-requirements install-runners insta
611609
# only have to update it one place when we change the version
612610
$(VIRTUALENV_DIR)/bin/pip install --upgrade $(shell grep "^virtualenv" fixed-requirements.txt)
613611

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

619615
# Fix for Travis CI race

fixed-requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ six==1.13.0
4646
sseclient-py==1.7
4747
stevedore==1.30.1
4848
tooz==2.8.0
49-
# Note: virtualenv embeds the pip wheel, so pinning virtualenv also pins pip
50-
# virtualenv==20.0.18 has pip==20.0.2
51-
virtualenv==20.0.18
49+
# Note: virtualenv embeds wheels for pip, wheel, and setuptools. So pinning virtualenv pins those as well.
50+
# virtualenv==20.4.0 (<21) has pip==20.3.3 wheel==0.36.2 setuptools==51.3.3
51+
virtualenv==20.4.0
5252
webob==1.8.5
5353
zake==0.2.2
5454
# test requirements below

requirements.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ argcomplete
1212
bcrypt==3.1.7
1313
chardet<3.1.0
1414
cryptography==3.3.2
15-
dnspython<2.0.0,>=1.16.0
15+
dnspython>=1.16.0,<2.0.0
1616
eventlet==0.25.1
1717
flex==6.14.0
1818
git+https://github.com/StackStorm/logshipper.git@stackstorm_patched#egg=logshipper
@@ -23,7 +23,6 @@ git+https://github.com/StackStorm/st2-rbac-backend.git@master#egg=st2-rbac-backe
2323
gitpython==2.1.15
2424
greenlet==0.4.15
2525
gunicorn==19.9.0
26-
ipaddr
2726
jinja2==2.10.3
2827
jsonpath-rw==1.4.0
2928
jsonschema==2.6.0
@@ -37,14 +36,14 @@ nose
3736
nose-parallel==0.3.1
3837
nose-timer==0.7.5
3938
orjson==3.5.0
40-
oslo.config<1.13,>=1.12.1
39+
oslo.config>=1.12.1,<1.13
4140
oslo.utils<5.0,>=4.0.0
4241
paramiko==2.7.1
4342
passlib==1.7.1
4443
prettytable
4544
prompt-toolkit==1.0.15
4645
psutil==5.6.6
47-
pyinotify==0.9.6 ; platform_system == "Linux"
46+
pyinotify==0.9.6; platform_system=="Linux"
4847
pymongo==3.10.0
4948
pyrabbit
5049
python-dateutil==2.8.0
@@ -69,4 +68,4 @@ unittest2
6968
webob==1.8.5
7069
webtest
7170
zake==0.2.2
72-
zipp<=1.0.0,>=0.5
71+
zipp>=0.5,<=1.0.0

scripts/fixate-requirements.py

Lines changed: 66 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@
7070
print("Using pip: %s" % (str(pip_version)))
7171
sys.exit(1)
7272

73+
try:
74+
from pip._internal.req.constructors import parse_req_from_line
75+
except ImportError:
76+
# Do not error, as will only use on pip >= 20
77+
pass
78+
7379

7480
def parse_args():
7581
parser = argparse.ArgumentParser(
@@ -138,19 +144,34 @@ def merge_source_requirements(sources):
138144
merged_requirements = []
139145
for infile_path in (locate_file(p, must_exist=True) for p in sources):
140146
for req in load_requirements(infile_path):
141-
# Requirements starting with project name "project ..."
142-
if req.req:
143-
# Skip already added project name
144-
if req.name in projects:
145-
continue
146-
projects.add(req.name)
147-
merged_requirements.append(req)
148-
149-
# Requirements lines like "vcs+proto://url"
150-
elif req.link:
151-
merged_requirements.append(req)
147+
if hasattr(req, "requirement"):
148+
# Requirements starting with project name "project ..."
149+
parsedreq = parse_req_from_line(req.requirement, req.line_source)
150+
if parsedreq.requirement:
151+
# Skip already added project name
152+
if parsedreq.requirement.name in projects:
153+
continue
154+
projects.add(parsedreq.requirement.name)
155+
merged_requirements.append(req)
156+
157+
# Requirements lines like "vcs+proto://url"
158+
elif parsedreq.link:
159+
merged_requirements.append(req)
160+
else:
161+
raise RuntimeError("Unexpected requirement {0}".format(req))
152162
else:
153-
raise RuntimeError("Unexpected requirement {0}".format(req))
163+
if req.req:
164+
# Skip already added project name
165+
if req.name in projects:
166+
continue
167+
projects.add(req.name)
168+
merged_requirements.append(req)
169+
170+
# Requirements lines like "vcs+proto://url"
171+
elif req.link:
172+
merged_requirements.append(req)
173+
else:
174+
raise RuntimeError("Unexpected requirement {0}".format(req))
154175

155176
return merged_requirements
156177

@@ -169,10 +190,17 @@ def write_requirements(
169190
# Make sure there are no duplicate / conflicting definitions
170191
fixedreq_hash = {}
171192
for req in fixed:
172-
project_name = req.name
193+
if hasattr(req, "requirement"):
194+
parsedreq = parse_req_from_line(req.requirement, req.line_source)
195+
project_name = parsedreq.requirement.name
173196

174-
if not req.req:
175-
continue
197+
if not req.requirement:
198+
continue
199+
else:
200+
project_name = req.name
201+
202+
if not req.req:
203+
continue
176204

177205
if project_name in fixedreq_hash:
178206
raise ValueError(
@@ -184,22 +212,38 @@ def write_requirements(
184212
lines_to_write = []
185213
links = set()
186214
for req in requirements:
187-
if req.name in skip:
215+
if hasattr(req, "requirement"):
216+
parsedreq = parse_req_from_line(req.requirement, req.line_source)
217+
project_name = parsedreq.requirement.name
218+
linkreq = parsedreq
219+
else:
220+
project_name = req.name
221+
linkreq = req
222+
if project_name in skip:
188223
continue
189224

190225
# we don't have any idea how to process links, so just add them
191-
if req.link and req.link not in links:
192-
links.add(req.link)
193-
rline = str(req.link)
226+
if linkreq.link and linkreq.link not in links:
227+
links.add(linkreq.link)
228+
rline = str(linkreq.link)
194229

195-
if req.editable:
230+
if (hasattr(req, "is_editable") and req.is_editable) or (
231+
hasattr(req, "editable") and req.editable
232+
):
196233
rline = "-e %s" % (rline)
197-
elif req.req:
234+
elif hasattr(req, "requirement") and req.requirement:
235+
project = parsedreq.requirement.name
236+
req_obj = fixedreq_hash.get(project, req)
237+
238+
rline = str(req_obj.requirement)
239+
240+
# Markers are included in req_obj.requirement, so no
241+
# special processing required
242+
elif hasattr(req, "req") and req.req:
198243
project = req.name
199244
req_obj = fixedreq_hash.get(project, req)
200245

201246
rline = str(req_obj.req)
202-
203247
# Also write out environment markers
204248
if req_obj.markers:
205249
rline += " ; {}".format(str(req_obj.markers))

st2actions/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ gitpython==2.1.15
1313
jinja2==2.10.3
1414
kombu==4.6.6
1515
lockfile==0.12.2
16-
oslo.config<1.13,>=1.12.1
16+
oslo.config>=1.12.1,<1.13
1717
oslo.utils<5.0,>=4.0.0
18-
pyinotify==0.9.6 ; platform_system == "Linux"
18+
pyinotify==0.9.6; platform_system=="Linux"
1919
python-dateutil==2.8.0
2020
python-json-logger
2121
pyyaml==5.1.2

st2api/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ gunicorn==19.9.0
1010
jsonschema==2.6.0
1111
kombu==4.6.6
1212
mongoengine==0.18.2
13-
oslo.config<1.13,>=1.12.1
13+
oslo.config>=1.12.1,<1.13
1414
oslo.utils<5.0,>=4.0.0
1515
pymongo==3.10.0
1616
simplejson

st2auth/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ eventlet==0.25.1
1010
git+https://github.com/StackStorm/st2-auth-backend-flat-file.git@master#egg=st2-auth-backend-flat-file
1111
git+https://github.com/StackStorm/st2-auth-ldap.git@master#egg=st2-auth-ldap
1212
gunicorn==19.9.0
13-
oslo.config<1.13,>=1.12.1
13+
oslo.config>=1.12.1,<1.13
1414
passlib==1.7.1
1515
pymongo==3.10.0
1616
six==1.13.0

st2client/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ pyyaml==5.1.2
2020
requests[security]==2.23.0
2121
six==1.13.0
2222
sseclient-py==1.7
23-
zipp<=1.0.0,>=0.5
23+
zipp>=0.5,<=1.0.0

0 commit comments

Comments
 (0)