def isolate(pathlib_tmpdir): """ Isolate our tests so that things like global configuration files and the like do not affect our test results. We use an autouse function scoped fixture because we want to ensure that every test has it's own isolated home directory. """ # Create a directory to use as our home location. home_dir = os.path.join(str(pathlib_tmpdir), "home") os.makedirs(home_dir) mkdir_p(os.path.join(home_dir, ".config", "git")) with open(os.path.join(home_dir, ".config", "git", "config"), "wb") as fp: fp.write( b"[user]\n\tname = pipenv\n\temail = [email protected]\n" ) os.environ["GIT_CONFIG_NOSYSTEM"] = fs_str("1") os.environ["GIT_AUTHOR_NAME"] = fs_str("pipenv") os.environ["GIT_AUTHOR_EMAIL"] = fs_str("*****@*****.**") mkdir_p(os.path.join(home_dir, ".virtualenvs")) os.environ["WORKON_HOME"] = fs_str(os.path.join(home_dir, ".virtualenvs")) # Ignore PIPENV_ACTIVE so that it works as under a bare environment. os.environ.pop("PIPENV_ACTIVE", None) os.environ.pop("VIRTUAL_ENV", None) global WE_HAVE_GITHUB_SSH_KEYS WE_HAVE_GITHUB_SSH_KEYS = check_github_ssh()
def _prepare_wheel_building_kwargs(ireq): download_dir = os.path.join(CACHE_DIR, "pkgs") mkdir_p(download_dir) wheel_download_dir = os.path.join(CACHE_DIR, "wheels") mkdir_p(wheel_download_dir) if ireq.source_dir is not None: src_dir = ireq.source_dir elif ireq.editable: src_dir = _get_src_dir() else: src_dir = create_tracked_tempdir(prefix="reqlib-src") # This logic matches pip's behavior, although I don't fully understand the # intention. I guess the idea is to build editables in-place, otherwise out # of the source tree? if ireq.editable: build_dir = src_dir else: build_dir = create_tracked_tempdir(prefix="reqlib-build") return { "build_dir": build_dir, "src_dir": src_dir, "download_dir": download_dir, "wheel_download_dir": wheel_download_dir, }
def _prepare_wheel_building_kwargs(ireq=None, src_root=None, src_dir=None, editable=False): # type: (Optional[InstallRequirement], Optional[AnyStr], Optional[AnyStr], bool) -> Dict[AnyStr, AnyStr] download_dir = os.path.join(CACHE_DIR, "pkgs") # type: STRING_TYPE mkdir_p(download_dir) wheel_download_dir = os.path.join(CACHE_DIR, "wheels") # type: STRING_TYPE mkdir_p(wheel_download_dir) if src_dir is None: if editable and src_root is not None: src_dir = src_root elif ireq is None and src_root is not None: src_dir = _get_src_dir(root=src_root) # type: STRING_TYPE elif ireq is not None and ireq.editable and src_root is not None: src_dir = _get_src_dir(root=src_root) else: src_dir = create_tracked_tempdir(prefix="reqlib-src") # Let's always resolve in isolation if src_dir is None: src_dir = create_tracked_tempdir(prefix="reqlib-src") build_dir = create_tracked_tempdir(prefix="reqlib-build") return { "build_dir": build_dir, "src_dir": src_dir, "download_dir": download_dir, "wheel_download_dir": wheel_download_dir, }
def isolate(pathlib_tmpdir): """ Isolate our tests so that things like global configuration files and the like do not affect our test results. We use an autouse function scoped fixture because we want to ensure that every test has it's own isolated home directory. """ # Create a directory to use as our home location. home_dir = os.path.join(str(pathlib_tmpdir), "home") os.makedirs(home_dir) mkdir_p(os.path.join(home_dir, ".config", "git")) with open(os.path.join(home_dir, ".config", "git", "config"), "wb") as fp: fp.write(b"[user]\n\tname = pipenv\n\temail = [email protected]\n") os.environ["GIT_CONFIG_NOSYSTEM"] = fs_str("1") os.environ["GIT_AUTHOR_NAME"] = fs_str("pipenv") os.environ["GIT_AUTHOR_EMAIL"] = fs_str("*****@*****.**") mkdir_p(os.path.join(home_dir, ".virtualenvs")) os.environ["WORKON_HOME"] = fs_str(os.path.join(home_dir, ".virtualenvs"))