Commits

holger krekel committed 292749b

* introduce a --installpkg=path option which will skip creation of an sdist and instead install the given package.
* introduce --indexserver|-i ALL=... to override all indexserver settings.

Comments (0)

Files changed (5)

     )
 
 if __name__ == '__main__':
-    main()
+    main()

tests/test_config.py

         assert config.indexserver['default'].url == "qwe2"
         assert config.indexserver['name1'].url == "abc"
 
+        config = newconfig(["-i", "ALL=xzy"], inisource)
+        assert len(config.indexserver) == 2
+        assert config.indexserver["default"].url == "xzy"
+        assert config.indexserver["name1"].url == "xzy"
+
 
 class TestParseEnv:
 

tests/test_z_cmdline.py

             distshare=%s
             sdistsrc={distshare}/pkg123-*
     """ % distshare)
-    distshare.ensure("pkg123-1.3.5.zip")
+    p0 = distshare.ensure("pkg123-1.3.5.zip")
     p = distshare.ensure("pkg123-1.4.5.zip")
     distshare.ensure("pkg123-1.4.5a1.zip")
     session = Session(config)
     sdist_path = session.sdist()
     assert sdist_path == p
 
+def test_installpkg(tmpdir, newconfig):
+    p = tmpdir.ensure("pkg123-1.0.zip")
+    config = newconfig(["--installpkg=%s" % p], "")
+    session = Session(config)
+    sdist_path = session.sdist()
+    assert sdist_path == p
+
+@pytest.mark.xfailif("sys.platform == 'win32'")
 def test_envsitepackagesdir(cmd, initproj):
     initproj("pkg512-0.0.5", filedefs={
         'tox.ini': """
             grep '__version__.*=.*0\.0\.5' {envsitepackagesdir}/pkg512/__init__.py
     """})
     result = cmd.run("tox")
+
                 return False
 
     def sdist(self):
-        if not self.config.option.sdistonly and self.config.sdistsrc:
-            self.report.info("using sdistfile %r, skipping 'sdist' activity " %
-                str(self.config.sdistsrc))
-            sdist_path = self.config.sdistsrc
+        if not self.config.option.sdistonly and (self.config.sdistsrc or
+            self.config.option.installpkg):
+            sdist_path = self.config.option.installpkg
+            if not sdist_path:
+                sdist_path = self.config.sdistsrc
             sdist_path = self._resolve_pkg(sdist_path)
+            self.report.info("using package %r, skipping 'sdist' activity " %
+                str(sdist_path))
         else:
             try:
                 sdist_path = self._makesdist()
         help="skip invoking test commands.")
     parser.add_argument("--sdistonly", action="store_true", dest="sdistonly",
         help="only perform the sdist packaging activity.")
+    parser.add_argument("--installpkg", action="store", default=None,
+        help="use specified package for installation into venv")
     parser.add_argument('-i', action="append",
         dest="indexurl", metavar="URL",
         help="set indexserver url (if URL is of form name=url set the "
             name, url = map(lambda x: x.strip(), line.split("=", 1))
             config.indexserver[name] = IndexServerConfig(name, url)
 
+        override = False
         if config.option.indexurl:
             for urldef in config.option.indexurl:
-                m = re.match(r"(\w+)=(\S+)", urldef)
+                m = re.match(r"\W*(\w+)=(\S+)", urldef)
                 if m is None:
                     url = urldef
                     name = "default"
                     name, url = m.groups()
                     if not url:
                         url = None
-                config.indexserver[name].url = url
+                if name != "ALL":
+                    config.indexserver[name].url = url
+                else:
+                    override = url
+        # let ALL override all existing entries
+        if override:
+            for name in config.indexserver:
+                config.indexserver[name] = IndexServerConfig(name, override)
+                print name, config.indexserver[name]
 
         reader.addsubstitions(toxworkdir=config.toxworkdir)
         config.distdir = reader.getpath(toxsection, "distdir",