diff --git a/.activate.sh b/.activate.sh deleted file mode 100644 index 2103e5b..0000000 --- a/.activate.sh +++ /dev/null @@ -1,4 +0,0 @@ -export TOP=$PWD -make venv -. venv/bin/activate -pre-commit install diff --git a/.activate.sh b/.activate.sh new file mode 120000 index 0000000..9308d33 --- /dev/null +++ b/.activate.sh @@ -0,0 +1 @@ +venv/bin/activate \ No newline at end of file diff --git a/.deactivate.sh b/.deactivate.sh index 02b27c4..d1898d7 100644 --- a/.deactivate.sh +++ b/.deactivate.sh @@ -1,2 +1 @@ deactivate -unset TOP diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1d2bea5..7629e80 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,6 +13,7 @@ - id: double-quote-string-fixer - id: end-of-file-fixer - id: flake8 + exclude: ^docs/ - repo: git://github.com/asottile/reorder_python_imports sha: 8b583ac1beb0dd0f14c4bceb0a53bb1023cb3dd7 hooks: diff --git a/CI/circle/main b/CI/circle/main index 8243ab7..517bced 100755 --- a/CI/circle/main +++ b/CI/circle/main @@ -15,7 +15,8 @@ lsb_release -a test $CIRCLE_NODE_TOTAL -eq 4 timestamp -sudo apt-get install python2.7-dev python3.4-dev +sudo apt-get update +sudo apt-get install -y python2.7-dev python3.4-dev ### per-node actions timestamp diff --git a/pip_faster.py b/pip_faster.py index b7c45b9..ba9fa9b 100644 --- a/pip_faster.py +++ b/pip_faster.py @@ -71,6 +71,25 @@ def is_local_directory(url): return isdir(url[5:]) +def is_vcs_url(url): + """Test if a URL is a VCS repo. + + >>> is_vcs_url('git+git://git.myproject.org/MyProject#egg=MyProject') + True + >>> is_vcs_url('svn+http://svn.myproject.org/svn/MyProject/trunk@2019#egg=MyProject') + True + >>> is_vcs_url('file:///tmp/') + False + """ + if url is None: + return False + else: + return url.startswith(tuple( + scheme + '+' + for scheme in pipmodule.vcs.vcs + )) + + def optimistic_wheel_search(req, find_links): assert req_is_pinned(req), req @@ -145,7 +164,9 @@ def wheelable(req): # we don't want to permanently cache something we'll edit not req.editable and # people expect `pip install .` to work without bumping the version - not is_local_directory(req.url) + not is_local_directory(req.url) and + # don't cache vcs packages, since the version is often bogus (#156) + not is_vcs_url(req.url) ) diff --git a/pylintrc b/pylintrc index 87c7f8d..ade0822 100644 --- a/pylintrc +++ b/pylintrc @@ -37,8 +37,8 @@ class-rgx=%(const-rgx)s [FORMAT] max-line-length=131 -# TODO: we'd like to hit 250 here -max-module-lines=532 +# TODO: we'd like to hit this +# max-module-lines=250 [TYPECHECK] ignored-classes=pytest,LocalPath,RootLogger diff --git a/tests/functional/get_installed_test.py b/tests/functional/get_installed_test.py index b23abec..bcce4a8 100644 --- a/tests/functional/get_installed_test.py +++ b/tests/functional/get_installed_test.py @@ -52,7 +52,7 @@ def test_pip_get_installed(tmpdir): run('myvenv/bin/pip', 'uninstall', '--yes', 'cov-core', 'coverage', 'py', 'pytest', 'pytest-cov') assert get_installed() == [] - run('myvenv/bin/pip', 'install', 'flake8') + run('myvenv/bin/pip', 'install', 'flake8==2.5.0') assert get_installed() == ['flake8', 'mccabe', 'pep8', 'pyflakes'] run('myvenv/bin/pip', 'uninstall', '--yes', 'flake8') diff --git a/tests/functional/pip_faster.py b/tests/functional/pip_faster.py index edf7adf..b7b4801 100644 --- a/tests/functional/pip_faster.py +++ b/tests/functional/pip_faster.py @@ -32,7 +32,7 @@ def it_installs_stuff(tmpdir): install_coverage(venv) assert pip_freeze(str(venv)) == '''\ -coverage==4.0.3 +coverage==4.2 coverage-enable-subprocess==1.0 ''' @@ -89,7 +89,7 @@ def it_installs_stuff_with_dash_e_without_wheeling(tmpdir): assert set(frozen_requirements) == set([ '-e git://github.com/Yelp/dumb-init.git@87545be699a13d0fd31f67199b7782ebd446437e#egg=dumb_init-dev', # noqa 'coverage-enable-subprocess==1.0', - 'coverage==4.0.3', + 'coverage==4.2', 'venv-update==' + __version__, 'wheel==0.29.0', '', @@ -117,7 +117,7 @@ def it_doesnt_wheel_local_dirs(tmpdir): frozen_requirements = pip_freeze(str(venv)).split('\n') assert set(frozen_requirements) == set([ - 'coverage==4.0.3', + 'coverage==4.2', 'coverage-enable-subprocess==1.0', 'dependant-package==1', 'implicit-dependency==1', @@ -136,6 +136,34 @@ def it_doesnt_wheel_local_dirs(tmpdir): ]) +@pytest.mark.usefixtures('pypi_server') +def it_doesnt_wheel_git_repos(tmpdir): + venv = tmpdir.join('venv') + install_coverage(venv) + + pip = venv.join('bin/pip').strpath + run(pip, 'install', 'venv-update==' + __version__) + + run( + venv.join('bin/pip-faster').strpath, + 'install', + 'git+git://github.com/Yelp/dumb-init.git@87545be699a13d0fd31f67199b7782ebd446437e#egg=dumb-init', # noqa + ) + + frozen_requirements = pip_freeze(str(venv)).split('\n') + assert set(frozen_requirements) == set([ + 'coverage-enable-subprocess==1.0', + 'coverage==4.2', + 'dumb-init==0.5.0', + 'venv-update==' + __version__, + 'wheel==0.29.0', + '', + ]) + + wheelhouse = tmpdir.join('home', '.cache', 'pip-faster', 'wheelhouse') + assert set(Wheel(f.basename).name for f in wheelhouse.listdir()) == set() + + @pytest.mark.usefixtures('pypi_server') def it_can_handle_requirements_already_met(tmpdir): venv = tmpdir.join('venv') diff --git a/tests/functional/simple_test.py b/tests/functional/simple_test.py index 30a7fbc..3a0529a 100644 --- a/tests/functional/simple_test.py +++ b/tests/functional/simple_test.py @@ -280,7 +280,7 @@ def flake8_older(): ''' % TOP) venv_update() assert pip_freeze() == '\n'.join(( - 'coverage==4.0.3', + 'coverage==4.2', 'coverage-enable-subprocess==1.0', 'flake8==2.0', 'mccabe==0.3', @@ -306,7 +306,7 @@ def flake8_newer(): ''' % TOP) venv_update() assert pip_freeze() == '\n'.join(( - 'coverage==4.0.3', + 'coverage==4.2', 'coverage-enable-subprocess==1.0', 'flake8==2.2.5', 'mccabe==0.3', diff --git a/tests/unit/fix_coverage_test.py b/tests/unit/fix_coverage_test.py index 520b19d..5de47b5 100644 --- a/tests/unit/fix_coverage_test.py +++ b/tests/unit/fix_coverage_test.py @@ -22,16 +22,16 @@ def test_fix_coverage(tmpdir): str(unrelated_file): {(5, 6): None}, }) - assert coverage_data.lines(base_file) == [1] - assert coverage_data.lines(sub_file) == [3] - assert coverage_data.lines(unrelated_file) == [5] + assert coverage_data.lines(base_file) == [1, 2] + assert coverage_data.lines(sub_file) == [3, 4] + assert coverage_data.lines(unrelated_file) == [5, 6] merge_coverage(coverage_data, '/site-packages/', str(tmpdir)) # The base file should contain all the lines and arcs - assert coverage_data.lines(base_file) == [1, 3] + assert coverage_data.lines(base_file) == [1, 2, 3, 4] assert coverage_data.arcs(base_file) == [(1, 2), (3, 4)] - assert coverage_data.lines(unrelated_file) == [5] + assert coverage_data.lines(unrelated_file) == [5, 6] assert coverage_data.arcs(unrelated_file) == [(5, 6)] # And the sub file should no longer exist diff --git a/tox.ini b/tox.ini index 477049f..82e589f 100644 --- a/tox.ini +++ b/tox.ini @@ -8,9 +8,9 @@ skipsdist=True passenv = PYTEST_OPTIONS PYTHON -changedir = +changedir = {envtmpdir} -setenv = +setenv = TOP={toxinidir} SITEPACKAGES={envsitepackagesdir} venv_update = @@ -33,3 +33,6 @@ commands = deps = -rrequirements.d/docs.txt changedir = docs commands = sphinx-build -b html -d build/doctrees source build/html + +[flake8] +max-line-length = 131 diff --git a/venv_update.py b/venv_update.py index 19dafeb..b426e6e 100755 --- a/venv_update.py +++ b/venv_update.py @@ -58,7 +58,7 @@ from os.path import exists from os.path import join -__version__ = '1.1.0' +__version__ = '1.1.1' DEFAULT_VIRTUALENV_PATH = 'venv' DEFAULT_OPTION_VALUES = { 'venv=': (DEFAULT_VIRTUALENV_PATH,), @@ -163,7 +163,7 @@ def exec_(argv): # never returns """Wrapper to os.execv which shows the command and runs any atexit handlers (for coverage's sake). Like os.execv, this function never returns. """ - ## info('EXEC' + colorize(argv)) # TODO: debug logging by environment variable + # info('EXEC' + colorize(argv)) # TODO: debug logging by environment variable # in python3, sys.exitfunc has gone away, and atexit._run_exitfuncs seems to be the only pubic-ish interface # https://hg.python.org/cpython/file/3.4/Modules/atexitmodule.c#l289