diff --git a/setup.py b/setup.py index 9aa66e5..46ac1a1 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,31 @@ from setuptools import setup from gitubuntu.version import VERSION -setup(name='gitubuntu', +import os +import sys + +sys.stderr.write("===================================\n") +sys.stderr.write("HERE HERE: %s\n" % sys.argv) +install_requires = [ + 'argcomplete==1.8.1', + 'python-debian==0.1.31', + 'launchpadlib==1.10.6', + 'petname', + 'setuptools', + 'keyring<16', # https://github.com/jaraco/keyrings.alt/issues/28 + 'keyrings.alt', + 'lazr.restfulclient==0.14.0', + 'pytest==3.1.3', + 'pytest-cov==2.5.1', +] + +if not os.environ.get('TOX_TOP_DIR'): + # pygit2 is troublesome for tox. Requires compilation and also + # specific versions of libgit2-dev. + install_requires.append('pygit2==0.24.2') + +setup( + name='gitubuntu', version=VERSION, packages=['gitubuntu'], entry_points={ @@ -10,17 +34,5 @@ setup(name='gitubuntu', ], }, include_package_data=True, - install_requires=[ - 'argcomplete==1.8.1', - 'python-debian==0.1.31', - 'pygit2==0.24.2', - 'launchpadlib==1.10.6', - 'petname', - 'setuptools', - 'keyring<16', # https://github.com/jaraco/keyrings.alt/issues/28 - 'keyrings.alt', - 'lazr.restfulclient==0.14.0', - 'pytest==3.1.3', - 'pytest-cov==2.5.1', - ] + install_requires=install_requires, ) diff --git a/snap-wrappers/wrappers/git-ubuntu-self-test b/snap-wrappers/wrappers/git-ubuntu-self-test index f57cde7..e354123 100755 --- a/snap-wrappers/wrappers/git-ubuntu-self-test +++ b/snap-wrappers/wrappers/git-ubuntu-self-test @@ -1,6 +1,24 @@ #!/snap/core/current/bin/bash -python3 -m pylint --ignored-modules=pygit2 -E $SNAP/lib/python3.6/site-packages/gitubuntu/ +if [ -n "$SNAP" ]; then + git_ubuntu_d="$SNAP/lib/python3.6/site-packages/gitubuntu" + pylint_ignore=( "--ignored-modules=pygit2" ) +elif [ -n "$TOX_TOP_DIR" ]; then + git_ubuntu_d="$TOX_TOP_DIR/gitubuntu" + # distro_info is not installable via pip, so ignore in tox environment. + pylint_ignore=( "--ignored-modules=pygit2,distro_info" ) +else + echo "Error, unexpected environment. no TOX_TOP_DIR or SNAP" 1>&2 + exit 3 +fi + +pylint_cmd=( + python3 -m pylint --errors-only + "${pylint_ignore[@]}" "${git_ubuntu_d}/" +) + +echo "running" "${pylint_cmd[@]}" +"${pylint_cmd[@]}" PYLINT_RC=$? if [ $PYLINT_RC == 0 ]; then @@ -8,7 +26,15 @@ if [ $PYLINT_RC == 0 ]; then fi TMPFILE=$(mktemp) -COVERAGE_FILE=$TMPFILE python3 -m pytest -p no:cacheprovider --cov=$SNAP/lib/python3.6/site-packages/gitubuntu $SNAP/lib/python3.6/site-packages/gitubuntu/* +pytest_cmd=( + env COVERAGE_FILE=$TMPFILE python3 -m pytest + -p no:cacheprovider + "--cov=gitubuntu" + "${git_ubuntu_d}/" +) + +echo "running" "${pytest_cmd[@]}" +"${pytest_cmd[@]}" PYTEST_RC=$? unlink $TMPFILE @@ -17,4 +43,3 @@ if [ $PYTEST_RC == 0 ]; then fi [[ $PYLINT_RC == 0 && $PYTEST_RC == 0 ]] - diff --git a/tox.ini b/tox.ini index 8524e0e..34e6eac 100644 --- a/tox.ini +++ b/tox.ini @@ -1,8 +1,11 @@ [tox] envlist = pylint -skipsdist = true basepython = python3 +use_develop = True [testenv:pylint] +setenv = + TOX_TOP_DIR = {toxinidir} deps = pylint==1.7.2 -commands = pylint -E gitubuntu/ +commands = /bin/bash +#commands = {posargs:{toxinidir}/snap-wrappers/wrappers/git-ubuntu-self-test}