From d3cbb3f606568717c2c9bc3805e5ab75dc4c2878 Mon Sep 17 00:00:00 2001 From: Marcus Smith Date: Wed, 7 Aug 2013 00:13:47 -0700 Subject: [PATCH] fix up the bundle support --- pip/req.py | 21 +++++++++++++-------- tests/data/packages/simplebundle.pybundle | Bin 0 -> 4355 bytes tests/functional/test_install_bundle.py | 11 +++++++++++ tests/lib/__init__.py | 2 +- 4 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 tests/data/packages/simplebundle.pybundle create mode 100644 tests/functional/test_install_bundle.py diff --git a/pip/req.py b/pip/req.py index 5742e62ce07..93af61c9d33 100644 --- a/pip/req.py +++ b/pip/req.py @@ -37,7 +37,8 @@ class InstallRequirement(object): def __init__(self, req, comes_from, source_dir=None, editable=False, - url=None, as_egg=False, update=True, prereleases=None): + url=None, as_egg=False, update=True, prereleases=None, + from_bundle=False): self.extras = () if isinstance(req, string_types): req = pkg_resources.Requirement.parse(req) @@ -65,6 +66,7 @@ def __init__(self, req, comes_from, source_dir=None, editable=False, self.uninstalled = None self.use_user_site = False self.target_dir = None + self.from_bundle = from_bundle # True if pre-releases are acceptable if prereleases: @@ -776,12 +778,10 @@ def bundle_requirements(self): url = None yield InstallRequirement( package, self, editable=True, url=url, - update=False, source_dir=dest_dir) + update=False, source_dir=dest_dir, from_bundle=True) for dest_dir in self._bundle_build_dirs: package = os.path.basename(dest_dir) - yield InstallRequirement( - package, self, - source_dir=dest_dir) + yield InstallRequirement(package, self,source_dir=dest_dir, from_bundle=True) def move_bundle_files(self, dest_build_dir, dest_src_dir): base = self._temp_build_dir @@ -1059,9 +1059,14 @@ def prepare_files(self, finder, force_root_egg_info=False, bundle=False): unpack = True url = None - # If a checkout exists, it's unwise to keep going. - # Version inconsistencies are logged later, but do not fail the installation. - if os.path.exists(os.path.join(location, 'setup.py')): + # In the case where the req comes from a bundle, we should + # assume a build dir exists and move on + if req_to_install.from_bundle: + pass + # If a checkout exists, it's unwise to keep going. version + # inconsistencies are logged later, but do not fail the + # installation. + elif os.path.exists(os.path.join(location, 'setup.py')): msg = textwrap.dedent(""" pip can't proceed with requirement '%s' due to a pre-existing build directory. location: %s diff --git a/tests/data/packages/simplebundle.pybundle b/tests/data/packages/simplebundle.pybundle new file mode 100644 index 0000000000000000000000000000000000000000..e8bb889971e9b991ff0e0054db7370fc40b75578 GIT binary patch literal 4355 zcmd5-22?; z{_gKS_jz*=ihmf1L<%BBnFE)D4#^Mu2Vxdzg=JD%5gV1tl`;vNLdx+t_yuS%$Lr{5 zX!O$+Sdx+wrc_Z}>UA>4)`^z~deawN*o}g*r$Gyc=j0$Om^^-#U?iK#TghYaY_kw1 zy~|>45GL8Ux9%a9>_#E2%ff8u-PT`%-E=n#LZrj-5@rhlH5^B!al?&z`IY_mk|IxZ+yZCsyR`N}7@zWy4Eo_g|~q!#UGZIx#p)vVhU1SK)U z{AnHsuv-G!T$m*)QI{!M8;VN|{A@vm)q-5AxJ~D+tPs#UExg>5t4OGjiU@TwO46~j z4E7JSMn=OT?(4G|?E%m#%K~S9CSkH*U{D@~2>ym|u@^ci&b8~jGn{z&R z7qI;tG#Y4bs?xz)Bv>U}o+)Cfx2Y4cY+gqA$Q^oM!wmZOd%0+^N_gLH=ZpIc0JvKZxQk75_P^U?#({vc`EinK4>~Plm?EJ}TVv$MV*MgbEi z#S6YloTn1wU6cMgi*ZfFgw}ATP;JD6kN1S*sGH}f686l$ zJFNf^t^p0cy>1Ggpj+~bEi;zpgzWBZ-n!YCA5xiK^lI==a#eZVlC~QLW8v1(AMLrR z$*o0{amHebz_4iF%cMe~HlO>R{Ef8wT+u*5uH=5c*<4z6hP!<*VntYgsAf@1sP*x9 z?YG+2=$_69&%(v^o#81-*S4iE#mxX%L7*{wW4aNqls;H@gof^OO#o{#P}mUgtCT94 z@&bjlSc0lC(aYu|ds~xc_S^}ZZH_*FdDyQxGqquUb%rz}`bOg)2fKz=@crulPQUu_ zMdjhlf{KvX8um{0K3>%OG1ls2|0BGn!kBUWp31;1Q*T!O)q#^$?O&BdGON%u{WrZS zyQyn$#aA0owZ@%Fi%%V1DLxi=&0g9mA76NVjKigF$~rXj2EF;xfuU3xcSru|>K5b2 zKcC2byT(59z_#72-z=; z;@KdA?M{RidtIDFh3#!BW*70$l9{0EtViDFV&)MKEqN{I66d;DNpDctzVOhJ4}q>5 zD3^^8%?f6w@G$8tpzDNy-+Gt??D`xKDv(Ggh)HRNF0BhB*y9wB%+8Y*NKtN*9}hV-N{x$s?XHh)x n*Y^TmZy5ac;>cQZ3izOaU*a4j030TX6aoIaKyLwN1xWt_xd{!T literal 0 HcmV?d00001 diff --git a/tests/functional/test_install_bundle.py b/tests/functional/test_install_bundle.py new file mode 100644 index 00000000000..ea45f30efb7 --- /dev/null +++ b/tests/functional/test_install_bundle.py @@ -0,0 +1,11 @@ +import os +from tests.lib import reset_env, pip_install_local, packages + +def test_install_pybundle(): + """ + Test intalling a *.pybundle file + """ + env = reset_env() + result = pip_install_local(os.path.join(packages, 'simplebundle.pybundle'), expect_temp=True) + result.assert_installed('simple', editable=False) + result.assert_installed('simple2', editable=False) diff --git a/tests/lib/__init__.py b/tests/lib/__init__.py index aebbd5faf68..b877259afaf 100644 --- a/tests/lib/__init__.py +++ b/tests/lib/__init__.py @@ -451,7 +451,7 @@ def run_pip(*args, **kw): def pip_install_local(*args, **kw): """Run 'pip install' using --find-links against our local test packages""" - run_pip('install', '--no-index', '--find-links=%s' % find_links, *args, **kw) + return run_pip('install', '--no-index', '--find-links=%s' % find_links, *args, **kw) def write_file(filename, text, dest=None): """Write a file in the dest (default=env.scratch_path)