Skip to content

Commit 91f54d5

Browse files
committed
Add meta package for backwards compatibility.
1 parent 159e95d commit 91f54d5

File tree

14 files changed

+189
-128
lines changed

14 files changed

+189
-128
lines changed

.github/workflows/docs.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: testcontainers documentation
2+
on:
3+
push:
4+
branches: [master]
5+
pull_request:
6+
branches: [master]
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Setup python 3.10
14+
uses: actions/setup-python@v2
15+
with:
16+
python-version: "3.10"
17+
- name: Cache Python dependencies
18+
uses: actions/cache@v2
19+
with:
20+
path: ~/.cache/pip
21+
key: ${{ runner.os }}-pip-${{ hashFiles('requirements/3.10.txt') }}
22+
restore-keys: |
23+
${{ runner.os }}-pip-
24+
${{ runner.os }}-
25+
- name: Install Python dependencies
26+
run: |
27+
pip install --upgrade pip
28+
pip install -r requirements/3.10.txt
29+
- name: Build documentation
30+
run: make docs
31+
- name: Run doctests
32+
run: make doctests

.github/workflows/main.yml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: testcontainers-python
1+
name: testcontainers packages
22
on:
33
push:
44
branches: [master]
@@ -52,6 +52,7 @@ jobs:
5252
- kafka
5353
- keycloak
5454
- localstack
55+
- meta
5556
- minio
5657
- mongodb
5758
- mssql
@@ -81,10 +82,10 @@ jobs:
8182
${{ runner.os }}-
8283
- name: Install Python dependencies
8384
run: |
84-
python -m pip install --upgrade pip
85-
pip install wheel
85+
pip install --upgrade pip
8686
pip install -r requirements/${{ matrix.python-version }}.txt
8787
- name: Run docker diagnostics
88+
if: matrix.test-component == 'core'
8889
run: |
8990
echo "Build minimal container for docker-in-docker diagnostics"
9091
docker build -f Dockerfile.diagnostics -t testcontainers-python .
@@ -95,16 +96,12 @@ jobs:
9596
echo "Container diagnostics with host network"
9697
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock --network=host testcontainers-python python diagnostics.py
9798
- name: Lint the code
98-
run: flake8
99+
run: make ${{ matrix.test-component }}/lint
99100
- name: Run tests
100-
run: >
101-
pytest -svx --cov-report=term-missing --cov=testcontainers.${{ matrix.test-component }}
102-
--tb=short ${{ matrix.test-component }}/tests
101+
if: matrix.test-component != 'meta'
102+
run: make ${{ matrix.test-component }}/tests
103103
- name: Build the package
104-
working-directory: ${{ matrix.test-component }}
105-
run: |
106-
python setup.py bdist_wheel
107-
twine check dist/*
104+
run: make ${{ matrix.test-component }}/dist
108105
- name: Publish the package to pypi
109106
if: >
110107
github.event_name == 'push'
@@ -114,4 +111,5 @@ jobs:
114111
env:
115112
TWINE_USERNAME: __token__
116113
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
117-
run: twine upload ${{ matrix.test-component }}/dist/*
114+
TWINE_REPOSITORY: pypi
115+
run: make ${{ matrix.test-component }}/publish

Makefile

Lines changed: 51 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,66 @@
11
PYTHON_VERSIONS = 3.7 3.8 3.9 3.10
2+
PYTHON_VERSION ?= 3.10
3+
IMAGE = testcontainers-python:${PYTHON_VERSION}
24
REQUIREMENTS = $(addprefix requirements/,${PYTHON_VERSIONS:=.txt})
3-
TESTS = $(addprefix tests/,${PYTHON_VERSIONS})
4-
IMAGES = $(addprefix image/,${PYTHON_VERSIONS})
55
RUN = docker run --rm -it
6+
TWINE_REPOSITORY ?= testpypi
7+
# Get all directories that contain a setup.py and get the directory name.
8+
PACKAGES = $(subst /,,$(dir $(wildcard */setup.py)))
9+
10+
# All */dist folders for each of the packages.
11+
DISTRIBUTIONS = $(addsuffix /dist,${PACKAGES})
12+
UPLOAD = $(addsuffix /upload,${PACKAGES})
13+
# All */tests folders for each of the test suites.
14+
TESTS = $(addsuffix /tests,$(filter-out meta,${PACKAGES}))
15+
TESTS_DIND = $(addsuffix -dind,${TESTS})
16+
# All linting targets.
17+
LINT = $(addsuffix /lint,${PACKAGES})
18+
19+
# Targets to build a distribution for each package.
20+
dist: ${DISTRIBUTIONS}
21+
${DISTRIBUTIONS} : %/dist : %/setup.py
22+
cd $* \
23+
&& python setup.py bdist_wheel \
24+
&& twine check dist/*
25+
26+
# Targets to run the test suite for each package.
27+
tests : ${TESTS}
28+
${TESTS} : %/tests :
29+
pytest -svx --cov-report=term-missing --cov=testcontainers.$* --tb=short $*/tests
630

