From 1bac56088d4c16582fb06c04c718f649a64ad4dc Mon Sep 17 00:00:00 2001 From: Vincent Philippon Date: Mon, 10 Apr 2017 20:42:56 -0400 Subject: [PATCH] Fix the --update-package option (#491) * Respect the --upgrade-packages list if given. --- CHANGELOG.md | 1 + piptools/scripts/compile.py | 13 +++++----- .../small_fake_a-0.1-py2.py3-none-any.whl | Bin 0 -> 1631 bytes .../small_fake_a-0.2-py2.py3-none-any.whl | Bin 0 -> 1632 bytes .../small_fake_b-0.1-py2.py3-none-any.whl | Bin 0 -> 1635 bytes .../small_fake_b-0.2-py2.py3-none-any.whl | Bin 0 -> 1631 bytes tests/test_cli.py | 23 ++++++++++++++++++ 7 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 tests/fixtures/minimal_wheels/small_fake_a-0.1-py2.py3-none-any.whl create mode 100644 tests/fixtures/minimal_wheels/small_fake_a-0.2-py2.py3-none-any.whl create mode 100644 tests/fixtures/minimal_wheels/small_fake_b-0.1-py2.py3-none-any.whl create mode 100644 tests/fixtures/minimal_wheels/small_fake_b-0.2-py2.py3-none-any.whl diff --git a/CHANGELOG.md b/CHANGELOG.md index 33052b010..4a9c5f3dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Features: - Preserve environment markers in generated requirements.txt. ([#460](https://github.com/jazzband/pip-tools/pull/460)). Thanks @barrywhart. Bug Fixes: +- Fixed the --upgrade-package option to respect the given package list to update ([#491](https://github.com/jazzband/pip-tools/pull/491)). - Fixed the default output file name when the source file has no extension ([#488](https://github.com/jazzband/pip-tools/pull/488)). Thanks @vphilippon - Fixed crash on editable requirements introduced in 1.8.2. - Fixed duplicated --trusted-host, --extra-index-url and --index-url in the generated requirements. diff --git a/piptools/scripts/compile.py b/piptools/scripts/compile.py index 850e4a503..da3ce085e 100755 --- a/piptools/scripts/compile.py +++ b/piptools/scripts/compile.py @@ -126,16 +126,15 @@ def cli(verbose, dry_run, pre, rebuild, find_links, index_url, extra_index_url, session = pip_command._build_session(pip_options) repository = PyPIRepository(pip_options, session) - # Pre-parse the inline package upgrade specs: they should take precedence - # over the stuff in the requirements files - upgrade_packages = [InstallRequirement.from_line(pkg) - for pkg in upgrade_packages] - # Proxy with a LocalRequirementsRepository if --upgrade is not specified # (= default invocation) - if not (upgrade or upgrade_packages) and os.path.exists(dst_file): + if not upgrade and os.path.exists(dst_file): ireqs = parse_requirements(dst_file, finder=repository.finder, session=repository.session, options=pip_options) - existing_pins = {key_from_req(ireq.req): ireq for ireq in ireqs if is_pinned_requirement(ireq)} + # Exclude packages from --upgrade-package/-P from the existing pins: We want to upgrade. + upgrade_pkgs_key = {key_from_req(InstallRequirement.from_line(pkg).req) for pkg in upgrade_packages} + existing_pins = {key_from_req(ireq.req): ireq + for ireq in ireqs + if is_pinned_requirement(ireq) and key_from_req(ireq.req) not in upgrade_pkgs_key} repository = LocalRequirementsRepository(existing_pins, repository) log.debug('Using indexes:') diff --git a/tests/fixtures/minimal_wheels/small_fake_a-0.1-py2.py3-none-any.whl b/tests/fixtures/minimal_wheels/small_fake_a-0.1-py2.py3-none-any.whl new file mode 100644 index 0000000000000000000000000000000000000000..e59cae74b5cfe1595c0f57ebd19fb07fe5b50960 GIT binary patch literal 1631 zcmWIWW@Zs#U|`^2@Y&Mk6{lN&i3iBz0%9#7F3wHN$%#)(%ubC@)HTpE)Jw@MF44`* zOUu`HaSe73@(c*^^!L*%DlXyv`uW>u{_l?;Jz`=AKrxe5wAW_|(5zcPtbyOm+|-i9 zl*E!my{zK=Jm22kd`$)-ZSk!omt1C@TDICsU~e*Ro1I)`v3%x} zbHdVXiGmy1rAi#GwVqhJ#`fuZu0U7ggOf$Yi_O};RD>`&{&RZ1d}m8{LhEjYy=+S# zS=$)49jIMxxtFn;bB$L+*X!&_pG`p;np(b3pK^Kn zY!A{{VRGs0>GR%Keb20J;g(e9{8+?@7OD3F1e3~uF53;n%J^OA>l)(d;uzwXdU_+* zAp?=thkp;%w(oK9dOPE+Z$R+E6`vjRO=sNpn8del?`)PkeDcrjy^hL?epA}nvc2u{NBvx@~W;sh0or6uiI0#EH-FkzRi-2Z=>dG{%;g@?ckL^ z?&>JrH+bfhgZVXE~Dy?gWQroMElfA+u2SvuzWN6v7SV|z3h6ty)TcYnK5 zJL`hEO||%q6Qb*;6q+2rx6zhsR8@}oVue>i^IcfXlM+@9! zW~^SE%P)1p*fOs~BuXIf-mga%)+RQJrXEc3s$S)NT+dba&63?Sqx|&LV1c<638e&00eQuOLCdpv)fTKqb+I{r{s=&KK}`cHU#^_cq8Y!Fe3rH1r&ZFin#QuNz_c5#2!ayn!(A0e%A^IVHfGl?|kY O4G2F0{S(dt;sF5RZ9gUe literal 0 HcmV?d00001 diff --git a/tests/fixtures/minimal_wheels/small_fake_a-0.2-py2.py3-none-any.whl b/tests/fixtures/minimal_wheels/small_fake_a-0.2-py2.py3-none-any.whl new file mode 100644 index 0000000000000000000000000000000000000000..33e62318819451b0bd3704d6a6f12b5f55447a4d GIT binary patch literal 1632 zcmWIWW@Zs#U|`^2IJl+DD^9om5)Y8a1;koFT%4PjlM|non4KD*sB55Sq?eLeT%wzq zmzJ;Z;u`E6F=jkR9wRS_4BvS{NEoxdc?#KfMRCM>eGHpfM(qSVh#Le=BAb; zrX-dm>SYz@=lS-Y=4&z#aIJ4W<0YKQVSRTMcQVs4_n1k7ZkajUne0;q{@pd(R8V=o zme)aE?Qu%7%$h}vx8}V**3l)g^w+{wn%2H;+|9GpT-I&blp6n8%Ix;#UpuVllvk>) zNtQTXD0r}$C-TX$wi9b7^>vr~E?E?*bZM!_vj@(%zH>^ZS3Q%}@$!=cy-ev5-X z%FY)_ez5McRIdCQ?``KlWsALtzkmMl4^~v4PG-Aq#0>NyBVnJGoPuQ}lbAEG>!4=~NPmBD|dh2@W zoYdbG}4+@2gx^8?;g0X6eSeQSqAp8%13^c;yer zPP;TM*=26%=DVS@J6)@~sO4*f|1tLN{FeG~Tm`M>=S6LpuFXcsse>71IR^)&t1(cr7t8vEt;;kS{%Ow5c&gf6V<}d8uFNL%s^9m72S-F#=sKK= z3wZLg=db=A=agG&M)H~e1F{#qlxSPs{Z`$2%HG9S!d5qxO|RBi|9zTboU!fd4jqlQ ze_LdowR>_ME3CY1IsUfqv(mATo+z+NCUBAPh3UUPf782vnt|*@$?sUbM6>tr zVw%?$eWfS|nlR9FRwY1E4uMFnwdG^dgIkrRRWn-=zr`uh>0MW;q z2YxFqe$pM#S^qyaS&sd@?bLsPIZ5B1m4&mL?YX%8cLB%R%T?>MAJxt6zs*0L^Hj|@ z<^XR-CJ_eQB?~a{!C+e>h{BV=(aITgbJ0r|h^Y(=+Zsdgn~PG`pqq-GlM$xc0aFeh z*P`TWbW_o@HNw<({HB64Il5`+SrB2GCKFya!ZIYff#{h7Vc-M&212q*fHx}}NDCVf MeggU@f(66_03k&{>Hq)$ literal 0 HcmV?d00001 diff --git a/tests/fixtures/minimal_wheels/small_fake_b-0.1-py2.py3-none-any.whl b/tests/fixtures/minimal_wheels/small_fake_b-0.1-py2.py3-none-any.whl new file mode 100644 index 0000000000000000000000000000000000000000..9140599c9bd5b5909422d8d2f828f8870b334353 GIT binary patch literal 1635 zcmWIWW@Zs#U|`^2*tVt1D^9om5)Y8a1;koFT%4PjlM|non4KD*q-&sOsF#viT%wzq zmzJ;Z;u`E6F=jkR9wRS_4BvS{NEoxdc?#KfMO;G-_F*hK(lTEu?BuKb5lza zQxZ!O^|Ffd^L%@E^EDZWw8giUTymLpYT0Tl0bzrbV9$l0nR*YEA|C2_tan`b zgU`R`^nu#draSZ^rsvFmdR^zj{(TR;&1x7?y*iogx)C$bi;RT5T9RK7pOadanxj`z zQSul)%#eJG?#%hkK?YZhA3QDcKkKdQ zrE^k$Q;>((NgcgTeRj>D3kDaAH(fEl@Z>4isq^|5zv^7$)zI}id(vl9kcOs~@6)GT zo<7@yG**~gI(z!O_f_9Bt6R7wl{r5aF`~ul)w0xMtGpX$M*kRi60x;qIh8g(eFNzaO`{e#iF=f2QPP;g6QME3avcDwIuoAB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a/tests/test_cli.py +++ b/tests/test_cli.py @@ -237,3 +237,26 @@ def test_input_file_without_extension(tmpdir): assert out.exit_code == 0 assert '--output-file requirements.txt' in out.output assert 'six==1.10.0' in out.output + + +def test_upgrade_packages_option(tmpdir): + """ + piptools respects --upgrade-package/-P inline list. + """ + fake_package_dir = os.path.join(os.path.split(__file__)[0], 'fixtures', 'minimal_wheels') + runner = CliRunner() + with runner.isolated_filesystem(): + with open('requirements.in', 'w') as req_in: + req_in.write('small-fake-a\nsmall-fake-b') + with open('requirements.txt', 'w') as req_in: + req_in.write('small-fake-a==0.1\nsmall-fake-b==0.1') + + out = runner.invoke(cli, [ + '-P', 'small_fake_b', + '-f', fake_package_dir, + ]) + + print(out.output) + assert out.exit_code == 0 + assert 'small-fake-a==0.1' in out.output + assert 'small-fake-b==0.2' in out.output