pytest-runner

raw JSON →
6.0.1 verified Sat Apr 11 auth: no python quickstart: stale deprecated

pytest-runner is a setuptools extension that historically allowed pytest to be invoked via `python setup.py test`. Version 6.0.1 is the latest release, but the project is officially deprecated and its GitHub repository was archived in December 2023. It is no longer recommended for use in modern Python projects due to reliance on deprecated setuptools features and security concerns.

pip install pytest-runner
breaking The `pytest-runner` project is officially deprecated and its GitHub repository was archived in December 2023. The `setup.py test` command it enables is also being deprecated and slated for removal by `setuptools` itself. You should migrate away from `pytest-runner` for all projects.
fix Remove `pytest-runner` from `setup_requires` and `pytest` from `tests_require` in your `setup.py`. Instead, invoke `pytest` directly (e.g., `python -m pytest` or `pytest`) or use a dedicated test orchestration tool like `tox`. Configure `pytest` using `pyproject.toml`, `pytest.ini`, or `setup.cfg`'s `[tool:pytest]` section.
gotcha `pytest-runner` (and the `setup_requires`/`tests_require` mechanism it relies upon) can bypass security mechanisms in `pip`, specifically `pip --require-hashes`. This can lead to insecure dependency resolution.
fix Follow the deprecation migration path by removing `pytest-runner` and invoking `pytest` directly. Manage test dependencies explicitly in `pyproject.toml` or `requirements.txt` for better security and reproducibility.
gotcha For new projects, or migrating existing ones, `pytest-runner` is unnecessary. `pytest` should be installed as a regular development dependency, typically specified in `pyproject.toml` (`[project.optional-dependencies]`) or `requirements-dev.txt`, and invoked directly from the command line (e.g., `pytest` or `python -m pytest`).
fix Ensure `pytest` is listed as a development dependency. Remove `pytest-runner` and any `setup_requires` or `tests_require` sections related to testing from `setup.py`. Configure `pytest` using `pyproject.toml`, `pytest.ini`, or `setup.cfg`.
breaking The script failed because the `setuptools` package was not found. This typically occurs when a Python script (especially a `setup.py` file) attempts to import `setuptools` without it being installed in the active environment.
fix Ensure `setuptools` is installed in your Python environment. You can install it using `pip install setuptools`. If you are running this in a container or isolated environment, ensure `setuptools` is included in the environment's dependencies (e.g., in a `requirements.txt` or a Dockerfile).

This is the *deprecated* quickstart method for `pytest-runner`. It demonstrates how to configure your `setup.py` to use `pytest-runner` to enable the `python setup.py pytest` (or `test`) command. Modern projects are advised to run `pytest` directly or via tools like `tox`.

# In setup.py (NOTE: This usage pattern is deprecated!)
from setuptools import setup, find_packages

setup(
    name='my-package',
    version='0.1.0',
    packages=find_packages(),
    setup_requires=[
        'pytest-runner',
    ],
    tests_require=[
        'pytest',
    ],
)

# To run tests (from your project root):
# python setup.py pytest
# OR python setup.py test (if 'test=pytest' alias is set in setup.cfg)