Esempio n. 1
0
    def fork_compat(self, venv, cwd, args):
        from .vendor import pexpect

        # Grab current terminal dimensions to replace the hardcoded default
        # dimensions of pexpect.
        dims = get_terminal_size()
        with temp_environ():
            c = pexpect.spawn(self.cmd, ["-i"],
                              dimensions=(dims.lines, dims.columns))
        c.sendline(_get_activate_script(self.cmd, venv))
        if args:
            c.sendline(" ".join(args))

        # Handler for terminal resizing events
        # Must be defined here to have the shell process in its context, since
        # we can't pass it as an argument
        def sigwinch_passthrough(sig, data):
            dims = get_terminal_size()
            c.setwinsize(dims.lines, dims.columns)

        signal.signal(signal.SIGWINCH, sigwinch_passthrough)

        # Interact with the new shell.
        c.interact(escape_character=None)
        c.close()
        sys.exit(c.exitstatus)
Esempio n. 2
0
 def inject_path(self, venv):
     with temp_environ():
         os.environ["PATH"] = "{}{}{}".format(
             os.pathsep.join(str(p.parent) for p in _iter_python(venv)),
             os.pathsep,
             os.environ["PATH"],
         )
         yield
Esempio n. 3
0
def build_dists(ctx):
    drop_dist_dirs(ctx)
    py_version = ".".join(str(v) for v in sys.version_info[:2])
    env = {"PIPENV_PYTHON": py_version}
    with ctx.cd(ROOT.as_posix()), temp_environ():
        executable = ctx.run(
            "python -c 'import sys; print(sys.executable)'", hide=True
        ).stdout.strip()
        log("Building sdist using %s ...." % executable)
        os.environ["PIPENV_PYTHON"] = py_version
        ctx.run("pipenv install --dev", env=env)
        ctx.run("pipenv run pip install -e . --upgrade --upgrade-strategy=eager", env=env)
        log("Building wheel using python %s ...." % py_version)
        ctx.run("pipenv run python setup.py sdist bdist_wheel", env=env)
Esempio n. 4
0
def PipenvInstance_NoPyPI(monkeypatch, pip_src_dir, pypi, capfdbinary):
    with temp_environ(), monkeypatch.context() as m:
        m.setattr(shutil, "rmtree", _rmtree_func)
        original_umask = os.umask(0o007)
        m.setenv("PIPENV_NOSPIN", "1")
        m.setenv("CI", "1")
        m.setenv('PIPENV_DONT_USE_PYENV', '1')
        m.setenv("PIPENV_TEST_INDEX", f"{pypi.url}/simple")
        m.setenv("ARTIFACT_PYPI_URL", pypi.url)
        warnings.simplefilter("ignore", category=ResourceWarning)
        warnings.filterwarnings("ignore", category=ResourceWarning, message="unclosed.*<ssl.SSLSocket.*>")
        try:
            yield functools.partial(_PipenvInstance, capfd=capfdbinary)
        finally:
            os.umask(original_umask)
Esempio n. 5
0
def PipenvInstance(pip_src_dir, monkeypatch, pypi):
    with temp_environ(), monkeypatch.context() as m:
        m.setattr(shutil, "rmtree", _rmtree_func)
        original_umask = os.umask(0o007)
        m.setenv("PIPENV_NOSPIN", fs_str("1"))
        m.setenv("CI", fs_str("1"))
        m.setenv('PIPENV_DONT_USE_PYENV', fs_str('1'))
        m.setenv("PIPENV_TEST_INDEX", "{0}/simple".format(pypi.url))
        m.setenv("PIPENV_PYPI_INDEX", "simple")
        m.setenv("ARTIFACT_PYPI_URL", pypi.url)
        m.setenv("PIPENV_PYPI_URL", pypi.url)
        warnings.simplefilter("ignore", category=ResourceWarning)
        warnings.filterwarnings("ignore",
                                category=ResourceWarning,
                                message="unclosed.*<ssl.SSLSocket.*>")
        try:
            yield _PipenvInstance
        finally:
            os.umask(original_umask)
