Skip to content

Commit

Permalink
Merge branch 'pip-tools-integration'
Browse files Browse the repository at this point in the history
This contains the commits that move the pip-tools repository from nvie
to jazzband, so update the "nvie/pip-tools" references to
"jazzband/pip-tools" also in our Change Log.

* pip-tools-integration:
  Revert "Use tox-travis for Travis/Tox integration"
  Revert "Add PyPI deploy using tox-travis' "after all""
  1.8.1rc3
  Remove other instance of req.specifier special case
  1.8.1rc2
  Added integration test to validate resolver reliability
  Remove special casing of pip specifier attribute.
  Update CHANGELOG.md
  Update CHANGELOG.md
  Fallback to sha256 hash on hashes import error
  Rename writer test to better reflect what happens
  Update writer test to lowercase only
  Release candidate 1: bump version
  relaxed package key_from_req normalization.
  Update Travis badge
  Add PyPI deploy using tox-travis' "after all"
  Use tox-travis for Travis/Tox integration
  Update CHANGELOG.md
  Added pep 503 compliance to package normalizing
  Update CHANGELOG.md
  Added environment specification in issue template
  Add the Jazzband badge to the README file
  Fix all links in the docs
  Prep for the move to Jazzband
  Always output lowercase to requirements file
  Remove code that is never executed
  Fix the usage of ireq keys for comparison purposes
  • Loading branch information
suutari-ai committed Mar 5, 2017
2 parents 8c7bb8d + c061c76 commit 860d8c8
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 39 deletions.
7 changes: 7 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
Describe the issue briefly here.

##### Environment Versions

1. OS Type
1. Python version: `$ python -V`
1. pip version: `$ pip --version`
1. pip-tools version: `$ pip-compile --version`

##### Steps to replicate