7-
.PHONY : docs
31+
# Targets to lint the code.
32+
lint : ${LINT}
33+
${LINT} : %/lint :
34+
flake8 $*
835

9-
# Default target
36+
# Targets to publish packages.
37+
${UPLOAD} : %/upload :
38+
twine upload --non-interactive --repository=${TWINE_REPOSITORY} --skip-existing $*/dist/*
1039

11-
default : tests/3.8
40+
# Targets to build docker images
41+
image: requirements/${PYTHON_VERSION}.txt
42+
docker build --build-arg version=${PYTHON_VERSION} -t ${IMAGE} .
1243

44+
# Targets to run tests in docker containers
45+
tests-dind : ${TESTS_DIND}
1346

14-
# Targets to build requirement files
47+
${TESTS_DIND} : %/tests-dind : image
48+
${RUN} -v /var/run/docker.sock:/var/run/docker.sock ${IMAGE} \
49+
bash -c "make $*/lint $*/tests"
1550

16-
requirements : ${REQUIREMENTS}
51+
# Target to build the documentation
52+
docs :
53+
sphinx-build -nW . docs/_build
54+
55+
doctests :
56+
sphinx-build -b doctest . docs/_build
1757

58+
# Targets to build requirement files
59+
requirements : ${REQUIREMENTS}
1860
${REQUIREMENTS} : requirements/%.txt : requirements.in */setup.py
1961
mkdir -p $(dir $@)
2062
${RUN} -w /workspace -v `pwd`:/workspace --platform=linux/amd64 python:$* bash -c \
2163
"pip install pip-tools && pip-compile --resolver=backtracking -v --upgrade -o $@ $<"
2264

23-
24-
# Targets to build docker images
25-
26-
images : ${IMAGES}
27-
28-
${IMAGES} : image/% : requirements/%.txt
29-
docker build --build-arg version=$* -t testcontainers-python:$* .
30-
31-
32-
# Targets to run tests in docker containers
33-
34-
tests : ${TESTS}
35-
36-
${TESTS} : tests/% : image/%
37-
${RUN} -v /var/run/docker.sock:/var/run/docker.sock testcontainers-python:$* \
38-
bash -c "flake8 && pytest -v ${ARGS}"
39-
40-
# Target to build the documentation
41-
42-
docs :
43-
sphinx-build -nW . docs/_build
65+
# Targets that do not generate file-level artifacts.
66+
.PHONY : dists ${DISTRIBUTIONS} docs doctests image tests ${TESTS}

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Installation
5858

5959
The suite of testcontainers packages is available on `PyPI <https://pypi.org/project/testcontainers/>`_, and individual packages can be installed using :code:`pip`. We recommend installing the package you need by running :code:`pip install testcontainers-<feature>`, e.g., :code:`pip install testcontainers-mysql`.
6060

61-
For backwards compatibility, packages can also be installed by specifying `extras <https://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-extras-optional-features-with-their-own-dependencies>`_, e.g., :code:`pip install testcontainers[mysql]`.
61+
For backwards compatibility, packages can also be installed by specifying `extras <https://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-extras-optional-features-with-their-own-dependencies>`__, e.g., :code:`pip install testcontainers[mysql]`.
6262

6363

6464
Usage within Docker (e.g., in a CI)

conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
# List of patterns, relative to source directory, that match files and
7777
# directories to ignore when looking for source files.
7878
# This patterns also effect to html_static_path and html_extra_path
79-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
79+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', "meta/README.rst"]
8080

8181
# The name of the Pygments (syntax highlighting) style to use.
8282
pygments_style = 'sphinx'

generate_version.py

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

