Пример #1
0
 def test_setup_requires_honors_fetch_params(self, mock_index, monkeypatch):
     """
     When easy_install installs a source distribution which specifies
     setup_requires, it should honor the fetch parameters (such as
     index-url, and find-links).
     """
     monkeypatch.setenv(str('PIP_RETRIES'), str('0'))
     monkeypatch.setenv(str('PIP_TIMEOUT'), str('0'))
     with contexts.quiet():
         # create an sdist that has a build-time dependency.
         with TestSetupRequires.create_sdist() as dist_file:
             with contexts.tempdir() as temp_install_dir:
                 with contexts.environment(PYTHONPATH=temp_install_dir):
                     ei_params = [
                         '--index-url',
                         mock_index.url,
                         '--exclude-scripts',
                         '--install-dir',
                         temp_install_dir,
                         dist_file,
                     ]
                     with sandbox.save_argv(['easy_install']):
                         # attempt to install the dist. It should
                         # fail because it doesn't exist.
                         with pytest.raises(SystemExit):
                             easy_install_pkg.main(ei_params)
     # there should have been one requests to the server
     assert [r.path for r in mock_index.requests] == ['/does-not-exist/']
Пример #2
0
    def _collect(self):

        setup_py = self.path / const.SETUP_PY
        if not setup_py.exists():
            log.warning("%r has no %s", self, const.SETUP_PY)
            return

        distutils.core._setup_distribution = None
        distutils.core._setup_stop_after = "config"

        with sandbox.save_argv((const.SETUP_PY, "-h")), sandbox.save_path():
            sys.path.insert(0, ".")
            sandbox._execfile(
                const.SETUP_PY,
                dict(__file__=const.SETUP_PY, __name__="__main__"),
            )

        dist = distutils.core._setup_distribution
        assert dist is not None, "distutils.core.setup not called"

        # get requirements from distutils dist
        for attr, extra in self.STD_EXTRAS.items():
            reqs = getattr(dist, attr, None) or []
            for req in self._filter_reqs(reqs):
                self.add_requirement(req, extra)
        for extra, reqs in getattr(dist, "extras_require", {}).items():
            for req in self._filter_reqs(reqs):
                self.add_requirement(req, extra)

        # get packages
        self.ext.packages = set(getattr(dist, "packages", None) or [])
        self.ext.modules = set(getattr(dist, "py_modules", None) or [])
        self.ext.hasext = bool(getattr(dist, "ext_modules", []))
Пример #3
0
 def test_as_module(self, tmpdir, capsys):
     self._run_egg_info(tmpdir, SETUP)
     main = str(Path(cli.__file__).parent / "__main__.py")
     with sandbox.save_argv((main, str(tmpdir))):
         pytest.raises(
             SystemExit,
             sandbox._execfile,
             main,
             dict(__file__=main, __name__="__main__"),
         )
     captured = capsys.readouterr()
     # dist = json.loads(captured.out)
     # assert dist["name"] == "test.dist"
     assert "test.dist" in captured.out
Пример #4
0
 def test_setup_requires_honors_fetch_params(self):
     """
     When easy_install installs a source distribution which specifies
     setup_requires, it should honor the fetch parameters (such as
     allow-hosts, index-url, and find-links).
     """
     # set up a server which will simulate an alternate package index.
     p_index = setuptools.tests.server.MockServer()
     p_index.start()
     netloc = 1
     p_index_loc = urllib.parse.urlparse(p_index.url)[netloc]
     if p_index_loc.endswith(':0'):
         # Some platforms (Jython) don't find a port to which to bind,
         #  so skip this test for them.
         return
     with contexts.quiet():
         # create an sdist that has a build-time dependency.
         with TestSetupRequires.create_sdist() as dist_file:
             with contexts.tempdir() as temp_install_dir:
                 with contexts.environment(PYTHONPATH=temp_install_dir):
                     ei_params = [
                         '--index-url',
                         p_index.url,
                         '--allow-hosts',
                         p_index_loc,
                         '--exclude-scripts',
                         '--install-dir',
                         temp_install_dir,
                         dist_file,
                     ]
                     with sandbox.save_argv(['easy_install']):
                         # attempt to install the dist. It should
                         # fail because it doesn't exist.
                         with pytest.raises(SystemExit):
                             easy_install_pkg.main(ei_params)
     # there should have been two or three requests to the server
     #  (three happens on Python 3.3a)
     assert 2 <= len(p_index.requests) <= 3
     assert p_index.requests[0].path == '/does-not-exist/'
 def test_setup_requires_honors_fetch_params(self):
     """
     When easy_install installs a source distribution which specifies
     setup_requires, it should honor the fetch parameters (such as
     allow-hosts, index-url, and find-links).
     """
     # set up a server which will simulate an alternate package index.
     p_index = setuptools.tests.server.MockServer()
     p_index.start()
     netloc = 1
     p_index_loc = urlparse(p_index.url)[netloc]
     if p_index_loc.endswith(':0'):
         # Some platforms (Jython) don't find a port to which to bind,
         #  so skip this test for them.
         return
     with contexts.quiet():
         # create an sdist that has a build-time dependency.
         with TestSetupRequires.create_sdist() as dist_file:
             with contexts.tempdir() as temp_install_dir:
                 with contexts.environment(PYTHONPATH=temp_install_dir):
                     ei_params = [
                         '--index-url', p_index.url,
                         '--allow-hosts', p_index_loc,
                         '--exclude-scripts',
                         '--install-dir', temp_install_dir,
                         dist_file,
                     ]
                     with sandbox.save_argv(['easy_install']):
                         # attempt to install the dist. It should fail because
                         #  it doesn't exist.
                         with pytest.raises(SystemExit):
                             easy_install_pkg.main(ei_params)
     # there should have been two or three requests to the server
     #  (three happens on Python 3.3a)
     assert 2 <= len(p_index.requests) <= 3
     assert p_index.requests[0].path == '/does-not-exist/'