mirror of https://github.com/mamba-org/mamba.git
Make some fixture local (#2919)
* Make xdg fixtures local * Make create fixtures local
This commit is contained in:
parent
8100f0e6ef
commit
a8464367c4
|
@ -184,95 +184,3 @@ def tmp_xtensor_env(tmp_prefix: pathlib.Path) -> Generator[pathlib.Path, None, N
|
||||||
"""An activated environment with Xtensor installed."""
|
"""An activated environment with Xtensor installed."""
|
||||||
helpers.install("-c", "conda-forge", "--json", "xtensor", no_dry_run=True)
|
helpers.install("-c", "conda-forge", "--json", "xtensor", no_dry_run=True)
|
||||||
yield tmp_prefix
|
yield tmp_prefix
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def user_config_dir(tmp_home: pathlib.Path) -> Generator[pathlib.Path, None, None]:
|
|
||||||
"""Location of config files that are generated from mamba"""
|
|
||||||
maybe_xdg_config = os.getenv("XDG_CONFIG_DIR", "")
|
|
||||||
if maybe_xdg_config:
|
|
||||||
yield pathlib.Path(maybe_xdg_config)
|
|
||||||
system = platform.system()
|
|
||||||
if system == "Linux" or system == "Darwin":
|
|
||||||
yield tmp_home / ".config/mamba"
|
|
||||||
elif system == "Windows":
|
|
||||||
yield pathlib.Path(os.environ["APPDATA"]) / "mamba"
|
|
||||||
else:
|
|
||||||
raise RuntimeError(f"Unsupported system {system}")
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def user_data_dir(tmp_home: pathlib.Path) -> Generator[pathlib.Path, None, None]:
|
|
||||||
"""Location of data files that are generated from mamba"""
|
|
||||||
maybe_xdg_data = os.getenv("XDG_DATA_DIR", "")
|
|
||||||
if maybe_xdg_data:
|
|
||||||
yield pathlib.Path(maybe_xdg_data)
|
|
||||||
system = platform.system()
|
|
||||||
if system == "Linux" or system == "Darwin":
|
|
||||||
yield tmp_home / ".local/share/mamba"
|
|
||||||
elif system == "Windows":
|
|
||||||
yield pathlib.Path(os.environ["APPDATA"]) / "mamba"
|
|
||||||
else:
|
|
||||||
raise RuntimeError(f"Unsupported system {system}")
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def user_cache_dir(tmp_home: pathlib.Path) -> Generator[pathlib.Path, None, None]:
|
|
||||||
"""Location of data files that are generated from mamba"""
|
|
||||||
maybe_xdg_cache = os.getenv("XDG_CACHE_DIR", "")
|
|
||||||
if maybe_xdg_cache:
|
|
||||||
yield pathlib.Path(maybe_xdg_cache)
|
|
||||||
system = platform.system()
|
|
||||||
if system == "Linux" or system == "Darwin":
|
|
||||||
yield tmp_home / ".cache/mamba"
|
|
||||||
elif system == "Windows":
|
|
||||||
yield pathlib.Path(os.environ["LOCALAPPDATA"]) / "mamba"
|
|
||||||
else:
|
|
||||||
raise RuntimeError(f"Unsupported system {system}")
|
|
||||||
|
|
||||||
|
|
||||||
def get_glibc_version():
|
|
||||||
try:
|
|
||||||
output = subprocess.check_output(["ldd", "--version"])
|
|
||||||
except:
|
|
||||||
return
|
|
||||||
output.splitlines()
|
|
||||||
version = output.splitlines()[0].split()[-1]
|
|
||||||
return version.decode("ascii")
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def add_glibc_virtual_package():
|
|
||||||
version = get_glibc_version()
|
|
||||||
here = os.path.dirname(os.path.abspath(__file__))
|
|
||||||
with open(os.path.join(here, "channel_a/linux-64/repodata.tpl")) as f:
|
|
||||||
repodata = f.read()
|
|
||||||
with open(os.path.join(here, "channel_a/linux-64/repodata.json"), "w") as f:
|
|
||||||
if version is not None:
|
|
||||||
glibc_placeholder = ', "__glibc=' + version + '"'
|
|
||||||
else:
|
|
||||||
glibc_placeholder = ""
|
|
||||||
repodata = repodata.replace("GLIBC_PLACEHOLDER", glibc_placeholder)
|
|
||||||
f.write(repodata)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def copy_channels_osx():
|
|
||||||
import shutil
|
|
||||||
|
|
||||||
here = os.path.dirname(os.path.abspath(__file__))
|
|
||||||
for channel in ["a", "b"]:
|
|
||||||
if not os.path.exists(os.path.join(here, f"channel_{channel}/osx-64")):
|
|
||||||
shutil.copytree(
|
|
||||||
os.path.join(here, f"channel_{channel}/linux-64"),
|
|
||||||
os.path.join(here, f"channel_{channel}/osx-64"),
|
|
||||||
)
|
|
||||||
with open(
|
|
||||||
os.path.join(here, f"channel_{channel}/osx-64/repodata.json")
|
|
||||||
) as f:
|
|
||||||
repodata = f.read()
|
|
||||||
with open(
|
|
||||||
os.path.join(here, f"channel_{channel}/osx-64/repodata.json"), "w"
|
|
||||||
) as f:
|
|
||||||
repodata = repodata.replace("linux", "osx")
|
|
||||||
f.write(repodata)
|
|
||||||
|
|
|
@ -11,6 +11,21 @@ import yaml
|
||||||
from . import helpers
|
from . import helpers
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def user_config_dir(tmp_home: Path):
|
||||||
|
"""Location of config files that are generated from mamba"""
|
||||||
|
maybe_xdg_config = os.getenv("XDG_CONFIG_DIR", "")
|
||||||
|
if maybe_xdg_config:
|
||||||
|
yield Path(maybe_xdg_config)
|
||||||
|
system = platform.system()
|
||||||
|
if system == "Linux" or system == "Darwin":
|
||||||
|
yield tmp_home / ".config/mamba"
|
||||||
|
elif system == "Windows":
|
||||||
|
yield Path(os.environ["APPDATA"]) / "mamba"
|
||||||
|
else:
|
||||||
|
raise RuntimeError(f"Unsupported system {system}")
|
||||||
|
|
||||||
|
|
||||||
class Dumper(yaml.Dumper):
|
class Dumper(yaml.Dumper):
|
||||||
"""A YAML dumper to properly indent lists.
|
"""A YAML dumper to properly indent lists.
|
||||||
|
|
||||||
|
|
|
@ -939,6 +939,47 @@ def test_long_path_support(tmp_home, tmp_root_prefix):
|
||||||
assert res["success"]
|
assert res["success"]
|
||||||
|
|
||||||
|
|
||||||
|
def get_glibc_version():
|
||||||
|
try:
|
||||||
|
output = subprocess.check_output(["ldd", "--version"])
|
||||||
|
except Exception:
|
||||||
|
return
|
||||||
|
output.splitlines()
|
||||||
|
version = output.splitlines()[0].split()[-1]
|
||||||
|
return version.decode("ascii")
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def add_glibc_virtual_package():
|
||||||
|
version = get_glibc_version()
|
||||||
|
with open(__this_dir__ / "channel_a/linux-64/repodata.tpl") as f:
|
||||||
|
repodata = f.read()
|
||||||
|
with open(__this_dir__ / "channel_a/linux-64/repodata.json", "w") as f:
|
||||||
|
if version is not None:
|
||||||
|
glibc_placeholder = ', "__glibc=' + version + '"'
|
||||||
|
else:
|
||||||
|
glibc_placeholder = ""
|
||||||
|
repodata = repodata.replace("GLIBC_PLACEHOLDER", glibc_placeholder)
|
||||||
|
f.write(repodata)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def copy_channels_osx():
|
||||||
|
for channel in ["a", "b"]:
|
||||||
|
if not (__this_dir__ / f"channel_{channel}/osx-64").exists():
|
||||||
|
shutil.copytree(
|
||||||
|
__this_dir__ / f"channel_{channel}/linux-64",
|
||||||
|
__this_dir__ / f"channel_{channel}/osx-64",
|
||||||
|
)
|
||||||
|
with open(__this_dir__ / f"channel_{channel}/osx-64/repodata.json") as f:
|
||||||
|
repodata = f.read()
|
||||||
|
with open(
|
||||||
|
__this_dir__ / f"channel_{channel}/osx-64/repodata.json", "w"
|
||||||
|
) as f:
|
||||||
|
repodata = repodata.replace("linux", "osx")
|
||||||
|
f.write(repodata)
|
||||||
|
|
||||||
|
|
||||||
def test_dummy_create(
|
def test_dummy_create(
|
||||||
add_glibc_virtual_package, copy_channels_osx, tmp_home, tmp_root_prefix
|
add_glibc_virtual_package, copy_channels_osx, tmp_home, tmp_root_prefix
|
||||||
):
|
):
|
||||||
|
|
Loading…
Reference in New Issue