meta/README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The :code:`testcontainers` meta package facilitates the installation of the collection of namespace packages that make up the testcontainers ecosystem for python. It follows `Jupyter's approach <https://github.com/jupyter/jupyter/blob/master/setup.py>`__ of installing a collection of packages.

meta/setup.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#
2+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
3+
# not use this file except in compliance with the License. You may obtain
4+
# a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11+
# License for the specific language governing permissions and limitations
12+
# under the License.
13+
14+
import setuptools
15+
16+
description = "Python interface for throwaway instances of anything that can run in a Docker " \
17+
"container."
18+
long_description = f"{description} See https://testcontainers-python.readthedocs.io/en/latest/ " \
19+
"for details."
20+
21+
setuptools.setup(
22+
name="testcontainers",
23+
version="4.0.0rc1",
24+
description=description,
25+
long_description=long_description,
26+
long_description_content_type="text/x-rst",
27+
author="Sergey Pirogov",
28+
author_email="[email protected]",
29+
url="https://github.com/testcontainers/testcontainers-python",
30+
keywords=["testing", "logging", "docker", "test automation"],
31+
classifiers=[
32+
"License :: OSI Approved :: Apache Software License",
33+
"Intended Audience :: Information Technology",
34+
"Intended Audience :: Developers",
35+
"Programming Language :: Python :: 3",
36+
"Programming Language :: Python :: 3.7",
37+
"Programming Language :: Python :: 3.8",
38+
"Programming Language :: Python :: 3.9",
39+
"Programming Language :: Python :: 3.10",
40+
"Topic :: Software Development :: Libraries :: Python Modules",
41+
"Operating System :: Microsoft :: Windows",
42+
"Operating System :: POSIX",
43+
"Operating System :: Unix",
44+
"Operating System :: MacOS",
45+
],
46+
install_requires=[
47+
"testcontainers-core",
48+
],
49+
extras_require={
50+
"arangodb": ["testcontainers-arangodb"],
51+
"azurite": ["testcontainers-azurite"],
52+
"clickhouse": ["testcontainers-clickhouse"],
53+
"docker-compose": ["testcontainers-compose"],
54+
"google-cloud-pubsub": ["testcontainers-gcp"],
55+
"kafka": ["testcontainers-kafka"],
56+
"keycloak": ["testcontainers-keycloak"],
57+
"minio": ["testcontainers-minio"],
58+
"mongo": ["testcontainers-mongo"],
59+
"mssqlserver": ["testcontainers-mssql"],
60+
"mysql": ["testcontainers-mysql"],
61+
"neo4j": ["testcontainers-neo4j"],
62+
"opensearch": ["testcontainers-opensearch"],
63+
"oracle": ["testcontainers-oracle"],
64+
"postgresql": ["testcontainers-postgres"],
65+
"rabbitmq": ["testcontainers-rabbitmq"],
66+
"redis": ["testcontainers-redis"],
67+
"selenium": ["testcontainers-selenium"],
68+
},
69+
python_requires=">=3.7",
70+
)

requirements.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
-e file:core
21
-e file:arangodb
32
-e file:azurite
43
-e file:clickhouse
4+
-e file:core
55
-e file:compose
66
-e file:elasticsearch
77
-e file:google
88
-e file:kafka
99
-e file:keycloak
1010
-e file:localstack
11+
-e file:meta
1112
-e file:minio
1213
-e file:mongodb
1314
-e file:mssql
@@ -28,3 +29,4 @@ pytest
2829
pytest-cov
2930
sphinx
3031
twine
32+
wheel

requirements/3.10.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#
55
# pip-compile --output-file=requirements/3.10.txt --resolver=backtracking requirements.in
66
#
7+
-e file:meta
8+
# via -r requirements.in
79
-e file:arangodb
810
# via -r requirements.in
911
-e file:azurite
@@ -15,6 +17,7 @@
1517
-e file:core
1618
# via
1719
# -r requirements.in
20+
# testcontainers
1821
# testcontainers-arangodb
1922
# testcontainers-azurite
2023
# testcontainers-clickhouse
@@ -426,6 +429,8 @@ websocket-client==0.59.0
426429
# via
427430
# docker
428431
# docker-compose
432+
wheel==0.38.4
433+
# via -r requirements.in
429434
wrapt==1.14.1
430435
# via testcontainers-core
431436
wsproto==1.2.0

0 commit comments

Comments
 (0)