Skip to content

Commit 7de6560

Browse files
authored
Merge pull request #5039 from StackStorm/py3-dev-default
Refactor Makefile to use python3 by default for development
2 parents 323bb89 + ba747b7 commit 7de6560

File tree

57 files changed

+1015
-1009
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1015
-1009
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ jobs:
4444
python: 2.7
4545
env: TASK=ci-integration CACHE_NAME=py2 COMMAND_THRESHOLD=700
4646

47-
- name: "Lint Checks, Packs Tests (Python 2.7)"
48-
python: 2.7
49-
env: TASK="ci-checks ci-packs-tests" CACHE_NAME=py2 COMMAND_THRESHOLD=430
47+
- name: "Lint Checks, Packs Tests (Python 3.6)"
48+
python: 3.6
49+
env: TASK="ci-checks ci-packs-tests" CACHE_NAME=py3 COMMAND_THRESHOLD=430
5050

5151
- name: "Unit Tests, Pack Tests (Python 3.6)"
5252
python: 3.6

Makefile

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ else
1515
VIRTUALENV_COMPONENTS_DIR ?= virtualenv-components
1616
endif
1717

18-
PYTHON_VERSION ?= python2.7
18+
PYTHON_VERSION ?= $(shell if [ -z "`which python3.6`" ]; then which python2.7; else which python3.6; fi)
1919

2020
BINARIES := bin
2121

@@ -107,6 +107,8 @@ all: requirements configgen check tests
107107
# Target for debugging Makefile variable assembly
108108
.PHONY: play
109109
play:
110+
@echo PYTHON_VERSION=$(PYTHON_VERSION)
111+
@echo
110112
@echo COVERAGE_GLOBS=$(COVERAGE_GLOBS_QUOTED)
111113
@echo
112114
@echo COMPONENTS=$(COMPONENTS)
@@ -226,8 +228,7 @@ check-python-packages:
226228
@echo ""
227229
@echo "================== CHECK PYTHON PACKAGES ===================="
228230
@echo ""
229-
230-
test -f $(VIRTUALENV_COMPONENTS_DIR)/bin/activate || virtualenv --python=$(PYTHON_VERSION) $(VIRTUALENV_COMPONENTS_DIR) --no-download
231+
test -f $(VIRTUALENV_COMPONENTS_DIR)/bin/activate || virtualenv --python=$(PYTHON_VERSION) $(VIRTUALENV_COMPONENTS_DIR) --no-download --system-site-packages
231232
@for component in $(COMPONENTS_WITHOUT_ST2TESTS); do \
232233
echo "==========================================================="; \
233234
echo "Checking component:" $$component; \
@@ -263,7 +264,7 @@ checklogs:
263264
@echo
264265
@echo "================== LOG WATCHER ===================="
265266
@echo
266-
. $(VIRTUALENV_DIR)/bin/activate; ./tools/log_watcher.py 10
267+
. $(VIRTUALENV_DIR)/bin/activate; python ./tools/log_watcher.py 10
267268

268269
.PHONY: pylint
269270
pylint: requirements .pylint
@@ -329,7 +330,7 @@ lint-api-spec: requirements .lint-api-spec
329330
@echo
330331
@echo "================== Lint API spec ===================="
331332
@echo
332-
. $(VIRTUALENV_DIR)/bin/activate; st2common/bin/st2-validate-api-spec --config-file conf/st2.dev.conf
333+
. $(VIRTUALENV_DIR)/bin/activate; python st2common/bin/st2-validate-api-spec --config-file conf/st2.dev.conf
333334

334335
.PHONY: generate-api-spec
335336
generate-api-spec: requirements .generate-api-spec
@@ -343,14 +344,14 @@ generate-api-spec: requirements .generate-api-spec
343344
echo "# Edit st2common/st2common/openapi.yaml.j2 and then run" >> st2common/st2common/openapi.yaml
344345
echo "# make .generate-api-spec" >> st2common/st2common/openapi.yaml
345346
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
347+
. $(VIRTUALENV_DIR)/bin/activate; python st2common/bin/st2-generate-api-spec --config-file conf/st2.dev.conf >> st2common/st2common/openapi.yaml
347348

348349
.PHONY: circle-lint-api-spec
349350
circle-lint-api-spec:
350351
@echo
351352
@echo "================== Lint API spec ===================="
352353
@echo
353-
. $(VIRTUALENV_DIR)/bin/activate; st2common/bin/st2-validate-api-spec --config-file conf/st2.dev.conf || echo "Open API spec lint failed."
354+
. $(VIRTUALENV_DIR)/bin/activate; python st2common/bin/st2-validate-api-spec --config-file conf/st2.dev.conf || echo "Open API spec lint failed."
354355

355356
.PHONY: flake8
356357
flake8: requirements .flake8
@@ -375,7 +376,7 @@ flake8: requirements .flake8
375376
@echo
376377
@echo "==================== st2client install check ===================="
377378
@echo
378-
test -f $(VIRTUALENV_ST2CLIENT_DIR)/bin/activate || virtualenv --python=$(PYTHON_VERSION) $(VIRTUALENV_ST2CLIENT_DIR) --no-download
379+
test -f $(VIRTUALENV_ST2CLIENT_DIR)/bin/activate || virtualenv --python=$(PYTHON_VERSION) $(VIRTUALENV_ST2CLIENT_DIR) --no-download --system-site-packages
379380

380381
# Setup PYTHONPATH in bash activate script...
381382
# Delete existing entries (if any)
@@ -389,11 +390,12 @@ flake8: requirements .flake8
389390
touch $(VIRTUALENV_ST2CLIENT_DIR)/bin/activate
390391
chmod +x $(VIRTUALENV_ST2CLIENT_DIR)/bin/activate
391392

392-
$(VIRTUALENV_ST2CLIENT_DIR)/bin/pip install --upgrade "pip==$(PIP_VERSION)"
393393
# NOTE We need to upgrade setuptools to avoid bug with dependency resolving in old versions
394394
# Setuptools 42 added support for python_requires, which is used by the configparser package,
395395
# which is required by the importlib-metadata package
396+
$(VIRTUALENV_ST2CLIENT_DIR)/bin/pip install --upgrade "pip==$(PIP_VERSION)"
396397
$(VIRTUALENV_ST2CLIENT_DIR)/bin/pip install --upgrade "setuptools==44.1.0"
398+
397399
$(VIRTUALENV_ST2CLIENT_DIR)/bin/activate; cd st2client ; ../$(VIRTUALENV_ST2CLIENT_DIR)/bin/python setup.py install ; cd ..
398400
$(VIRTUALENV_ST2CLIENT_DIR)/bin/st2 --version
399401
$(VIRTUALENV_ST2CLIENT_DIR)/bin/python -c "import st2client"
@@ -626,7 +628,7 @@ endif
626628
tests: pytests
627629

628630
.PHONY: pytests
629-
pytests: compile requirements .flake8 .pylint .pytests-coverage
631+
pytests: compilepy3 requirements .flake8 .pylint .pytests-coverage
630632

631633
.PHONY: .pytests
632634
.pytests: compile .configgen .generate-api-spec .unit-tests clean
@@ -963,7 +965,7 @@ debs:
963965
ci: ci-checks ci-unit ci-integration ci-packs-tests
964966

965967
.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
968+
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
967969

968970
.PHONY: ci-py3-unit
969971
ci-py3-unit:

0 commit comments

Comments
 (0)