15
15
VIRTUALENV_COMPONENTS_DIR ?= virtualenv-components
16
16
endif
17
17
18
- PYTHON_VERSION ?= python2.7
18
+ PYTHON_VERSION ?= $( shell if [ -z "`which python3.6`" ]; then echo " python2.7"; else echo "python3.6"; fi)
19
19
20
20
BINARIES := bin
21
21
@@ -50,7 +50,12 @@ COMPONENTS_TEST_MODULES_COMMA := $(subst $(space_char),$(comma),$(COMPONENTS_TES
50
50
COVERAGE_GLOBS := .coverage.unit.* .coverage.integration.*
51
51
COVERAGE_GLOBS_QUOTED := $(foreach glob,$(COVERAGE_GLOBS ) ,'$(glob ) ')
52
52
53
- REQUIREMENTS := test-requirements.txt requirements.txt
53
+ ifeq ($(PYTHON_VERSION ) ,python2.7)
54
+ REQUIREMENTS := test-requirements-py27.txt requirements.txt
55
+ else
56
+ REQUIREMENTS := test-requirements.txt requirements.txt
57
+ endif
58
+
54
59
# Pin common pip version here across all the targets
55
60
# Note! Periodic maintenance pip upgrades are required to be up-to-date with the latest pip security fixes and updates
56
61
PIP_VERSION ?= 20.0.2
@@ -107,6 +112,8 @@ all: requirements configgen check tests
107
112
# Target for debugging Makefile variable assembly
108
113
.PHONY : play
109
114
play :
115
+ @echo PYTHON_VERSION=$(PYTHON_VERSION )
116
+ @echo
110
117
@echo COVERAGE_GLOBS=$(COVERAGE_GLOBS_QUOTED )
111
118
@echo
112
119
@echo COMPONENTS=$(COMPONENTS )
@@ -226,8 +233,7 @@ check-python-packages:
226
233
@echo " "
227
234
@echo " ================== CHECK PYTHON PACKAGES ===================="
228
235
@echo " "
229
-
230
- test -f $(VIRTUALENV_COMPONENTS_DIR)/bin/activate || virtualenv --python=$(PYTHON_VERSION) $(VIRTUALENV_COMPONENTS_DIR) --no-download
236
+ test -f $(VIRTUALENV_COMPONENTS_DIR ) /bin/activate || virtualenv --python=$(PYTHON_VERSION ) $(VIRTUALENV_COMPONENTS_DIR ) --no-download --system-site-packages
231
237
@for component in $(COMPONENTS_WITHOUT_ST2TESTS ) ; do \
232
238
echo " ===========================================================" ; \
233
239
echo " Checking component:" $$ component; \
@@ -263,7 +269,7 @@ checklogs:
263
269
@echo
264
270
@echo " ================== LOG WATCHER ===================="
265
271
@echo
266
- . $(VIRTUALENV_DIR ) /bin/activate; ./tools/log_watcher.py 10
272
+ . $(VIRTUALENV_DIR ) /bin/activate; python ./tools/log_watcher.py 10
267
273
268
274
.PHONY : pylint
269
275
pylint : requirements .pylint
@@ -329,7 +335,7 @@ lint-api-spec: requirements .lint-api-spec
329
335
@echo
330
336
@echo " ================== Lint API spec ===================="
331
337
@echo
332
- . $(VIRTUALENV_DIR ) /bin/activate; st2common/bin/st2-validate-api-spec --config-file conf/st2.dev.conf
338
+ . $(VIRTUALENV_DIR ) /bin/activate; python st2common/bin/st2-validate-api-spec --config-file conf/st2.dev.conf
333
339
334
340
.PHONY : generate-api-spec
335
341
generate-api-spec : requirements .generate-api-spec
@@ -343,14 +349,14 @@ generate-api-spec: requirements .generate-api-spec
343
349
echo " # Edit st2common/st2common/openapi.yaml.j2 and then run" >> st2common/st2common/openapi.yaml
344
350
echo " # make .generate-api-spec" >> st2common/st2common/openapi.yaml
345
351
echo " # to generate the final spec file" >> st2common/st2common/openapi.yaml
346
- . $(VIRTUALENV_DIR ) /bin/activate; st2common/bin/st2-generate-api-spec --config-file conf/st2.dev.conf >> st2common/st2common/openapi.yaml
352
+ . $(VIRTUALENV_DIR ) /bin/activate; python st2common/bin/st2-generate-api-spec --config-file conf/st2.dev.conf >> st2common/st2common/openapi.yaml
347
353
348
354
.PHONY : circle-lint-api-spec
349
355
circle-lint-api-spec :
350
356
@echo
351
357
@echo " ================== Lint API spec ===================="
352
358
@echo
353
- . $(VIRTUALENV_DIR ) /bin/activate; st2common/bin/st2-validate-api-spec --config-file conf/st2.dev.conf || echo " Open API spec lint failed."
359
+ . $(VIRTUALENV_DIR ) /bin/activate; python st2common/bin/st2-validate-api-spec --config-file conf/st2.dev.conf || echo " Open API spec lint failed."
354
360
355
361
.PHONY : flake8
356
362
flake8 : requirements .flake8
@@ -375,7 +381,7 @@ flake8: requirements .flake8
375
381
@echo
376
382
@echo " ==================== st2client install check ===================="
377
383
@echo
378
- test -f $(VIRTUALENV_ST2CLIENT_DIR ) /bin/activate || virtualenv --python=$(PYTHON_VERSION ) $(VIRTUALENV_ST2CLIENT_DIR ) --no-download
384
+ test -f $(VIRTUALENV_ST2CLIENT_DIR ) /bin/activate || virtualenv --python=$(PYTHON_VERSION ) $(VIRTUALENV_ST2CLIENT_DIR ) --no-download --system-site-packages
379
385
380
386
# Setup PYTHONPATH in bash activate script...
381
387
# Delete existing entries (if any)
@@ -389,11 +395,12 @@ flake8: requirements .flake8
389
395
touch $(VIRTUALENV_ST2CLIENT_DIR)/bin/activate
390
396
chmod +x $(VIRTUALENV_ST2CLIENT_DIR)/bin/activate
391
397
392
- $(VIRTUALENV_ST2CLIENT_DIR)/bin/pip install --upgrade "pip==$(PIP_VERSION)"
393
398
# NOTE We need to upgrade setuptools to avoid bug with dependency resolving in old versions
394
399
# Setuptools 42 added support for python_requires, which is used by the configparser package,
395
400
# which is required by the importlib-metadata package
401
+ $(VIRTUALENV_ST2CLIENT_DIR)/bin/pip install --upgrade "pip==$(PIP_VERSION)"
396
402
$(VIRTUALENV_ST2CLIENT_DIR)/bin/pip install --upgrade "setuptools==44.1.0"
403
+
397
404
$(VIRTUALENV_ST2CLIENT_DIR)/bin/activate; cd st2client ; ../$(VIRTUALENV_ST2CLIENT_DIR)/bin/python setup.py install ; cd ..
398
405
$(VIRTUALENV_ST2CLIENT_DIR)/bin/st2 --version
399
406
$(VIRTUALENV_ST2CLIENT_DIR)/bin/python -c "import st2client"
@@ -541,10 +548,9 @@ requirements: virtualenv .requirements .sdist-requirements install-runners insta
541
548
fi
542
549
543
550
# Install requirements
544
- #
545
551
for req in $(REQUIREMENTS); do \
546
- echo "Installing $$req..." ; \
547
- $(VIRTUALENV_DIR)/bin/pip install $(PIP_OPTIONS) -r $$req ; \
552
+ echo "Installing $$req..." ; \
553
+ $(VIRTUALENV_DIR)/bin/pip install $(PIP_OPTIONS) -r $$req ; \
548
554
done
549
555
550
556
# Install st2common package to load drivers defined in st2common setup.py
@@ -626,7 +632,7 @@ endif
626
632
tests : pytests
627
633
628
634
.PHONY : pytests
629
- pytests : compile requirements .flake8 .pylint .pytests-coverage
635
+ pytests : compilepy3 requirements .flake8 .pylint .pytests-coverage
630
636
631
637
.PHONY : .pytests
632
638
.pytests : compile .configgen .generate-api-spec .unit-tests clean
@@ -963,7 +969,7 @@ debs:
963
969
ci : ci-checks ci-unit ci-integration ci-packs-tests
964
970
965
971
.PHONY : ci-checks
966
- ci-checks : compile .generated-files-check .pylint .flake8 check-requirements check-sdist-requirements .st2client-dependencies-check .st2common-circular-dependencies-check circle-lint-api-spec .rst-check .st2client-install-check check-python-packages
972
+ ci-checks : compilepy3 .generated-files-check .pylint .flake8 check-requirements check-sdist-requirements .st2client-dependencies-check .st2common-circular-dependencies-check circle-lint-api-spec .rst-check .st2client-install-check check-python-packages
967
973
968
974
.PHONY : ci-py3-unit
969
975
ci-py3-unit :
0 commit comments