Skip to content
This repository has been archived by the owner on Mar 20, 2018. It is now read-only.

Commit

Permalink
Dependency checking environment (#124)
Browse files Browse the repository at this point in the history
* Dependency checking environment

Add an tox environment that does static analysis (via pylint) without
install test-requirements.txt; this ensures that the dependencies
specified in setup.py are enough. Previously, the
tests could pass but the package might not build if a necessary
dependency was specified in the test environment but not in the real
package metadata. Remove requirements.txt, which is redundant with
setup.py.

Also, switch to using grpcio-tools to provide protoc
- It is difficult to debug linuxbrew problems on Travis; it's cleaner just
  to install a Python package.
- Note that grpcio-tools does not install properly for pip versions <8.

Also, fix an import for style
- Directly importing the method is inconsistent with the rest
  of this repo.
- The import causes Sphinx to document the method as though it were
  part of `api_callable`, even though it really belongs to a third-
  party library.
  • Loading branch information
geigerj authored Aug 18, 2016
1 parent f0de06e commit e8f6daa
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 47 deletions.
7 changes: 1 addition & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
sudo: false
env:
- BREW_HOME=$HOME/.linuxbrew PATH=$BREW_HOME/bin:$PATH

# Protobuf is very expensive to install, so we cache it between builds
before_install:
- pip install --upgrade pip
- ./install-protobuf3.sh
cache:
directories:
- $BREW_HOME
- pip --version

language: python
python:
Expand Down
4 changes: 2 additions & 2 deletions google/gax/api_callable.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import random
import time

from future.utils import raise_with_traceback
from future import utils

from . import (BackoffSettings, BundleOptions, bundling, CallSettings, config,
PageIterator, ResourceIterator, RetryOptions)
Expand Down Expand Up @@ -430,7 +430,7 @@ def inner(*args, **kwargs):
return a_func(*args, **kwargs)
# pylint: disable=catching-non-exception
except tuple(errors) as exception:
raise_with_traceback(GaxError('RPC failed', cause=exception))
utils.raise_with_traceback(GaxError('RPC failed', cause=exception))

return inner

Expand Down
22 changes: 0 additions & 22 deletions install-protobuf3.sh

This file was deleted.

5 changes: 0 additions & 5 deletions requirements.txt

This file was deleted.

8 changes: 8 additions & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@ pytest>=2.8.3
pytest-cov>=1.8.1
pytest-timeout>=1.0.0
unittest2>=1.1.0

# TODO: remove this line when grpcio goes to 1.0.0. This is only necessary
# because pip (running in Travis CI) will not install the release candidate
# when it gets pulled in as a dependency of grpcio-tools, below, which causes
# build failure in Python 3 environments
grpcio>=1.0.0rc1

grpcio-tools>=1.0.0rc2
22 changes: 10 additions & 12 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
[tox]
envlist = py27,py34,py35,pep8,pylint-errors,pylint-full
envlist = py27,py34,py35,pep8,pylint-errors,pylint-full,pylint-no-test-deps

[tox:travis]
2.7 = py27,pep8,pylint-full,docs
3.4 = py34,pep8,pylint-full
3.5 = py35,pep8,pylint-full
2.7 = py27,pep8,pylint-full,pylint-no-test-deps,docs
3.4 = py34,pep8,pylint-full,pylint-no-test-deps
3.5 = py35,pep8,pylint-full,pylint-no-test-deps

[testenv]
setenv =
PYTHONPATH = {toxinidir}:{toxinidir}/src-gen/test
PYTHONPATH = {toxinidir}:{toxinidir}/src-gen
deps = -r{toxinidir}/test-requirements.txt
-r{toxinidir}/requirements.txt
whitelist_externals = mkdir
protoc
commands = -mkdir src-gen
-{env:BREW_HOME}/bin/protoc --python_out=src-gen test/fixture.proto
-python -m grpc.tools.protoc -Itest --python_out=src-gen test/fixture.proto
-py.test --timeout=30 --cov-report html --cov-report=term --cov {toxinidir}/google

[testenv:pep8]
Expand All @@ -24,17 +23,19 @@ commands = flake8 --max-complexity=10 google test --ignore=E501 --exclude=src-ge
[testenv:pylint-errors]
deps = pylint
-r{toxinidir}/test-requirements.txt
-r{toxinidir}/requirements.txt
commands = pylint -f colorized -E google test --ignore=src-gen

[testenv:pylint-warnings]
deps = pylint
commands = pylint -f colorized -d all -e W -r n google test --ignore=src-gen

[testenv:pylint-no-test-deps]
deps = pylint
commands = pylint -f colorized -e E,W,R -d fixme,locally-disabled google --ignore=src-gen

[testenv:pylint-full]
deps = pylint
-r{toxinidir}/test-requirements.txt
-r{toxinidir}/requirements.txt
commands = pylint -f colorized -e E,W,R -d fixme,locally-disabled google test --ignore=src-gen

[testenv:devenv]
Expand All @@ -43,8 +44,6 @@ envdir = {toxworkdir}/develop
basepython = python2.7
usedevelop = True
deps= -r{toxinidir}/test-requirements.txt
-r{toxinidir}/requirements.txt


[testenv:docs]
basepython = python2.7
Expand All @@ -56,6 +55,5 @@ commands =
sphinx-build -W -b html -d docs/_build/doctrees docs docs/_build/html
sphinx-build -b latex -D language=en -d _build/doctrees docs _build/latex
deps =
-r{toxinidir}/requirements.txt
Sphinx
sphinx_rtd_theme

0 comments on commit e8f6daa

Please sign in to comment.