From dbd784b870a878ef6dbecd14310018cdaeda5c6d Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Fri, 25 Jul 2014 10:54:44 +0200 Subject: [PATCH 1/3] List runtime dependencies in requirements.txt More and more packages are listing their dependencies in requirements.txt which make it trivial to maintain and install them. --- MANIFEST.in | 1 + README.md | 10 +++++++--- requirements.txt | 2 ++ setup.py | 4 +++- 4 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 requirements.txt diff --git a/MANIFEST.in b/MANIFEST.in index 89f5b92d0..95b2e883f 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -3,6 +3,7 @@ include LICENSE include CHANGES include AUTHORS include README +include requirements.txt graft git/test/fixtures graft git/test/performance diff --git a/README.md b/README.md index d2a858bf9..0b5f5a2a0 100644 --- a/README.md +++ b/README.md @@ -14,16 +14,20 @@ The object database implementation is optimized for handling large quantities of * Mock by Michael Foord used for tests - Tested with 1.0.1 +The list of dependencies are listed in /requirements.txt. The installer takes care of installing them for you though. + ### INSTALL If you have downloaded the source code: python setup.py install - -or if you want to obtain a copy more easily: + +or if you want to obtain a copy from the Pypi repository: pip install gitpython - + +Both commands will install the required package dependencies. + A distribution package can be obtained for manual installation at: http://pypi.python.org/pypi/GitPython diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000..67f5eb742 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +# Remember to update README.md +gitdb>=0.5.1 diff --git a/setup.py b/setup.py index e7c927b13..58a763e49 100644 --- a/setup.py +++ b/setup.py @@ -16,6 +16,8 @@ VERSION = v.readline().strip() v.close() +with open('requirements.txt') as reqs_file: + requirements = reqs_file.read().splitlines() class build_py(_build_py): def run(self): @@ -73,7 +75,7 @@ def _stamp_version(filename): package_data = {'git.test' : ['fixtures/*']}, package_dir = {'git':'git'}, license = "BSD License", - install_requires='gitdb >= 0.5.1', + install_requires=requirements, zip_safe=False, long_description = """\ GitPython is a python library used to interact with Git repositories""", From 2ddd5e5ef89da7f1e3b3a7d081fbc7f5c46ac11c Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Fri, 25 Jul 2014 11:01:30 +0200 Subject: [PATCH 2/3] Use tox to easily run tests in venv tox https://pypi.python.org/pypi/tox is a thin wrapper around virtualenv which let you craft a fresh python environement to execute command in. It creates the env with virtualenv, install dependencies, run python setup.py install in it and then execute whatever command you want it to do and report status. To do so I simply: - listed tests dependencies in test-requirements.txt (which are just nose and mock) - provide a tox.ini file which describe how to install the dependencies and execute nosetests - added the module 'coverage' to the list of test dependencies To run tests simply: pip install tox && tox That will execute the test command 'nosetests' using python2.6 and then python 2.7. The additional env 'cover' can be run using: tox -ecover. --- .gitignore | 3 +++ README.md | 13 ++++++++++++- test-requirements.txt | 4 ++++ tox.ini | 13 +++++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 test-requirements.txt create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore index 1a26c03a1..f6f85969d 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,6 @@ cover/ /doc/_build nbproject *.sublime-workspace + +/*egg-info +/.tox diff --git a/README.md b/README.md index 0b5f5a2a0..fcf74c3d6 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,9 @@ The object database implementation is optimized for handling large quantities of - Tested with nose 1.3.0 * Mock by Michael Foord used for tests - Tested with 1.0.1 +* Coverage - used for tests coverage -The list of dependencies are listed in /requirements.txt. The installer takes care of installing them for you though. +The list of dependencies are listed in /requirements.txt and /test-requirements.txt. The installer takes care of installing them for you though. ### INSTALL @@ -32,6 +33,16 @@ A distribution package can be obtained for manual installation at: http://pypi.python.org/pypi/GitPython +### RUNNING TESTS + +The easiest way to run test is by using [tox](https://pypi.python.org/pypi/tox) a wrapper around virtualenv. It will take care of setting up environnements with the proper dependencies installed and execute test commands. To install it simply: + + pip install tox + +Then run: + + tox + ### DEVELOPMENT STATUS [![Build Status](https://travis-ci.org/gitpython-developers/GitPython.svg?branch=0.3)](https://travis-ci.org/gitpython-developers/GitPython) diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 000000000..6da60814c --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,4 @@ +# Remember to update README.md +coverage +nose +mock diff --git a/tox.ini b/tox.ini new file mode 100644 index 000000000..a89b13482 --- /dev/null +++ b/tox.ini @@ -0,0 +1,13 @@ +[tox] +envlist = py26,py27 + +[testenv] +commands = nosetests +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt + +[testenv:cover] +commands = nosetests --with-coverage + +[testenv:venv] +commands = {posargs} From d43055d44e58e8f010a71ec974c6a26f091a0b7a Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Fri, 25 Jul 2014 11:10:52 +0200 Subject: [PATCH 3/3] tox env to easily run flake8 Most people know about pep8 which enforce coding style. pyflakes goes a step beyond by analyzing the code. flake8 is basically a wrapper around both pep8 and pyflakes and comes with some additional checks. I find it very useful since you only need to require one package to have a lot of code issues reported to you. This patch provides a 'flake8' tox environement to easily install and run the utility on the code base. One simply has to: tox -eflake8 The env has been added to the default list of environement to have flake8 run by default. The repository in its current state does not pass checks but I noticed a pull request fixing pep8 issues. We can later easily ensure there is no regression by adjusting Travis configuration to run this env. More informations about flake8: https://pypi.python.org/pypi/flake8 --- test-requirements.txt | 1 + tox.ini | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/test-requirements.txt b/test-requirements.txt index 6da60814c..116fbbd38 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,4 +1,5 @@ # Remember to update README.md coverage +flake8 nose mock diff --git a/tox.ini b/tox.ini index a89b13482..60bfb1d97 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py26,py27 +envlist = py26,py27,flake8 [testenv] commands = nosetests @@ -9,5 +9,12 @@ deps = -r{toxinidir}/requirements.txt [testenv:cover] commands = nosetests --with-coverage +[testenv:flake8] +commands = flake8 + [testenv:venv] commands = {posargs} + +[flake8] +#show-source = True +exclude = .tox,.venv,build,dist,doc,git/ext/