Skip to content

Commit 47261c7

Browse files
committed
Update makefile to generate requirements.
1 parent 62f5625 commit 47261c7

File tree

3 files changed

+23
-71
lines changed

3 files changed

+23
-71
lines changed

Makefile

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ space_char +=
1414
comma := ,
1515
COMPONENT_PYTHONPATH = $(subst $(space_char),:,$(realpath $(COMPONENTS)))
1616

17-
PYTHON_TARGET := 3.10
18-
19-
REQUIREMENTS := test-requirements.txt requirements.txt
17+
PYTHON_VERSION := $(shell python3 --version | sed -r 's/.*([[0-9]+\.[0-9]+)\.[0-9]+.*/\1/g')
18+
REQUIREMENTS := test-requirements-$(PYTHON_VERSION).txt requirements.txt
2019
# Grab the version of pip from the Makefile in the st2 repository
2120
#
2221
# 1. Grab the st2 branch name from ST2_BRANCH
@@ -73,7 +72,7 @@ pylint: requirements .pylint
7372
. $(VIRTUALENV_DIR)/bin/activate; pylint -E --rcfile=./lint-configs/python/.pylintrc packs/fixtures/actions/scripts/*/*.py || exit 1;
7473
. $(VIRTUALENV_DIR)/bin/activate; pylint -E --rcfile=./lint-configs/python/.pylintrc packs/fixtures/sensors/*.py || exit 1;
7574
. $(VIRTUALENV_DIR)/bin/activate; pylint -E --rcfile=./lint-configs/python/.pylintrc packs/asserts/actions/*.py || exit 1;
76-
75+
7776
.PHONY: flake8
7877
flake8: requirements .flake8
7978

@@ -140,3 +139,17 @@ $(VIRTUALENV_DIR)/bin/activate:
140139
echo ' functions -e old_deactivate' >> $(VIRTUALENV_DIR)/bin/activate.fish
141140
echo 'end' >> $(VIRTUALENV_DIR)/bin/activate.fish
142141
touch $(VIRTUALENV_DIR)/bin/activate.fish
142+
143+
.PHONY: piptools
144+
piptools: virtualenv
145+
@echo
146+
@echo "================== Install pip-tools ===================="
147+
@echo
148+
"$(VIRTUALENV_DIR)/bin/pip" install pip-tools
149+
150+
.PHONY: generate_requirements
151+
generate_requirements: piptools
152+
@echo
153+
@echo "================== Generate requirements file ===================="
154+
@echo
155+
"$(VIRTUALENV_DIR)/bin/pip-compile" --output-file=$(ROOT_DIR)/test-requirements-$(PYTHON_VERSION).txt $(ROOT_DIR)/test-requirements.in

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,9 @@ For example:
3636
git subtree pull --prefix test_helpers/bats-assert https://github.com/ztombol/bats-assert.git master --squash
3737
git subtree pull --prefix test_helpers/bats-support https://github.com/ztombol/bats-support.git master --squash
3838
```
39+
40+
## Supported Python versions
41+
42+
StackStorm supports mulitple versions of python across numerous GNU/Linux distributions. To define python dependencies in a
43+
reproducible fashion, the `pip-compile` tool is used to resolve dependencies from the `requirements.in` file. The requirements
44+
are kept up to date with the `st2` repository and should be regenerated when requirements are updated.

test-requirements.txt

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
 (0)