Esempio n. 6
0
def build_dists(ctx):
    drop_dist_dirs(ctx)
    for py_version in ['3.6', '2.7']:
        env = {'PIPENV_PYTHON': py_version}
        with ctx.cd(ROOT.as_posix()), temp_environ():
            executable = ctx.run(
                "python -c 'import sys; print(sys.executable)'",
                hide=True).stdout.strip()
            log('Building sdist using %s ....' % executable)
            os.environ["PIPENV_PYTHON"] = py_version
            ctx.run('pipenv install --dev', env=env)
            ctx.run(
                'pipenv run pip install -e . --upgrade --upgrade-strategy=eager --no-use-pep517',
                env=env)
            log('Building wheel using python %s ....' % py_version)
            if py_version == '3.6':
                ctx.run('pipenv run python setup.py sdist bdist_wheel',
                        env=env)
            else:
                ctx.run('pipenv run python setup.py bdist_wheel', env=env)
Esempio n. 7
0
def build_dists(ctx):
    drop_dist_dirs(ctx)
    for py_version in ["3.6", "3.7", "3.8", "2.7"]:
        env = {"PIPENV_PYTHON": py_version}
        with ctx.cd(ROOT.as_posix()), temp_environ():
            executable = ctx.run(
                "python -c 'import sys; print(sys.executable)'", hide=True
            ).stdout.strip()
            log("Building sdist using %s ...." % executable)
            os.environ["PIPENV_PYTHON"] = py_version
            ctx.run("pipenv install --dev", env=env)
            ctx.run(
                "pipenv run pip install -e . --upgrade --upgrade-strategy=eager", env=env
            )
            log("Building wheel using python %s ...." % py_version)
            tag_arg = "--python-tag py{}".format(py_version.replace(".", ""))
            if py_version == "3.8":
                ctx.run(f"pipenv run python setup.py sdist bdist_wheel {tag_arg}", env=env)
            else:
                ctx.run(f"pipenv run python setup.py bdist_wheel {tag_arg}", env=env)
            if py_version in ("3.6", "2.7"):
                # generate py2 / py3 generic untagged wheels
                ctx.run(f"pipenv run python setup.py sdist bdist_wheel", env=env)
Esempio n. 8
0
def get_dependencies_from_index(dep,
                                sources=None,
                                pip_options=None,
                                wheel_cache=None):
    """Retrieves dependencies for the given install requirement from the pip
    resolver.

    :param dep: A single InstallRequirement
    :type dep: :class:`~pipenv.patched.notpip._internal.req.req_install.InstallRequirement`
    :param sources: Pipfile-formatted sources, defaults to None
    :type sources: list[dict], optional
    :return: A set of dependency lines for generating new InstallRequirements.
    :rtype: set(str) or None
    """

    session, finder = get_finder(sources=sources, pip_options=pip_options)
    dep.is_direct = True
    requirements = None
    setup_requires = {}
    with temp_environ(), ExitStack() as stack:
        if not wheel_cache:
            wheel_cache = stack.enter_context(_get_wheel_cache())
        os.environ["PIP_EXISTS_ACTION"] = "i"
        if dep.editable and not dep.prepared and not dep.req:
            setup_info = SetupInfo.from_ireq(dep)
            results = setup_info.get_info()
            setup_requires.update(results["setup_requires"])
            requirements = set(results["requires"].values())
        else:
            results = pip_shims.shims.resolve(dep)
            requirements = [v for v in results.values() if v.name != dep.name]
        requirements = set([format_requirement(r) for r in requirements])
    if not dep.editable and is_pinned_requirement(
            dep) and requirements is not None:
        DEPENDENCY_CACHE[dep] = list(requirements)
    return requirements
Esempio n. 9
0
def virtualenv(vistir_tmpdir):
    with temp_environ(), VirtualEnv(base_dir=vistir_tmpdir) as venv:
        yield venv