1. ...
Expand Down
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[![Jazzband](https://jazzband.co/static/img/jazzband.svg)](https://jazzband.co/)

This is a [Jazzband](https://jazzband.co/) project. By contributing you agree
to abide by the [Contributor Code of Conduct](https://jazzband.co/about/conduct)
and follow the [guidelines](https://jazzband.co/about/guidelines).
26 changes: 16 additions & 10 deletions ChangeLog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@ Unreleased
----------

- Rename "prequ compile-all" to "prequ compile"
- (jazzband/pip-tools#427) Fix duplicate entries that could happen in
generated requirements.txt
- (jazzband/pip-tools#457) Gracefully report invalid pip version
- (jazzband/pip-tools#452) Fix capitalization in the generated
requirements.txt, packages will always be lowercased

0.180.9
-------

- (nvie/pip-tools#453) Write relative find-links opts to output file
- (jazzband/pip-tools#453) Write relative find-links opts to output file
- Add "--silent" option for the compile command
- Rename "prequ compile" to "prequ compile-in"
- Use ``requirements.pre`` as input for ``prequ update``
Expand All @@ -19,15 +24,16 @@ Unreleased
0.180.7
-------

- (nvie/pip-tools#450) Fix resolver when toplevel requirements are also
in pinned subdependency
- (jazzband/pip-tools#450) Calculated dependencies could be left with wrong
candidates when toplevel requirements happen to be also pinned in
sub-dependencies
- Convert README and ChangeLog to restructured text (ReST)
- Include README as package long description in setup.py

0.180.6
-------

- (nvie/pip-tools#417) Exclude irrelevant pip constraints
- (jazzband/pip-tools#417) Exclude irrelevant pip constraints

0.180.5
-------
Expand All @@ -48,12 +54,12 @@ Unreleased
0.180.2
-------

- (nvie/pip-tools#378) Recalculate secondary dependencies between rounds
- (nvie/pip-tools#448) Add "--no-trusted-host" option to fix #382
- (nvie/pip-tools#448) Deduplicate the option lines of output
- (nvie/pip-tools#441) Exclude packages required only by unsafe packages
- (nvie/pip-tools#389) Ignore pkg-resources
- (nvie/pip-tools#355) Support non-editable pinned VCS dependencies
- (jazzband/pip-tools#378) Recalculate secondary dependencies between rounds
- (jazzband/pip-tools#448) Add "--no-trusted-host" option to fix #382
- (jazzband/pip-tools#448) Deduplicate the option lines of output
- (jazzband/pip-tools#441) Exclude packages required only by unsafe packages
- (jazzband/pip-tools#389) Ignore pkg-resources
- (jazzband/pip-tools#355) Support non-editable pinned VCS dependencies

0.180.1
-------
Expand Down
10 changes: 2 additions & 8 deletions prequ/repositories/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,8 @@ def ireq_satisfied_by_existing_pin(ireq, existing_pin):
Return True if the given InstallationRequirement is satisfied by the
previously encountered version pin.
"""
if hasattr(existing_pin.req, 'specs'):
# pip < 8.1.2
version = existing_pin.req.specs[0][1]
return version in ireq.req
else:
# pip >= 8.1.2
version = next(iter(existing_pin.req.specifier)).version
return version in ireq.req.specifier
version = next(iter(existing_pin.req.specifier)).version
return version in ireq.req.specifier


class LocalRequirementsRepository(BaseRepository):
Expand Down
5 changes: 4 additions & 1 deletion prequ/repositories/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
from pip.download import unpack_url
from pip.index import PackageFinder
from pip.req.req_set import RequirementSet
from pip.utils.hashes import FAVORITE_HASH
try:
from pip.utils.hashes import FAVORITE_HASH
except ImportError:
FAVORITE_HASH = 'sha256'

from ..cache import CACHE_DIR
from ..exceptions import NoCandidateFound
Expand Down
7 changes: 1 addition & 6 deletions prequ/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,7 @@ def __init__(self, req):
self.req = req
self.key = key_from_req(req)
self.extras = str(sorted(req.extras))
if hasattr(req, 'specs'):
# pip < 8.1.2
self.specifier = str(req.specs)
else:
# pip >= 8.1.2
self.specifier = str(req.specifier)
self.specifier = str(req.specifier)

def __eq__(self, other):
return str(self) == str(other)
Expand Down
8 changes: 0 additions & 8 deletions prequ/scripts/compile_in.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ def cli(verbose, silent, dry_run, pre, rebuild, find_links, index_url,
# over the stuff in the requirements files
upgrade_packages = [InstallRequirement.from_line(pkg)
for pkg in upgrade_packages]
upgrade_pkgs_by_key = {key_from_req(ireq.req): ireq
for ireq in upgrade_packages}

# Proxy with a LocalRequirementsRepository if --upgrade is not specified
# (= default invocation)
Expand All @@ -144,12 +142,6 @@ def cli(verbose, silent, dry_run, pre, rebuild, find_links, index_url,
for ireq in ireqs:
key = key_from_req(ireq.req)

# Packages explicitly listed on the command line should not remain
# pinned by whatever is in the dst_file (the command line argument
# overwrites the current pins)
if key in upgrade_pkgs_by_key:
ireq = upgrade_pkgs_by_key[key]

if is_pinned_requirement(ireq):
existing_pins[key] = ireq
repository = LocalRequirementsRepository(existing_pins, repository)
Expand Down
11 changes: 7 additions & 4 deletions prequ/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ def key_from_req(req):
"""Get an all-lowercase version of the requirement's name."""
if hasattr(req, 'key'):
# pip 8.1.1 or below, using pkg_resources
return req.key
key = req.key
else:
# pip 8.1.2 or above, using packaging
return req.name.lower()
key = req.name

key = key.replace('_', '-').lower()
return key


def name_from_req(req):
Expand Down Expand Up @@ -73,9 +76,9 @@ def format_requirement(ireq, include_specifier=True):
if ireq.editable or is_vcs_link(ireq):
line = '{}{}'.format('-e ' if ireq.editable else '', ireq.link)
elif include_specifier:
line = str(ireq.req)
line = str(ireq.req).lower()
else:
line = name_from_req(ireq.req)
line = name_from_req(ireq.req).lower()
return line


Expand Down
22 changes: 22 additions & 0 deletions tests/fixtures/fake_package/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from setuptools import setup

setup(
name='fake_with_deps',
version=0.1,
install_requires=[
"python-dateutil>=2.4.2,<2.5",
"colorama<0.4.0,>=0.3.7",
"cornice<1.1,>=1.0.0",
"enum34<1.1.7,>=1.0.4",
"six>1.5,<=1.8",
"futures<3.1,>=3.0.3",
"ipaddress<1.1,>=1.0.16",
"jsonschema<3.0,>=2.4.0",
"pyramid<1.6,>=1.5.7",
"pyzmq<14.8,>=14.7.0",
"simplejson>=3.5,!=3.8,>3.9",
"SQLAlchemy!=0.9.5,<2.0.0,>=0.7.8,>=1.0.0",
"python-memcached>=1.57,<2.0",
"xmltodict<=0.11,>=0.4.6",
],
)
22 changes: 22 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
from textwrap import dedent
import subprocess

from click.testing import CliRunner

Expand Down Expand Up @@ -130,3 +131,24 @@ def test_trusted_host_no_emit(pip_conf):
'--no-trusted-host'])
print(out.output)
assert '--trusted-host example.com' not in out.output


def test_realistic_complex_sub_dependencies(tmpdir):

# make a temporary wheel of a fake package
subprocess.check_output(['pip', 'wheel',
'--no-deps',
'-w', str(tmpdir),
os.path.join('.', 'tests', 'fixtures', 'fake_package', '.')])

runner = CliRunner()
with runner.isolated_filesystem():
with open('requirements.in', 'w') as req_in:
req_in.write('fake_with_deps') # require fake package

out = runner.invoke(cli, ['-v',
'-n', '--rebuild',
'-f', str(tmpdir)])

print(out.output)
assert out.exit_code == 0
4 changes: 2 additions & 2 deletions tests/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ def test_format_requirement_annotation(from_line, writer):
'test==1.2 ' + comment('# via xyz'))


def test_format_requirement_annotation_case_sensitive(from_line, writer):
def test_format_requirement_annotation_lower_case(from_line, writer):
ireq = from_line('Test==1.2')
reverse_dependencies = {'test': ['xyz']}

assert (writer._format_requirement(ireq,
reverse_dependencies,
primary_packages=[]) ==
'Test==1.2 ' + comment('# via xyz'))
'test==1.2 ' + comment('# via xyz'))


def test_format_requirement_not_for_primary(from_line, writer):
Expand Down

0 comments on commit 860d8c8

Please sign in to comment.