Skip to content

Commit 1acdb57

Browse files
committed
Merge branch 'release/0.5.3'
2 parents 6e5920f + 6e42869 commit 1acdb57

File tree

7 files changed

+142
-111
lines changed

7 files changed

+142
-111
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ branches:
99
except:
1010
- piptools-ignore-patch
1111
install:
12+
- "pip install setuptools"
1213
- "pip install cram"
1314
- "pip install ."
1415
script:

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ Any kind of contribution is welcome; nothing is "off limits". However, for those
1515

1616
This repo ([jgonggrijp/pip-review](https://github.com/jgonggrijp/pip-review)) uses [gitflow](https://github.com/nvie/gitflow). Please submit pull requests to the `develop` branch.
1717

18-
The Python files (currently only `pip_review.py`) use 4-space soft tabs. The other files use 2-space soft tabs.
18+
The Python files use 4-space soft tabs. The other files use 2-space soft tabs.

README.md

Lines changed: 0 additions & 90 deletions
This file was deleted.

README.rst

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
.. image:: https://travis-ci.org/jgonggrijp/pip-review.svg?branch=master
2+
:alt: Build status
3+
:target: https://secure.travis-ci.org/jgonggrijp/pip-review
4+
5+
pip-review
6+
==========
7+
8+
``pip-review`` checks PyPI and reports available updates. It uses the list of
9+
currently installed packages to check for updates, it does not use any
10+
``requirements.txt``.
11+
12+
Example, report-only:
13+
14+
.. code:: console
15+
16+
$ pip-review
17+
requests==0.13.4 available (you have 0.13.2)
18+
redis==2.4.13 available (you have 2.4.9)
19+
rq==0.3.2 available (you have 0.3.0)
20+
21+
Example, actually install everything:
22+
23+
.. code:: console
24+
25+
$ pip-review --auto
26+
... <pip install output>
27+
28+
Example, run interactively, ask to upgrade for each package:
29+
30+
.. code:: console
31+
32+
$ pip-review --interactive
33+
requests==0.14.0 available (you have 0.13.2)
34+
Upgrade now? [Y]es, [N]o, [A]ll, [Q]uit y
35+
...
36+
redis==2.6.2 available (you have 2.4.9)
37+
Upgrade now? [Y]es, [N]o, [A]ll, [Q]uit n
38+
rq==0.3.2 available (you have 0.3.0)
39+
Upgrade now? [Y]es, [N]o, [A]ll, [Q]uit y
40+
...
41+
42+
Up until version 0.3.7, ``pip-review`` would show and install any available
43+
update including pre-release versions. As of version 0.4, it will only show and
44+
install release versions by default. To restore the original behaviour, use the
45+
``--pre`` flag.
46+
47+
Since version 0.5, you can also invoke pip-review as ``python -m pip_review``. **This is the only way to invoke pip-review that enables it to update itself.**
48+
49+
50+
Installation
51+
============
52+
53+
To install, simply use pip:
54+
55+
.. code:: console
56+
57+
$ pip install pip-review
58+
59+
Decide for yourself whether you want to install the tool system-wide, or
60+
inside a virtual env. Both are supported.
61+
62+
63+
Testing
64+
=======
65+
66+
To test with your active Python version:
67+
68+
.. code:: console
69+
70+
$ ./run-tests.sh
71+
72+
To test under all (supported) Python versions:
73+
74+
.. code:: console
75+
76+
$ tox
77+
78+
The tests run quite slow, since they actually interact with PyPI, which
79+
involves downloading packages, etc. So please be patient.
80+
81+
82+
Origins
83+
=======
84+
85+
``pip-review`` was originally part of pip-tools_ but
86+
has been discontinued_ as such. See `Pin Your Packages`_ by Vincent
87+
Driessen for the original introduction. Since there are still use cases, the
88+
tool now lives on as a separate package.
89+
90+
91+
.. _pip-tools: https://github.com/nvie/pip-tools/
92+
.. _discontinued: https://github.com/nvie/pip-tools/issues/185
93+
.. _Pin Your Packages: http://nvie.com/posts/pin-your-packages/
94+
.. _cram: https://bitheap.org/cram/

pip_review/__main__.py

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/usr/bin/env python
21
from __future__ import absolute_import
32
import os
43
import re
@@ -8,6 +7,7 @@
87
import sys
98
import json
109
import pip
10+
import subprocess
1111
try:
1212
import urllib2 as urllib_request # Python2
1313
except ImportError:
@@ -40,11 +40,32 @@ def _check_output(*args, **kwargs):
4040

4141
from packaging import version as packaging_version
4242

43+
SELFUPDATE_NOTICE = '''
44+
For selfupdate, run python -m pip_review (for Python 2.6, use
45+
pip_review.__main__).
46+
'''
47+
48+
DEPRECATED_NOTICE = '''
49+
Support for Python 2.6 and Python 3.2 has been deprecated. From
50+
version 1.0 onwards, pip-review will only support Python==2.7 and
51+
Python>=3.3.
52+
'''
53+
54+
55+
def version_epilog():
56+
"""Version-specific information to be add to the help page."""
57+
if sys.version_info < (2, 7) or (3, 0) <= sys.version_info < (3, 3):
58+
return DEPRECATED_NOTICE
59+
else:
60+
return ''
61+
4362

4463
def parse_args():
64+
description = 'Keeps your Python packages fresh.'
4565
parser = argparse.ArgumentParser(
46-
description='Keeps your Python package dependencies pinned, '
47-
'but fresh.')
66+
description=description,
67+
epilog=SELFUPDATE_NOTICE+version_epilog(),
68+
)
4869
parser.add_argument(
4970
'--verbose', '-v', action='store_true', default=False,
5071
help='Show more output')
@@ -70,6 +91,13 @@ def parse_args():
7091
return parser.parse_args()
7192

7293

94+
def pip_cmd():
95+
if sys.version_info[0] > 2 or sys.version_info[1] > 6:
96+
return [sys.executable, '-m', 'pip']
97+
else:
98+
return ['pip']
99+
100+
73101
def load_pkg_info(pkg_name):
74102
if pkg_name is None:
75103
return
@@ -154,7 +182,7 @@ def get_latest_versions(pkg_names, prerelease=False):
154182

155183
def get_installed_pkgs(local=False):
156184
logger = logging.getLogger(u'pip-review')
157-
command = 'pip freeze'
185+
command = ' '.join(pip_cmd()) + ' freeze'
158186
if packaging_version.parse(pip.__version__) >= packaging_version.parse('8.0.3'):
159187
command += ' --all'
160188
if local:
@@ -230,10 +258,8 @@ def ask(self, prompt):
230258

231259

232260
def update_pkg(pkg, version):
233-
command = 'pip install {0}=={1}'.format(pkg, version)
234-
if pkg=='pip':
235-
command = 'python -m ' + command
236-
os.system(command)
261+
command = pip_cmd() + ['install', '{0}=={1}'.format(pkg, version)]
262+
subprocess.call(command, stdout=sys.stdout, stderr=sys.stderr)
237263

238264

239265
def confirm(question):

setup.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,9 @@
55
from setuptools import setup
66

77

8-
def get_dependencies():
9-
deps = ['packaging', 'pip']
10-
if sys.version_info < (2, 7):
11-
deps += ['argparse']
12-
return deps
13-
14-
158
setup(
169
name='pip-review',
17-
version='0.5.2',
10+
version='0.5.3',
1811
url='https://github.com/jgonggrijp/pip-review',
1912
license='BSD',
2013
author='Vincent Driessen, Julian Gonggrijp',
@@ -31,7 +24,12 @@ def get_dependencies():
3124
#include_package_data=True,
3225
zip_safe=False,
3326
platforms='any',
34-
install_requires=get_dependencies(),
27+
install_requires=[
28+
'packaging',
29+
'pip',
30+
'argparse;python_version<"2.7"',
31+
],
32+
python_requires='>=2.6, !=3.0, !=3.1',
3533
classifiers=[
3634
# As from https://pypi.python.org/pypi?%3Aaction=list_classifiers
3735
#'Development Status :: 1 - Planning',
@@ -46,12 +44,12 @@ def get_dependencies():
4644
#'Programming Language :: Python :: 2.3',
4745
#'Programming Language :: Python :: 2.4',
4846
#'Programming Language :: Python :: 2.5',
49-
'Programming Language :: Python :: 2.6',
47+
#'Programming Language :: Python :: 2.6',
5048
'Programming Language :: Python :: 2.7',
5149
'Programming Language :: Python :: 3',
5250
#'Programming Language :: Python :: 3.0',
5351
#'Programming Language :: Python :: 3.1',
54-
'Programming Language :: Python :: 3.2',
52+
#'Programming Language :: Python :: 3.2',
5553
'Programming Language :: Python :: 3.3',
5654
'Programming Language :: Python :: 3.4',
5755
'Programming Language :: Python :: 3.5',

tests/review.t

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Create a new playground first:
22

3+
$ cd $TESTDIR/..
34
$ pip install virtualenv >/dev/null 2>&1
45
$ virtualenv --python="$(which python)" FOO >/dev/null 2>&1
56
$ PATH=FOO/bin:$PATH
@@ -8,7 +9,7 @@ Create a new playground first:
89
$ pip install packaging >/dev/null 2>&1
910
$ pip install -U --force-reinstall argparse >/dev/null 2>&1
1011
$ pip install -U --force-reinstall wheel >/dev/null 2>&1
11-
$ alias pip-review="$TESTDIR/../pip_review/__main__.py"
12+
$ function pip-review { python -m pip_review.__main__ $* ; }
1213

1314
Setup. Let's pretend we have some outdated package versions installed:
1415

@@ -50,6 +51,7 @@ Next, let's test for regressions with older versions of pip:
5051

5152
$ pip install --force-reinstall --upgrade pip\<6.0 >/dev/null 2>&1
5253
$ if python -c 'import sys; sys.exit(0 if sys.version_info < (3, 6) else 1)'; then
54+
> rm -rf pip_review.egg-info # prevents spurious editable in pip freeze
5355
> pip-review
5456
> else
5557
> echo Skipped

0 commit comments

Comments
 (0)