def prepare_pip_requirements(env):
    requirements = list(itertools.chain(
        pytest_requirements(env.sys_version_info, env.ctypes_version),
        six_requirements(env.sys_version_info),
        virtualenv_requirements(env.sys_version_info)))
    janitor = prepare_pip_requirements_file_if_needed(requirements)
    return requirements, janitor
Beispiel #2
0
def prepare_pip_requirements(env):
    requirements = list(
        itertools.chain(
            pytest_requirements(env.sys_version_info, env.ctypes_version),
            six_requirements(env.sys_version_info),
            virtualenv_requirements(env.sys_version_info)))
    janitor = prepare_pip_requirements_file_if_needed(requirements)
    return requirements, janitor
Beispiel #3
0
def test_requirements():
    """
    Return test requirements for the 'test' command or an error string.

    An error is reported if the requirements can not be satisfied for some
    reason.

    Exact required packages and their versions vary depending on our target
    Python environment version as pytest dropped backward compatibility support
    for some of the Python versions we still support in this project.

    """
    if not using_setuptools:
        return "test command not available without setuptools"

    include_pytest_requirements = True

    if sys.version_info < (2, 5):
        # pytest requirements can not be installed automatically by this setup
        # script under Python 2.4.x environment. Specific pytest & py library
        # package version combination that we found working in Python 2.4.x
        # environments does not formally satisfy pytest requirements, and we
        # found no way to make setuptools' test command succeed when this
        # script installs packages that do not have all their formal
        # requirements satisfied.
        have_pytest, have_py = check_Python24_pytest_requirements()
        if not have_pytest:
            return "compatible preinstalled pytest needed prior to Python 2.5"
        if not have_py:
            return "compatible preinstalled py needed prior to Python 2.5"

        # We must not explicitly specify pytest requirements when running the
        # tests using a Python 2.4.x environment as the only way we found we
        # can run our tests there is to use formally incompatible pytest & py
        # packages. Explicitly specifying pytest requirements here would then
        # cause setuptols to verify those requirements prior to running our
        # test suite.
        include_pytest_requirements = False

    if ((3,) <= sys.version_info < (3, 2, 3)):
        # Python 3.x versions prior to Python 3.2.3 have a bug in their inspect
        # module causing inspect.getmodule() calls to fail if some module lazy
        # loads other modules when some of its attributes are accessed. For
        # more detailed information see Python development issue #13487
        # (http://bugs.python.org/issue13487).
        #
        # This occurs when using setuptools to install our project into a
        # Python 3.1 environment. There the py.error module seems to do such
        # lazy loading. Forcing that module to be loaded here, before the
        # setuptools installation procedure, avoids the issue.
        try:
            import py.error
            py.error.__attribute_access_to_force_this_module_to_lazy_load__
        except (AttributeError, ImportError):
            pass

    # When using Python 2.5 on Windows, if setuptools chooses to install the
    # colorama package (pytest requirement on Windows) older than version
    # 0.1.11, running our 'setup.py test' command may show benign error
    # messages caused by some colorama atexit handlers getting triggered
    # multiple times. There are no adverse effects to this and the issue only
    # occurs if the package is not already installed and it is the 'setup.py
    # test' command that is installing it. The issue has been fixed by the next
    # Python 2.5 compatible colorama 0.3.2 release.
    result = []
    if include_pytest_requirements:
        result.extend(pytest_requirements())
    result.extend(six_requirements())
    return result
Beispiel #4
0
def test_requirements():
    """
    Return test requirements for the 'test' command or an error string.

    An error is reported if the requirements can not be satisfied for some
    reason.

    Exact required packages and their versions vary depending on our target
    Python environment version as pytest dropped backward compatibility support
    for some of the Python versions we still support in this project.

    """
    if not using_setuptools:
        return "test command not available without setuptools"

    include_pytest_requirements = True

    if sys.version_info < (2, 5):
        # pytest requirements can not be installed automatically by this setup
        # script under Python 2.4.x environment. Specific pytest & py library
        # package version combination that we found working in Python 2.4.x
        # environments does not formally satisfy pytest requirements, and we
        # found no way to make setuptools' test command succeed when this
        # script installs packages that do not have all their formal
        # requirements satisfied.
        have_pytest, have_py = check_Python24_pytest_requirements()
        if not have_pytest:
            return "compatible preinstalled pytest needed prior to Python 2.5"
        if not have_py:
            return "compatible preinstalled py needed prior to Python 2.5"

        # We must not explicitly specify pytest requirements when running the
        # tests using a Python 2.4.x environment as the only way we found we
        # can run our tests there is to use formally incompatible pytest & py
        # packages. Explicitly specifying pytest requirements here would then
        # cause setuptols to verify those requirements prior to running our
        # test suite.
        include_pytest_requirements = False

    if ((3,) <= sys.version_info < (3, 2, 3)):
        # Python 3.x versions prior to Python 3.2.3 have a bug in their inspect
        # module causing inspect.getmodule() calls to fail if some module lazy
        # loads other modules when some of its attributes are accessed. For
        # more detailed information see Python development issue #13487
        # (http://bugs.python.org/issue13487).
        #
        # This occurs when using setuptools to install our project into a
        # Python 3.1 environment. There the py.error module seems to do such
        # lazy loading. Forcing that module to be loaded here, before the
        # setuptools installation procedure, avoids the issue.
        try:
            import py.error
            py.error.__attribute_access_to_force_this_module_to_lazy_load__
        except (AttributeError, ImportError):
            pass

    # When using Python 2.5 on Windows, if setuptools chooses to install the
    # colorama package (pytest requirement on Windows) older than version
    # 0.1.11, running our 'setup.py test' command may show benign error
    # messages caused by some colorama atexit handlers getting triggered
    # multiple times. There are no adverse effects to this and the issue only
    # occurs if the package is not already installed and it is the 'setup.py
    # test' command that is installing it. The issue has been fixed by the next
    # Python 2.5 compatible colorama 0.3.2 release.
    result = []
    if include_pytest_requirements:
        result.extend(pytest_requirements())
    result.extend(six_requirements())
    return result