@@ -7,23 +7,36 @@ that) you can just run them in docker using containers.
77
88# Setup
99
10- To build a container say for Python 3.11 change to the root directory of the
10+ To build a container say for Python 3.11, change to the root directory of the
1111project and run:
1212
1313``` bash
14- docker build -t pactfoundation:python311 -f docker/py311. Dockerfile .
14+ (export PY=3.11 && docker build --build-arg PY= " $PY " --build-arg TOXPY= " $( sed ' s/\.// ' <<< " $PY " ) " - t pactfoundation:python ${PY} -f docker/Dockerfile .)
1515```
1616
17- To then run the tests and exit, you will need:
17+ This uses an Alpine based image (currently 3.17), which is available as of
18+ 2023-04 for Python versions 3.7 - 3.11.
19+
20+ Note: To run tox, the Python version without the '.' is required, i.e. '311'
21+ instead of '3.11', so some manipulation with ` sed ` is used to remove the '.'
22+
23+ To build for Python versions which require a different Alpine image, such as if
24+ trying to build against Python 3.6, an extra ` ALPINE ` arg can be provided:
25+
26+ ``` bash
27+ (export PY=3.6 && docker build --build-arg PY=" $PY " --build-arg TOXPY=" $( sed ' s/\.//' <<< " $PY" ) " --build-arg ALPINE=3.15 -t pactfoundation:python${PY} -f docker/Dockerfile .)
28+ ```
29+
30+ To then run the tests and exit:
1831
1932``` bash
20- docker run -it --rm -v " $( pwd) " :/home pactfoundation:python311
33+ docker run -it --rm -v " $( pwd) " :/home pactfoundation:python3.11
2134```
2235
2336If you need to debug you can change the command to:
2437
2538``` bash
26- docker run -it --rm -v " $( pwd) " :/home pactfoundation:python311 sh
39+ docker run -it --rm -v " $( pwd) " :/home pactfoundation:python3.11 sh
2740```
2841
2942This will open a container with a prompt. From the ` /home ` location in the
@@ -34,11 +47,11 @@ tox -e py311-{test,install}
3447```
3548
3649In all the above if you need to run a different version change
37- ` py311 ` /` python311 ` where appropriate. Or you can run the convenience script
50+ ` py311 ` /` python3.11 ` where appropriate. Or you can run the convenience script
3851to build:
3952
4053``` bash
41- docker/build.sh 311
54+ docker/build.sh 3.11
4255```
4356
44- where ` 311 ` is the python environment version (3.11 in this case) .
57+ where ` 3.11 ` is the python environment version.
0 commit comments