1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00
Commit graph

27 commits

Author SHA1 Message Date
Ed Morley 4bc0395a53 Correct the suggested package hash lines for URL requirements
When require hashes mode is enabled, if any packages defined in the
requirements file are missing a hash, installation fails with a message
suggesting the appropriate lines that should be copied into the
requirements file.

This worked fine for requirement specifiers such as `requests==2.9.1`,
however for packages specified by URL, the resultant output did not
match that originally in the requirements file.

For example a requirements file containing:
```
--require-hashes
https://github.com/benoitc/gunicorn/archive/19.4.5.zip
https://github.com/kennethreitz/requests/archive/v2.9.1.zip#egg=requests==2.9.1
```

Would result in:
```
Hashes are required in ...
    unknown package --hash=sha256:399347c0a7272fb70b45d5840027c372f...
    requests==2.9.1 --hash=sha256:89839b1698243e232780d1fc808ae8730...
```

Now the original URL line is correctly shown:
```
Hashes are required in ...
    https://github.com/benoitc/gunicorn/archive/19.4.5.zip --hash=...
    https://github.com/kennethreitz/requests/archive/v2.9.1.zip#egg=requests==2.9.1 --hash=...
```

Fixes #3362.
2016-03-04 10:46:40 +00:00
Erik Rose e23f59673e Consolidate hash constants in pip.utils.hashing. 2015-10-12 16:29:08 -04:00
Erik Rose 05b7ef9467 Rename "goods" to "allowed" for clarity.
Renaming "gots" didn't go well. I think the current naming is the most concise way to put it. If we rename it to "got", then the loop iterator can't be called "got", and the simple relationship between the iterator and collection names is lost. "Actual" and "actuals" are the other names that occurred to me, but they look so much like "allowed" that the code becomes harder to read.
2015-10-11 09:17:27 -04:00
Erik Rose 304c90aa46 Break after initial """ in multi-paragraph docstrings in exceptions module. 2015-10-10 22:44:13 -04:00
Erik Rose 0e6058bc63 Change head() method to an attr in hashing exceptions. Tweak English.
Standardize on present tense, improve flow, and clarify.
2015-10-10 22:44:12 -04:00
Erik Rose 910b82c59d --require-hashes no longer implies --no-deps.
For dependencies that are properly pinned and hashed (not really dependencies at all, if you like, since they're explicit, root-level requirements), we install them as normal. For ones that are not pinned and hashes, we raise the errors typical of any unhashed requirement in --require-hashes mode.

Since the stanza under "if not ignore_dependencies" doesn't actually add anything if it's already in the RequirementSet, not much has to be done in the way of code: the unhashed deps don't have any hashes, so we complain about them as per usual.

Also...
* Revise wording of HashUnpinned errors. They can be raised even if no hash is specified, so the previous wording was misleading.
* Make wording of HashMissing less awkward.
2015-09-25 19:07:20 -04:00
Erik Rose 0c17248998 Pass PEP 8 checks. 2015-09-24 22:16:00 -04:00
Erik Rose 11dbb92440 Switch from --sha256 etc. to a single option: --hash.
Everybody seems to favor this. Spelled -H, it's still pretty short. And it is less unusual programmatically.
2015-09-24 22:16:00 -04:00
Erik Rose 1e41f01823 Add checks against requirements-file-dwelling hashes for most kinds of packages. Close #1175.
* Add --require-hashes option. This is handy in deployment scripts to force application authors to hash their requirements. It is also a convenient way to get pip to show computed hashes for a virgin, unhashed requirements file. Eventually, additions to `pip freeze` should fill a superset of this use case.
  * In --require-hashes mode, at least one hash is required to match for each requirement.
  * Option-based requirements (--sha256=...) turn on --require-hashes mode implicitly.
  * Internet-derived URL-based hashes are "necessary but not sufficient": they do not satisfy --require-hashes mode when they match, but they are still used to guard against transmission errors.
  * Other URL-based requirements (#md5=...) are treated just like flag-based ones, except they don't turn on --require-hashes.
* Complain informatively, with the most devastating errors first so you don't chase your tail all day only to run up against a brick wall at the end. This also means we don't complain that a hash is missing, only for the user to find, after fixing it, that we have no idea how to even compute a hash for that type of requirement.
  * Complain about unpinned requirements when hash-checking mode is on, lest they cause the user surprise later.
  * Complain about missing hashes.
  * Complain about requirement types we don't know how to hash (like VCS ones and local dirs).
* Have InstallRequirement keep its original Link around (original_link) so we can differentiate between URL hashes from requirements files and ones downloaded from the (untrustworthy) internet.
* Remove test_download_hashes, which is obsolete. Similar coverage is provided in test_utils.TestHashes and the various hash cases in test_req.py.
2015-09-24 22:16:00 -04:00
Marcus Smith 7c83f8d3cd 1) parse with defaults set as they are naturally (vs forcing to None)
and adjust the logic to match; the result is simpler.
2) Due to #1, we can remove some hairy "format_control" hacks
3) Due to #1, we have to relax the parsing and allow:
   - multiple options per line
   - any supported option on a line with a requirement (not just
     --install-option/--global-option, although they are the only
     options that are passed into a requirement)
2015-04-24 22:32:26 -07:00
Marcus Smith 55e7bd3daa handle requirement specifiers with spaces, e.g. "pkg >= 1" 2015-04-23 01:31:48 -07:00
Marcus Smith 0a265de087 make the requirements file exceptions "InstallationError"'s so they
don't error with tracebacks
2015-04-18 13:06:42 -07:00
Marcus Smith 764e468f42 refactor the requirements file parsing
two major changes:

1) re-use the optparse options in pip.cmdoptions instead of maintaining
   a custom parser

2) as a result of #1, simplify the call stack
    from:  parse_requirements -> parse_content -> parse_line
      to:  parse_requirements -> process_line

beyond #1/#2, minor cosmetics and adjusting the tests to match
2015-04-16 22:10:46 -07:00
Georgi Valkov b014668b30 Add --install-options and --global-options to the requirements file parser
This allows lines such as the following to exist in requirements files:

  INITools==0.2 --install-options="--prefix=/opt"
  virtualenv>=1 --global-options="--no-user-cfg"

In addition, the requirements file parser was overhauled with simplicity
and clarity in mind.
2015-04-12 23:52:49 +02:00
Donald Stufft 767d11e49c Switch to using the stdlib logger instead of pip.log 2014-09-10 09:36:09 -04:00
Marcus Smith 3dc40cad46 - if installing directly from a wheel, fail if it has an invalid name or is unsupported
- when walking links, skip invalid wheel filenames, don't crash
2013-11-14 16:35:24 -08:00
Carl Meyer 388d1b53a7 Refactor unpack_http_url. 2013-05-30 16:59:57 -06:00
Marcus Smith 2c14940a6f deal with pre-existing build dirs 2013-04-20 11:24:43 -07:00
Marcus Smith 6e2bfe8323 remove python 2.5 logic 2013-04-17 22:50:22 -07:00
Marcus Smith 889e1a02b8 custom NoSSLError exception instead of util function 2013-02-18 13:17:54 -08:00
Georgi Valkov fb38f4709a All pip exceptions inherit from PipError 2012-03-02 01:51:13 +02:00
Paul Nasrat 35027f278b Fix pep8 CI build.
Tested locally:
=====================================================
================== Running pep8 =====================

Searching for pep8
Reading http://pypi.python.org/simple/pep8/
Reading http://github.com/cburroughs/pep8.py/tree/master
Reading http://github.com/jcrocholl/pep8
Best match: pep8 0.6.1
Processing pep8-0.6.1-py2.7.egg
pep8 0.6.1 is already the active version in easy-install.pth
Installing pep8 script to
/Users/pnasrat/Development/pip/pip_virtualenv/bin

Using
/Users/pnasrat/Development/pip/pip_virtualenv/lib/python2.7/site-packages/pep8-0.6.1-py2.7.egg
Processing dependencies for pep8
Finished processing dependencies for pep8

==================== Ended pep8 =====================
=====================================================
2012-01-30 06:26:12 +00:00
Erik Bray 1ecda0db16 Fix --upgrade to leave already up-to-date packages alone. Add --force-reinstall to force reinstallation even of up-to-date packages, as was the prior behavior. 2011-08-24 14:07:16 -04:00
Paul Nasrat 09bba5b4aa Fix pep8 2011-08-04 16:09:38 +01:00
Alex Morega a58839e194 "search" command reports error via exception 2011-07-20 22:14:56 +03:00
Hugo Lopes Tavares d06c98dc6f merged changes related to PEP 8 from hltbra's fork 2010-06-02 23:25:26 -03:00
Ian Bicking 47d9c03c06 Extracted the Command class (and helpers); fix -E now that pip is a package; extracted some virtualenv stuff; extracted exceptions; tweak tests 2009-11-20 02:47:28 -06:00