PYTHON-4483 Use hatch as task runner (#1728)
Co-authored-by: Noah Stapp <noah@noahstapp.com>
This commit is contained in:
parent
d0193eb045
commit
875688cecc
@ -365,7 +365,7 @@ functions:
|
||||
${PREPARE_SHELL}
|
||||
set -o xtrace
|
||||
export PYTHON_BINARY=${PYTHON_BINARY}
|
||||
bash ${PROJECT_DIRECTORY}/.evergreen/tox.sh -m test-mockupdb
|
||||
bash ${PROJECT_DIRECTORY}/.evergreen/hatch.sh test:test-mockupdb
|
||||
|
||||
"run doctests":
|
||||
- command: shell.exec
|
||||
@ -375,18 +375,19 @@ functions:
|
||||
script: |
|
||||
${PREPARE_SHELL}
|
||||
set -o xtrace
|
||||
PYTHON_BINARY=${PYTHON_BINARY} bash ${PROJECT_DIRECTORY}/.evergreen/tox.sh -m doc-test
|
||||
PYTHON_BINARY=${PYTHON_BINARY} bash ${PROJECT_DIRECTORY}/.evergreen/hatch.sh doctest:test
|
||||
|
||||
"run tests":
|
||||
- command: shell.exec
|
||||
params:
|
||||
working_dir: "src"
|
||||
shell: bash
|
||||
include_expansions_in_env: ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN"]
|
||||
background: true
|
||||
include_expansions_in_env: ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN"]
|
||||
script: |
|
||||
${PREPARE_SHELL}
|
||||
if [ -n "${test_encryption}" ]; then
|
||||
. .evergreen/tox.sh -m setup-encryption
|
||||
./.evergreen/hatch.sh encryption:setup
|
||||
fi
|
||||
- command: shell.exec
|
||||
type: test
|
||||
@ -407,6 +408,7 @@ functions:
|
||||
if [ -n "${test_encryption}" ]; then
|
||||
# Disable xtrace (just in case it was accidentally set).
|
||||
set +x
|
||||
bash ${DRIVERS_TOOLS}/.evergreen/csfle/await-servers.sh
|
||||
export TEST_ENCRYPTION=1
|
||||
if [ -n "${test_encryption_pyopenssl}" ]; then
|
||||
export TEST_ENCRYPTION_PYOPENSSL=1
|
||||
@ -446,7 +448,7 @@ functions:
|
||||
SSL=${SSL} \
|
||||
TEST_DATA_LAKE=${TEST_DATA_LAKE} \
|
||||
MONGODB_API_VERSION=${MONGODB_API_VERSION} \
|
||||
bash ${PROJECT_DIRECTORY}/.evergreen/tox.sh -m test-eg
|
||||
bash ${PROJECT_DIRECTORY}/.evergreen/hatch.sh test:test-eg
|
||||
|
||||
"run enterprise auth tests":
|
||||
- command: shell.exec
|
||||
@ -462,7 +464,7 @@ functions:
|
||||
PYTHON_BINARY="${PYTHON_BINARY}" \
|
||||
TEST_ENTERPRISE_AUTH=1 \
|
||||
AUTH=auth \
|
||||
bash ${PROJECT_DIRECTORY}/.evergreen/tox.sh -m test-eg
|
||||
bash ${PROJECT_DIRECTORY}/.evergreen/hatch.sh test:test-eg
|
||||
|
||||
"run atlas tests":
|
||||
- command: shell.exec
|
||||
@ -478,7 +480,7 @@ functions:
|
||||
PROJECT_DIRECTORY="${PROJECT_DIRECTORY}" \
|
||||
PYTHON_BINARY="${PYTHON_BINARY}" \
|
||||
TEST_ATLAS=1 \
|
||||
bash ${PROJECT_DIRECTORY}/.evergreen/tox.sh -m test-eg
|
||||
bash ${PROJECT_DIRECTORY}/.evergreen/hatch.sh test:test-eg
|
||||
|
||||
"get aws auth secrets":
|
||||
- command: subprocess.exec
|
||||
@ -597,7 +599,7 @@ functions:
|
||||
working_dir: "src"
|
||||
script: |
|
||||
${PREPARE_SHELL}
|
||||
. .evergreen/tox.sh -m teardown-encryption
|
||||
. .evergreen/hatch.sh encryption:teardown
|
||||
rm -rf $DRIVERS_TOOLS || true
|
||||
rm -f ./secrets-export.sh || true
|
||||
|
||||
@ -683,7 +685,7 @@ functions:
|
||||
PYTHON_BINARY=${PYTHON_BINARY} \
|
||||
CA_FILE="$DRIVERS_TOOLS/.evergreen/ocsp/${OCSP_ALGORITHM}/ca.pem" \
|
||||
OCSP_TLS_SHOULD_SUCCEED="${OCSP_TLS_SHOULD_SUCCEED}" \
|
||||
bash ${PROJECT_DIRECTORY}/.evergreen/tox.sh -m test-eg
|
||||
bash ${PROJECT_DIRECTORY}/.evergreen/hatch.sh test:test-eg
|
||||
|
||||
run-valid-ocsp-server:
|
||||
- command: shell.exec
|
||||
@ -2128,7 +2130,7 @@ tasks:
|
||||
${PREPARE_SHELL}
|
||||
export PYTHON_BINARY=/opt/mongodbtoolchain/v4/bin/python3
|
||||
export LIBMONGOCRYPT_URL=https://s3.amazonaws.com/${bucket_name}/libmongocrypt/debian10/master/latest/libmongocrypt.tar.gz
|
||||
SUCCESS=false TEST_FLE_GCP_AUTO=1 ./.evergreen/tox.sh -m test-eg
|
||||
SUCCESS=false TEST_FLE_GCP_AUTO=1 ./.evergreen/hatch.sh test:test-eg
|
||||
|
||||
- name: testazurekms-task
|
||||
commands:
|
||||
|
||||
24
.evergreen/hatch.sh
Normal file
24
.evergreen/hatch.sh
Normal file
@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
set -o errexit # Exit the script with error if any of the commands fail
|
||||
set -x
|
||||
|
||||
. .evergreen/utils.sh
|
||||
|
||||
if [ -z "$PYTHON_BINARY" ]; then
|
||||
PYTHON_BINARY=$(find_python3)
|
||||
fi
|
||||
|
||||
if $PYTHON_BINARY -m hatch --version; then
|
||||
run_hatch() {
|
||||
$PYTHON_BINARY hatch run "$@"
|
||||
}
|
||||
else # No toolchain hatch present, set up virtualenv before installing hatch
|
||||
createvirtualenv "$PYTHON_BINARY" hatchenv
|
||||
trap "deactivate; rm -rf hatchenv" EXIT HUP
|
||||
python -m pip install -q hatch
|
||||
run_hatch() {
|
||||
python -m hatch run "$@"
|
||||
}
|
||||
fi
|
||||
|
||||
run_hatch "${@:1}"
|
||||
@ -7,4 +7,4 @@ PYTHON_BINARY=/opt/mongodbtoolchain/v4/bin/python3 \
|
||||
KEY_VAULT_ENDPOINT="${AZUREKMS_KEYVAULTENDPOINT}" \
|
||||
LIBMONGOCRYPT_URL=https://s3.amazonaws.com/mciuploads/libmongocrypt/debian10/master/latest/libmongocrypt.tar.gz \
|
||||
SUCCESS=false TEST_FLE_AZURE_AUTO=1 \
|
||||
./.evergreen/tox.sh -m test-eg
|
||||
./.evergreen/hatch.sh test:test-eg
|
||||
|
||||
@ -16,6 +16,6 @@ AZUREKMS_CMD="tar xf mongo-python-driver.tgz" \
|
||||
$DRIVERS_TOOLS/.evergreen/csfle/azurekms/run-command.sh
|
||||
echo "Untarring file ... end"
|
||||
echo "Running test ... begin"
|
||||
AZUREKMS_CMD="KEY_NAME=\"$AZUREKMS_KEYNAME\" KEY_VAULT_ENDPOINT=\"$AZUREKMS_KEYVAULTENDPOINT\" LIBMONGOCRYPT_URL=https://s3.amazonaws.com/mciuploads/libmongocrypt/debian10/master/latest/libmongocrypt.tar.gz SUCCESS=true TEST_FLE_AZURE_AUTO=1 ./.evergreen/tox.sh -m test-eg" \
|
||||
AZUREKMS_CMD="KEY_NAME=\"$AZUREKMS_KEYNAME\" KEY_VAULT_ENDPOINT=\"$AZUREKMS_KEYVAULTENDPOINT\" LIBMONGOCRYPT_URL=https://s3.amazonaws.com/mciuploads/libmongocrypt/debian10/master/latest/libmongocrypt.tar.gz SUCCESS=true TEST_FLE_AZURE_AUTO=1 ./.evergreen/hatch.sh test:test-eg" \
|
||||
$DRIVERS_TOOLS/.evergreen/csfle/azurekms/run-command.sh
|
||||
echo "Running test ... end"
|
||||
|
||||
@ -14,5 +14,5 @@ echo "Untarring file ... begin"
|
||||
GCPKMS_CMD="tar xf mongo-python-driver.tgz" $DRIVERS_TOOLS/.evergreen/csfle/gcpkms/run-command.sh
|
||||
echo "Untarring file ... end"
|
||||
echo "Running test ... begin"
|
||||
GCPKMS_CMD="SUCCESS=true TEST_FLE_GCP_AUTO=1 LIBMONGOCRYPT_URL=https://s3.amazonaws.com/mciuploads/libmongocrypt/debian10/master/latest/libmongocrypt.tar.gz ./.evergreen/tox.sh -m test-eg" $DRIVERS_TOOLS/.evergreen/csfle/gcpkms/run-command.sh
|
||||
GCPKMS_CMD="SUCCESS=true TEST_FLE_GCP_AUTO=1 LIBMONGOCRYPT_URL=https://s3.amazonaws.com/mciuploads/libmongocrypt/debian10/master/latest/libmongocrypt.tar.gz ./.evergreen/hatch.sh test:test-eg" $DRIVERS_TOOLS/.evergreen/csfle/gcpkms/run-command.sh
|
||||
echo "Running test ... end"
|
||||
|
||||
@ -30,5 +30,5 @@ export TEST_AUTH_AWS=1
|
||||
export AUTH="auth"
|
||||
export SET_XTRACE_ON=1
|
||||
cd src
|
||||
$PYTHON_BINARY -m pip install -q --user tox
|
||||
bash .evergreen/tox.sh -m test-eg
|
||||
$PYTHON_BINARY -m pip install -q --user hatch
|
||||
bash .evergreen/hatch.sh test:test-eg
|
||||
|
||||
@ -24,4 +24,4 @@ set -x
|
||||
export TEST_AUTH_AWS=1
|
||||
export AUTH="auth"
|
||||
export SET_XTRACE_ON=1
|
||||
bash ./.evergreen/tox.sh -m test-eg
|
||||
bash ./.evergreen/hatch.sh test:test-eg
|
||||
|
||||
@ -29,4 +29,4 @@ fi
|
||||
export TEST_AUTH_OIDC=1
|
||||
export COVERAGE=1
|
||||
export AUTH="auth"
|
||||
bash ./.evergreen/tox.sh -m test-eg -- "${@:1}"
|
||||
bash ./.evergreen/hatch.sh test:test-eg -- "${@:1}"
|
||||
|
||||
@ -16,4 +16,4 @@ export OUTPUT_FILE="${PROJECT_DIRECTORY}/results.json"
|
||||
export PYTHON_BINARY=/opt/mongodbtoolchain/v4/bin/python3
|
||||
export PERF_TEST=1
|
||||
|
||||
bash ./.evergreen/tox.sh -m test-eg
|
||||
bash ./.evergreen/hatch.sh test:test-eg
|
||||
|
||||
@ -123,9 +123,9 @@ if [ -n "$TEST_ENCRYPTION" ] || [ -n "$TEST_FLE_AZURE_AUTO" ] || [ -n "$TEST_FLE
|
||||
|
||||
python -m pip install '.[encryption]'
|
||||
|
||||
# Install libmongocrypt if necessary.
|
||||
# Setup encryption if necessary.
|
||||
if [ ! -d "libmongocrypt" ]; then
|
||||
bash ./.evergreen/setup-libmongocrypt.sh
|
||||
bash ./.evergreen/setup-encryption.sh
|
||||
fi
|
||||
|
||||
# Use the nocrypto build to avoid dependency issues with older windows/python versions.
|
||||
|
||||
@ -2,6 +2,10 @@
|
||||
set -o errexit # Exit the script with error if any of the commands fail
|
||||
set -o xtrace
|
||||
|
||||
if [ -z "${DRIVERS_TOOLS}" ]; then
|
||||
echo "Missing environment variable DRIVERS_TOOLS"
|
||||
fi
|
||||
|
||||
TARGET=""
|
||||
|
||||
if [ "Windows_NT" = "${OS:-''}" ]; then # Magic variable in cygwin
|
||||
@ -45,3 +49,6 @@ mkdir libmongocrypt
|
||||
tar xzf libmongocrypt.tar.gz -C ./libmongocrypt
|
||||
ls -la libmongocrypt
|
||||
ls -la libmongocrypt/nocrypto
|
||||
|
||||
bash ${DRIVERS_TOOLS}/.evergreen/csfle/setup-secrets.sh
|
||||
bash ${DRIVERS_TOOLS}/.evergreen/csfle/start-servers.sh
|
||||
10
.evergreen/teardown-encryption.sh
Normal file
10
.evergreen/teardown-encryption.sh
Normal file
@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
set -o errexit # Exit the script with error if any of the commands fail
|
||||
set -o xtrace
|
||||
|
||||
if [ -z "${DRIVERS_TOOLS}" ]; then
|
||||
echo "Missing environment variable DRIVERS_TOOLS"
|
||||
fi
|
||||
|
||||
bash ${DRIVERS_TOOLS}/.evergreen/csfle/stop-servers.sh
|
||||
rm -rf libmongocrypt/ libmongocrypt_git/ libmongocrypt.tar.gz mongocryptd.pid
|
||||
@ -1,24 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -o errexit # Exit the script with error if any of the commands fail
|
||||
set -x
|
||||
|
||||
. .evergreen/utils.sh
|
||||
|
||||
if [ -z "$PYTHON_BINARY" ]; then
|
||||
PYTHON_BINARY=$(find_python3)
|
||||
fi
|
||||
|
||||
if $PYTHON_BINARY -m tox --version; then
|
||||
run_tox() {
|
||||
$PYTHON_BINARY -m tox "$@"
|
||||
}
|
||||
else # No toolchain present, set up virtualenv before installing tox
|
||||
createvirtualenv "$PYTHON_BINARY" toxenv
|
||||
trap "deactivate; rm -rf toxenv" EXIT HUP
|
||||
python -m pip install -q tox
|
||||
run_tox() {
|
||||
python -m tox "$@"
|
||||
}
|
||||
fi
|
||||
|
||||
run_tox "${@:1}"
|
||||
@ -66,7 +66,7 @@ createvirtualenv () {
|
||||
|
||||
export PIP_QUIET=1
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install --upgrade tox
|
||||
python -m pip install --upgrade hatch
|
||||
}
|
||||
|
||||
# Usage:
|
||||
|
||||
34
.github/workflows/test-python.yml
vendored
34
.github/workflows/test-python.yml
vendored
@ -27,10 +27,10 @@ jobs:
|
||||
cache-dependency-path: 'pyproject.toml'
|
||||
- name: Install Python dependencies
|
||||
run: |
|
||||
python -m pip install -U pip tox
|
||||
python -m pip install -U pip hatch
|
||||
- name: Run linters
|
||||
run: |
|
||||
tox -m lint-manual
|
||||
hatch run lint:run-manual
|
||||
- name: Run compilation
|
||||
run: |
|
||||
export PYMONGO_C_EXT_MUST_BUILD=1
|
||||
@ -38,7 +38,7 @@ jobs:
|
||||
python tools/fail_if_no_c.py
|
||||
- name: Run typecheck
|
||||
run: |
|
||||
tox -m typecheck
|
||||
hatch run typing:check
|
||||
- run: |
|
||||
sudo apt-get install -y cppcheck
|
||||
- run: |
|
||||
@ -64,17 +64,23 @@ jobs:
|
||||
allow-prereleases: true
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
pip install -q tox
|
||||
pip install -U pip
|
||||
if [ "${{ matrix.python-version }}" == "3.13" ]; then
|
||||
pip install --pre cffi setuptools
|
||||
pip install --no-build-isolation hatch
|
||||
else
|
||||
pip install hatch
|
||||
fi
|
||||
- name: Start MongoDB
|
||||
uses: supercharge/mongodb-github-action@1.10.0
|
||||
with:
|
||||
mongodb-version: 6.0
|
||||
- name: Run tests
|
||||
run: |
|
||||
tox -m test
|
||||
hatch run test:test
|
||||
- name: Run async tests
|
||||
run: |
|
||||
tox -m test-async
|
||||
hatch run test:test-async
|
||||
|
||||
doctest:
|
||||
runs-on: ubuntu-latest
|
||||
@ -89,14 +95,14 @@ jobs:
|
||||
cache-dependency-path: 'pyproject.toml'
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
pip install -q tox
|
||||
pip install -U hatch pip
|
||||
- name: Start MongoDB
|
||||
uses: supercharge/mongodb-github-action@1.10.0
|
||||
with:
|
||||
mongodb-version: 4.4
|
||||
- name: Run tests
|
||||
run: |
|
||||
tox -m doc-test
|
||||
hatch run doctest:test
|
||||
|
||||
docs:
|
||||
name: Docs Checks
|
||||
@ -111,10 +117,10 @@ jobs:
|
||||
python-version: '3.8'
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
pip install -q tox
|
||||
pip install -U pip hatch
|
||||
- name: Build docs
|
||||
run: |
|
||||
tox -m doc
|
||||
hatch run doc:build
|
||||
|
||||
linkcheck:
|
||||
name: Link Check
|
||||
@ -129,10 +135,10 @@ jobs:
|
||||
python-version: '3.8'
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
pip install -q tox
|
||||
pip install -U pip hatch
|
||||
- name: Build docs
|
||||
run: |
|
||||
tox -m linkcheck
|
||||
hatch run doc:linkcheck
|
||||
|
||||
typing:
|
||||
name: Typing Tests
|
||||
@ -149,10 +155,10 @@ jobs:
|
||||
cache-dependency-path: 'pyproject.toml'
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
pip install -q tox
|
||||
pip install -U pip hatch
|
||||
- name: Run typecheck
|
||||
run: |
|
||||
tox -m typecheck
|
||||
hatch run typing:check
|
||||
|
||||
make_sdist:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@ -28,8 +28,9 @@ including 4 space indents and 79 character line limits.
|
||||
|
||||
- Avoid backward breaking changes if at all possible.
|
||||
- Write inline documentation for new classes and methods.
|
||||
- We use [hatch](https://hatch.pypa.io/dev/) for our script runner and packaging tool.
|
||||
- Write tests and make sure they pass (make sure you have a mongod
|
||||
running on the default port, then execute `tox -e test` from the cmd
|
||||
running on the default port, then execute `hatch run test:test` from the cmd
|
||||
line to run the test suite).
|
||||
- Add yourself to doc/contributors.rst `:)`
|
||||
|
||||
@ -153,11 +154,11 @@ To run a manual hook like `mypy` manually, run:
|
||||
pre-commit run --all-files --hook-stage manual mypy
|
||||
```
|
||||
|
||||
Typically we use `tox` to run the linters, e.g.
|
||||
Typically we use `hatch` to run the linters, e.g.
|
||||
|
||||
```bash
|
||||
tox -e typecheck-mypy
|
||||
tox -e lint-manual
|
||||
hatch run typing:check-mypy
|
||||
hatch run lint:build-manual
|
||||
```
|
||||
|
||||
## Documentation
|
||||
@ -178,13 +179,13 @@ documentation including narrative docs, and the [Sphinx docstring format](https:
|
||||
You can build the documentation locally by running:
|
||||
|
||||
```bash
|
||||
tox -e doc
|
||||
hatch run doc:build
|
||||
```
|
||||
|
||||
When updating docs, it can be helpful to run the live docs server as:
|
||||
|
||||
```bash
|
||||
tox -e doc-serve
|
||||
hatch run doc:serve
|
||||
```
|
||||
|
||||
Browse to the link provided, and then as you make changes to docstrings or narrative docs,
|
||||
@ -194,13 +195,13 @@ the pages will re-render and the browser will automatically refresh.
|
||||
## Running Tests Locally
|
||||
|
||||
- Ensure you have started the appropriate Mongo Server(s).
|
||||
- Run `pip install tox` to use `tox` for testing or run
|
||||
- Run `pip install hatch` to use `hatch` for testing or run
|
||||
`pip install -e ".[test]"` to run `pytest` directly.
|
||||
- Run `tox -m test` or `pytest` to run all of the tests.
|
||||
- Run `hatch run test:test` or `pytest` to run all of the tests.
|
||||
- Append `test/<mod_name>.py::<class_name>::<test_name>` to run
|
||||
specific tests. You can omit the `<test_name>` to test a full class
|
||||
and the `<class_name>` to test a full module. For example:
|
||||
`tox -m test -- test/test_change_stream.py::TestUnifiedChangeStreamsErrors::test_change_stream_errors_on_ElectionInProgress`.
|
||||
`hatch run test:test -- test/test_change_stream.py::TestUnifiedChangeStreamsErrors::test_change_stream_errors_on_ElectionInProgress`.
|
||||
- Use the `-k` argument to select tests by pattern.
|
||||
|
||||
## Running Load Balancer Tests Locally
|
||||
@ -213,15 +214,15 @@ the pages will re-render and the browser will automatically refresh.
|
||||
- Start the load balancer using:
|
||||
`MONGODB_URI='mongodb://localhost:27017,localhost:27018/' $PWD/drivers-evergreen-tools/.evergreen/run-load-balancer.sh start`.
|
||||
- Run the tests from the `pymongo` checkout directory using:
|
||||
`TEST_LOADBALANCER=1 tox -m test-eg`.
|
||||
`TEST_LOADBALANCER=1 hatch run test:test-eg`.
|
||||
|
||||
## Running Encryption Tests Locally
|
||||
- Clone `drivers-evergreen-tools`:
|
||||
`git clone git@github.com:mongodb-labs/drivers-evergreen-tools.git`.
|
||||
- Run `export DRIVERS_TOOLS=$PWD/drivers-evergreen-tools`
|
||||
- Run `AWS_PROFILE=<profile> tox -m setup-encryption` after setting up your AWS profile with `aws configure sso`.
|
||||
- Run the tests with `TEST_ENCRYPTION=1 tox -e test-eg`.
|
||||
- When done, run `tox -m teardown-encryption` to clean up.
|
||||
- Run `AWS_PROFILE=<profile> hatch run encryption:setup` after setting up your AWS profile with `aws configure sso`.
|
||||
- Run the tests with `TEST_ENCRYPTION=1 hatch run test:test-eg`.
|
||||
- When done, run `hatch run encryption:teardown` to clean up.
|
||||
|
||||
## Re-sync Spec Tests
|
||||
|
||||
|
||||
@ -155,7 +155,7 @@ python -m pip install "pymongo[gssapi,aws,ocsp,snappy,zstd,encryption]"
|
||||
Additional dependencies are:
|
||||
|
||||
- (to generate documentation or run tests)
|
||||
[tox](https://tox.wiki/en/latest/index.html)
|
||||
[hatch](https://hatch.pypa.io/dev/)
|
||||
|
||||
## Examples
|
||||
|
||||
@ -201,7 +201,7 @@ ObjectId('4aba160ee23f6b543e000002')
|
||||
Documentation is available at
|
||||
[pymongo.readthedocs.io](https://pymongo.readthedocs.io/en/stable/).
|
||||
|
||||
Documentation can be generated by running **tox -m doc**. Generated
|
||||
Documentation can be generated by running **pip install hatch; hatch run doc:build**. Generated
|
||||
documentation can be found in the `doc/build/html/` directory.
|
||||
|
||||
## Learning Resources
|
||||
@ -213,9 +213,10 @@ Center](https://www.mongodb.com/developer/languages/python/).
|
||||
|
||||
## Testing
|
||||
|
||||
The easiest way to run the tests is to run **tox -m test** in the root
|
||||
The easiest way to run the tests is to run *hatch run test:test** in the root
|
||||
of the distribution. For example,
|
||||
|
||||
```bash
|
||||
tox -e test
|
||||
pip install hatch
|
||||
hatch run test:test
|
||||
```
|
||||
|
||||
@ -105,8 +105,8 @@ following command from the root directory of the **PyMongo** source:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ pip install tox
|
||||
$ tox -m doc
|
||||
$ pip install hatch
|
||||
$ hatch run doc:build
|
||||
|
||||
Indices and tables
|
||||
------------------
|
||||
|
||||
51
hatch.toml
Normal file
51
hatch.toml
Normal file
@ -0,0 +1,51 @@
|
||||
# See https://hatch.pypa.io/dev/config/environment/overview/
|
||||
|
||||
[envs.doc]
|
||||
features = ["docs"]
|
||||
[envs.doc.scripts]
|
||||
build = "sphinx-build -W -b html doc ./doc/_build/html"
|
||||
serve = "sphinx-autobuild -W -b html doc --watch ./pymongo --watch ./bson --watch ./gridfs ./doc/_build/serve"
|
||||
linkcheck = "sphinx-build -E -b linkcheck doc ./doc/_build/linkcheck"
|
||||
|
||||
[envs.doctest]
|
||||
features = ["docs","test"]
|
||||
[envs.doctest.scripts]
|
||||
test = "sphinx-build -E -b doctest doc ./doc/_build/doctest"
|
||||
|
||||
[envs.typing]
|
||||
features = ["encryption", "ocsp", "zstd", "aws"]
|
||||
dependencies = ["mypy==1.2.0","pyright==1.1.290", "certifi", "typing_extensions"]
|
||||
[envs.typing.scripts]
|
||||
check-mypy = [
|
||||
"mypy --install-types --non-interactive bson gridfs tools pymongo",
|
||||
"mypy --install-types --non-interactive --config-file mypy_test.ini test",
|
||||
"mypy --install-types --non-interactive test/test_typing.py test/test_typing_strict.py"
|
||||
]
|
||||
check-pyright = ["rm -f pyrightconfig.json", "pyright test/test_typing.py test/test_typing_strict.py"]
|
||||
check-strict-pyright = [
|
||||
"echo '{{\"strict\": [\"tests/test_typing_strict.py\"]}}' > pyrightconfig.json",
|
||||
"pyright test/test_typing_strict.py",
|
||||
"rm -f pyrightconfig.json"
|
||||
]
|
||||
check = ["check-mypy", "check-pyright", "check-strict-pyright"]
|
||||
|
||||
[envs.lint]
|
||||
skip-install = true
|
||||
dependencies = ["pre-commit"]
|
||||
[envs.lint.scripts]
|
||||
run = "pre-commit run --all-files"
|
||||
run-manual = "pre-commit run --all-files --hook-stage manual"
|
||||
|
||||
[envs.test]
|
||||
features = ["test"]
|
||||
[envs.test.scripts]
|
||||
test = "pytest -v --durations=5 --maxfail=10 {args}"
|
||||
test-eg = "bash ./.evergreen/run-tests.sh {args}"
|
||||
test-async = "test test/asynchronous/ {args}"
|
||||
test-mockupdb = ["pip install -U git+https://github.com/ajdavis/mongo-mockup-db@master", "test ./test/mockupdb"]
|
||||
|
||||
[envs.encryption]
|
||||
skip-install = true
|
||||
[envs.encryption.scripts]
|
||||
setup = "bash .evergreen/setup-encryption.sh"
|
||||
teardown = "bash .evergreen/teardown-encryption.sh"
|
||||
212
tox.ini
212
tox.ini
@ -1,212 +0,0 @@
|
||||
[tox]
|
||||
requires =
|
||||
tox>=4
|
||||
|
||||
envlist =
|
||||
# Test using the system Python.
|
||||
test,
|
||||
# Test async tests using the system Python.
|
||||
test-async,
|
||||
# Test using the run-tests Evergreen script.
|
||||
test-eg,
|
||||
# Set up encryption files and services.
|
||||
setup-encryption,
|
||||
# Tear down encryption files and services.
|
||||
teardown-encryption,
|
||||
# Run pre-commit on all files.
|
||||
lint,
|
||||
# Run pre-commit on all files, including stages that require manual fixes.
|
||||
lint-manual,
|
||||
# Typecheck using mypy.
|
||||
typecheck-mypy,
|
||||
# Typecheck using pyright.
|
||||
typecheck-pyright,
|
||||
# Typecheck using pyright strict.
|
||||
typecheck-pyright-strict,
|
||||
# Typecheck all files.
|
||||
typecheck,
|
||||
# Build sphinx docs
|
||||
doc,
|
||||
# Server live sphinx docs
|
||||
doc-serve,
|
||||
# Test sphinx docs
|
||||
doc-test,
|
||||
# Linkcheck sphinx docs
|
||||
linkcheck
|
||||
|
||||
labels = # Use labels and -m instead of -e so that tox -m <label> fails instantly if the label does not exist
|
||||
test = test
|
||||
test-async = test-async
|
||||
test-eg = test-eg
|
||||
setup-encryption = setup-encryption
|
||||
teardown-encryption = teardown-encryption
|
||||
lint = lint
|
||||
lint-manual = lint-manual
|
||||
typecheck-mypy = typecheck-mypy
|
||||
typecheck-pyright = typecheck-pyright
|
||||
typecheck-pyright-strict = typecheck-pyright-strict
|
||||
typecheck = typecheck
|
||||
doc = doc
|
||||
doc-serve = doc-serve
|
||||
doc-test = doc-test
|
||||
linkcheck = linkcheck
|
||||
test-mockupdb = test-mockupdb
|
||||
aws-secrets = aws-secrets
|
||||
|
||||
[testenv]
|
||||
package = editable
|
||||
|
||||
[testenv:.pkg]
|
||||
pass_env =
|
||||
NO_EXT
|
||||
|
||||
[testenv:test]
|
||||
description = run base set of unit tests with no extra functionality
|
||||
extras =
|
||||
test
|
||||
commands =
|
||||
pytest -v --durations=5 --maxfail=10 {posargs}
|
||||
|
||||
[testenv:test-async]
|
||||
description = run base set of async unit tests with no extra functionality
|
||||
extras =
|
||||
test
|
||||
commands =
|
||||
pytest -v --durations=5 --maxfail=10 test/asynchronous/ {posargs}
|
||||
|
||||
[testenv:test-eg]
|
||||
description = run tests using run-tests.sh Evergreen script
|
||||
passenv = *
|
||||
extras = test
|
||||
allowlist_externals =
|
||||
bash
|
||||
commands =
|
||||
bash ./.evergreen/run-tests.sh {posargs}
|
||||
|
||||
[testenv:lint]
|
||||
description = run pre-commit
|
||||
skip_install = true
|
||||
deps =
|
||||
pre-commit
|
||||
commands =
|
||||
pre-commit run --all-files
|
||||
|
||||
[testenv:lint-manual]
|
||||
description = run all pre-commit stages, including those that require manual fixes
|
||||
skip_install = true
|
||||
deps =
|
||||
pre-commit
|
||||
commands =
|
||||
pre-commit run --all-files --hook-stage manual
|
||||
|
||||
[testenv:typecheck-mypy]
|
||||
description = run mypy and pyright to typecheck
|
||||
extras =
|
||||
encryption
|
||||
ocsp
|
||||
zstd
|
||||
aws
|
||||
deps =
|
||||
mypy==1.2.0
|
||||
certifi; platform_system == "win32" or platform_system == "Darwin"
|
||||
typing_extensions
|
||||
commands =
|
||||
mypy --install-types --non-interactive bson gridfs tools pymongo
|
||||
mypy --install-types --non-interactive --config-file mypy_test.ini test
|
||||
mypy --install-types --non-interactive test/test_typing.py test/test_typing_strict.py
|
||||
|
||||
[testenv:typecheck-pyright]
|
||||
description = run pyright to typecheck
|
||||
deps =
|
||||
mypy==1.2.0
|
||||
pyright==1.1.290
|
||||
commands =
|
||||
pyright test/test_typing.py test/test_typing_strict.py
|
||||
|
||||
[testenv:typecheck-pyright-strict]
|
||||
description = run pyright with strict mode to typecheck
|
||||
deps =
|
||||
{[testenv:typecheck-pyright]deps}
|
||||
allowlist_externals=echo
|
||||
commands =
|
||||
echo '{"strict": ["tests/test_typing_strict.py"]}' > pyrightconfig.json
|
||||
pyright test/test_typing_strict.py
|
||||
|
||||
[testenv:typecheck]
|
||||
description = run mypy and pyright to typecheck
|
||||
extras =
|
||||
{[testenv:typecheck-mypy]extras}
|
||||
deps =
|
||||
{[testenv:typecheck-mypy]deps}
|
||||
{[testenv:typecheck-pyright]deps}
|
||||
allowlist_externals=echo
|
||||
commands =
|
||||
python tools/ensure_future_annotations_import.py
|
||||
{[testenv:typecheck-mypy]commands}
|
||||
{[testenv:typecheck-pyright]commands}
|
||||
{[testenv:typecheck-pyright-strict]commands}
|
||||
|
||||
[testenv:doc]
|
||||
description = build sphinx docs
|
||||
deps =
|
||||
-rrequirements/docs.txt
|
||||
commands =
|
||||
sphinx-build -W -b html doc ./doc/_build/html
|
||||
|
||||
[testenv:doc-serve]
|
||||
description = serve sphinx docs
|
||||
deps =
|
||||
{[testenv:doc]deps}
|
||||
sphinx-autobuild
|
||||
commands =
|
||||
sphinx-autobuild -W -b html doc --watch ./pymongo --watch ./bson --watch ./gridfs ./doc/_build/serve
|
||||
|
||||
[testenv:doc-test]
|
||||
description = run sphinx doc tests
|
||||
deps =
|
||||
{[testenv:doc]deps}
|
||||
pytz
|
||||
commands =
|
||||
sphinx-build -E -b doctest doc ./doc/_build/doctest
|
||||
|
||||
[testenv:linkcheck]
|
||||
description = check links of sphinx docs
|
||||
deps =
|
||||
{[testenv:doc]deps}
|
||||
commands =
|
||||
sphinx-build -E -b linkcheck doc ./doc/_build/linkcheck
|
||||
|
||||
[testenv:test-mockupdb]
|
||||
description = run mockupdb tests
|
||||
deps =
|
||||
{[testenv:test]deps}
|
||||
https://github.com/ajdavis/mongo-mockup-db/archive/master.zip
|
||||
extras =
|
||||
{[testenv:test]extras}
|
||||
passenv = *
|
||||
allowlist_externals =
|
||||
{[testenv:test]allowlist_externals}
|
||||
commands =
|
||||
{[testenv:test]commands} ./test/mockupdb
|
||||
|
||||
[testenv:setup-encryption]
|
||||
description = set up encryption assets and servers
|
||||
skip_install = true
|
||||
passenv = *
|
||||
allowlist_externals =
|
||||
bash
|
||||
commands =
|
||||
bash .evergreen/setup-libmongocrypt.sh
|
||||
bash {env:DRIVERS_TOOLS:DRIVERS_TOOLS_var_undefined}/.evergreen/csfle/setup-secrets.sh
|
||||
bash {env:DRIVERS_TOOLS}/.evergreen/csfle/start-servers.sh
|
||||
|
||||
[testenv:teardown-encryption]
|
||||
description = tear down encryption assets and servers
|
||||
skip_install = true
|
||||
passenv = *
|
||||
allowlist_externals =
|
||||
bash
|
||||
rm
|
||||
commands =
|
||||
bash {env:DRIVERS_TOOLS:DRIVERS_TOOLS_var_undefined}/.evergreen/csfle/stop-servers.sh
|
||||
rm -rf libmongocrypt/ libmongocrypt_git/ libmongocrypt.tar.gz mongocryptd.pid
|
||||
Loading…
Reference in New Issue
Block a user