Skip to content

Commit

Permalink
windows pip install failed
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbertDeFusco committed Apr 25, 2024
1 parent e1331c0 commit 8adc7de
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 91 deletions.
89 changes: 0 additions & 89 deletions src/conda_project/conda.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,92 +318,3 @@ def conda_activate(prefix: Path, working_dir: Path, env: Optional[Dict] = None):
)

_send_activation(child_shell, prefix)

# local_dependencies = {}
# for dep in p.depends:
# matchspec = MatchSpec(dep)
# name = matchspec.name
# version = (
# matchspec.version.spec_str if matchspec.version is not None else ""
# )
# local_dependencies[name] = version

# if p.schannel == "pypi":
# if "WHEEL" in str(p.package_type):
# for fn in p.files:
# fn = prefix / Path(fn)
# if fn.name == "WHEEL":
# with fn.open() as f:
# data = f.readlines()
# lines = [line for line in data if line.startswith("Tag")]
# if lines:
# tag = lines[0].split(":", maxsplit=1)[1].strip()
# wheel = f"{p.name}-{p.version}-{tag}.whl"
# parsed = parse_wheel_filename(wheel)
# url = f"https://files.pythonhosted.org/packages/{parsed.python_tags[0]}/"
# f"{parsed.project[0]}/{parsed.project}/{p.name}-{p.version}-{tag}.whl"
# break
# else:
# url = f"https://pypi.io/packages/source/{p.name[0]}/{p.name}/{p.name}-{p.version}.tar.gz"
# else:
# url = str(p.url)

# locked.append(LockedDependency(
# name=p.name,
# version=p.version,
# manager="pip" if p.schannel == "pypi" else "conda",
# platform="unknown",
# dependencies=local_dependencies,
# url=url,
# hash=HashModel(
# md5=p.get("md5"),
# sha256=p.get("sha256")
# ),
# ))
# lock_content = Lockfile(
# package=locked,
# metadata=LockMeta(
# content_hash=spec.content_hash(),
# channels=list(),
# platforms=[current_platform()],
# sources=["environment.yml"],
# ),
# )


# def requested_packages(prefix: Path, with_version: bool = True) -> EnvironmentYaml:
# proc = call_conda(["env", "export", "--from-history", "-p", str(prefix), "--json"])
# requested = json.loads(proc.stdout)

# proc = call_conda(["env", "export", "-p", str(prefix), "--json"])
# full = json.loads(proc.stdout)

# if with_version:
# versioned_dependencies = []

# dependencies = {}
# for d in requested["dependencies"]:
# split = d.split("::", maxsplit=1)
# if len(split) == 1:
# name = split[0].split("=")[0]
# dependencies[name] = ""
# else:
# channel, name = split
# dependencies[name.split("=")[0]] = f"{channel}::"

# for d in full["dependencies"]:
# if isinstance(d, str):
# name, version, _ = d.split("=")
# if name in dependencies:
# prefix = dependencies[name]
# versioned_dependencies.append(f"{prefix}{name}={version}")

# requested["dependencies"] = versioned_dependencies

# pip_pkgs = [p for p in full["dependencies"] if isinstance(p, dict) and "pip" in p]
# if pip_pkgs:
# pip_pkgs = [p for p in pip_pkgs[0]["pip"] if not p.startswith("anaconda")]
# requested["dependencies"].append({"pip": pip_pkgs})

# environment = EnvironmentYaml(**requested)
# return environment
26 changes: 24 additions & 2 deletions tests/test_conda.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,18 @@ def test_env_export_from_history_with_pip(empty_conda_environment):
_ = call_conda(
["install", "python=3.11", "pip", "-p", empty_conda_environment, "-y"]
)
_ = call_conda(["run", "-p", empty_conda_environment, "pip", "install", "requests"])
_ = call_conda(
[
"run",
"-p",
empty_conda_environment,
"python",
"-m",
"pip",
"install",
"requests",
]
)

env, lock = env_export(empty_conda_environment)
assert len(env.dependencies[-1]["pip"]) == 1
Expand All @@ -309,7 +320,18 @@ def test_env_export_full_with_pip(empty_conda_environment):
_ = call_conda(
["install", "python=3.11", "pip", "-p", empty_conda_environment, "-y"]
)
_ = call_conda(["run", "-p", empty_conda_environment, "pip", "install", "requests"])
_ = call_conda(
[
"run",
"-p",
empty_conda_environment,
"python",
"-m",
"pip",
"install",
"requests",
]
)

env, lock = env_export(empty_conda_environment, from_history=False)
assert len(env.dependencies[-1]["pip"]) == len(
Expand Down

0 comments on commit 8adc7de

Please sign in to comment.