diff --git a/.appveyor.yml b/.appveyor.yml index 500c71320..e7e9c80f9 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -14,14 +14,11 @@ install: # Prepend Python installation and scripts (e.g. pytest) to PATH - set PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH% - # We need to install the python-can library itself including the dependencies - - "python -m pip install .[test,neovi]" + # Install tox + - "pip install tox" build: off test_script: # run tests - - "pytest" - - # uplad coverage reports - - "codecov -X gcov" + - "tox -e appveyor" diff --git a/.travis.yml b/.travis.yml index 76195ce51..3b674f371 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,19 +21,14 @@ env: install: - if [[ "$TEST_SOCKETCAN" ]]; then sudo bash test/open_vcan.sh ; fi - - travis_retry pip install .[test] + - python setup.py install script: - | + # install tox + pip install tox # Run the tests - python setup.py test - # preserve the error code - RETURN_CODE=$? - # Upload the coverage to codecov.io - codecov -X gcov - # set error code - (exit $RETURN_CODE); - + tox -e travis jobs: allow_failures: diff --git a/doc/development.rst b/doc/development.rst index 8bad5c58e..0e3cc5c2c 100644 --- a/doc/development.rst +++ b/doc/development.rst @@ -22,14 +22,30 @@ Building & Installing The following assumes that the commands are executed from the root of the repository: -- The project can be built and installed with ``python setup.py build`` and - ``python setup.py install``. -- The unit tests can be run with ``python setup.py test``. The tests can be run with ``python2``, - ``python3``, ``pypy`` or ``pypy3`` to test with other python versions, if they are installed. - Maybe, you need to execute ``pip3 install python-can[test]`` (or only ``pip`` for Python 2), - if some dependencies are missing. -- The docs can be built with ``sphinx-build doc/ doc/_build``. Appending ``-n`` to the command - makes Sphinx complain about more subtle problems. +The project can be built with:: + + pip install wheel + python setup.py sdist bdist_wheel + +The project can be installed in editable mode with:: + + pip install -e . + +The unit tests can be run with:: + + pip install tox + tox + +The documentation can be built with:: + + pip install -r doc/doc-requirements.txt + python -m sphinx -an doc build + +The linters can be run with:: + + pip install -r requirements-lint.txt + pylint --rcfile=.pylintrc-wip can/**.py + black --check --verbose can Creating a new interface/backend @@ -81,7 +97,7 @@ Creating a new Release - Update `CONTRIBUTORS.txt` with any new contributors. - For larger changes update ``doc/history.rst``. - Sanity check that documentation has stayed inline with code. -- Create a temporary virtual environment. Run ``python setup.py install`` and ``python setup.py test``. +- Create a temporary virtual environment. Run ``python setup.py install`` and ``tox``. - Create and upload the distribution: ``python setup.py sdist bdist_wheel``. - Sign the packages with gpg ``gpg --detach-sign -a dist/python_can-X.Y.Z-py3-none-any.whl``. - Upload with twine ``twine upload dist/python-can-X.Y.Z*``. diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..17d87f033 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,6 @@ +[build-system] +requires = [ + "setuptools >= 40.8", + "wheel", +] +build-backend = "setuptools.build_meta" diff --git a/setup.cfg b/setup.cfg index a0e8d5b6a..498ec14ac 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,25 +1,2 @@ -[aliases] -test=pytest - [metadata] license_file = LICENSE.txt - -[tool:pytest] -addopts = -v --timeout=300 --cov=can --cov-config=setup.cfg - -[coverage:run] -# we could also use branch coverage -branch = False -# already specified by call to pytest using --cov=can -#source = can - -[coverage:report] -# two digits after decimal point -precision = 3 -show_missing = True -exclude_lines = - # Have to re-enable the standard pragma, see https://coverage.readthedocs.io/en/coverage-4.5.1a/config.html#syntax - pragma: no cover - - # Don't complain if non-runnable code isn't run: - if __name__ == .__main__.: diff --git a/setup.py b/setup.py index 8327b1432..6499aad8b 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,6 @@ from os.path import isfile, join import re import logging -import sys from setuptools import setup, find_packages logging.basicConfig(level=logging.WARNING) @@ -29,30 +28,9 @@ extras_require = { "seeedstudio": ["pyserial>=3.0"], "serial": ["pyserial~=3.0"], - "neovi": ["python-ics>=2.12", "filelock"], + "neovi": ["python-ics>=2.12"], } -tests_require = [ - "pytest~=5.3", - "pytest-timeout~=1.3", - "pytest-cov~=2.8", - # coveragepy==5.0 fails with `Safety level may not be changed inside a transaction` - # on python 3.6 on MACOS - "coverage<5", - "codecov~=2.0", - "hypothesis~=4.56", -] + extras_require["serial"] - -extras_require["test"] = tests_require - -# Check for 'pytest-runner' only if setup.py was invoked with 'test'. -# This optimizes setup.py for cases when pytest-runner is not needed, -# using the approach that is suggested upstream. -# -# See https://pypi.org/project/pytest-runner/#conditional-requirement -needs_pytest = {"pytest", "test", "ptr"}.intersection(sys.argv) -pytest_runner = ["pytest-runner"] if needs_pytest else [] - setup( # Description name="python-can", @@ -110,7 +88,5 @@ "mypy_extensions >= 0.4.0, < 0.5.0", 'pywin32;platform_system=="Windows"', ], - setup_requires=pytest_runner, extras_require=extras_require, - tests_require=tests_require, ) diff --git a/tox.ini b/tox.ini index 7447ccaf2..e5df520fe 100644 --- a/tox.ini +++ b/tox.ini @@ -1,11 +1,60 @@ [tox] -envlist = py36, py37 [testenv] +deps = + pytest~=5.3 + pytest-timeout~=1.3 + pytest-cov~=2.8 + coverage<5 + codecov~=2.0 + hypothesis~=4.56 + pyserial~=3.0 + commands = - pip install .[test] pytest -passenv = CI + recreate = True -usedevelop = True -sitepackages=False + +[testenv:travis] +passenv = + CI + TRAVIS + TRAVIS_* + TEST_SOCKETCAN + +commands_post = + codecov -X gcov + +[testenv:appveyor] +passenv = + CI + APPVEYOR + APPVEYOR_* + +extras = neovi + +commands_post = + codecov -X gcov + +[pytest] +testpaths = test +addopts = -v --timeout=300 --cov=can --cov-append --cov-report=term + + +[coverage:run] +# we could also use branch coverage +branch = False + +[coverage:report] +# two digits after decimal point +precision = 3 +show_missing = True +exclude_lines = + # Have to re-enable the standard pragma, see https://coverage.readthedocs.io/en/coverage-4.5.1a/config.html#syntax + pragma: no cover + + # Don't complain if non-runnable code isn't run: + if __name__ == .__main__.: + + # Don't complain if tests don't hit defensive assertion code: + raise NotImplementedError