From e41c2ce5eaaae890996c2a7175a09a299b4b8182 Mon Sep 17 00:00:00 2001 From: Jay Qi Date: Fri, 9 Feb 2024 01:31:45 -0500 Subject: [PATCH 1/4] Import dependencies_in_sync from hatchling instead of using shell command --- hatch_conda/plugin.py | 11 ++++++----- pyproject.toml | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/hatch_conda/plugin.py b/hatch_conda/plugin.py index 5744fdc..8f4dda2 100644 --- a/hatch_conda/plugin.py +++ b/hatch_conda/plugin.py @@ -213,12 +213,13 @@ def dependencies_in_sync(self): if not self.dependencies: return True self.apply_env_vars() - with self: - process = self.platform.run_command( - " ".join(["hatchling", "dep", "synced", "-p", "python", *self.dependencies]), - capture_output=True, + + from hatchling.dep.core import dependencies_in_sync + + with self.safe_activation(): + return dependencies_in_sync( + self.dependencies_complex, sys_path=self.virtual_env.sys_path, environment=self.virtual_env.environment ) - return not process.returncode def sync_dependencies(self): self.apply_env_vars() diff --git a/pyproject.toml b/pyproject.toml index cde5e7f..4ee4ec9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,6 +33,7 @@ classifiers = [ ] dependencies = [ "hatch>=1.2.0", + "hatchling>=1.0.0", "pexpect~=4.8", ] dynamic = ["version"] @@ -87,4 +88,4 @@ exclude_lines = ["no cov", "if __name__ == .__main__.:", "if TYPE_CHECKING:", "r exclude = [".direnv", ] select = ["B","C","E","F","W","B001","B003","B006","B007","B301","B305","B306","B902","Q001","Q002","Q003"] ignore = ["E203","E722","W503"] -max-line-length = 120 \ No newline at end of file +max-line-length = 120 From aabcfd5df0f867935c5734624cb51303fa3619dd Mon Sep 17 00:00:00 2001 From: Jay Qi Date: Fri, 9 Feb 2024 01:44:29 -0500 Subject: [PATCH 2/4] safe_activation is not implemented, use self context manager --- hatch_conda/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hatch_conda/plugin.py b/hatch_conda/plugin.py index 8f4dda2..117537f 100644 --- a/hatch_conda/plugin.py +++ b/hatch_conda/plugin.py @@ -216,7 +216,7 @@ def dependencies_in_sync(self): from hatchling.dep.core import dependencies_in_sync - with self.safe_activation(): + with self: return dependencies_in_sync( self.dependencies_complex, sys_path=self.virtual_env.sys_path, environment=self.virtual_env.environment ) From 05dc5077217ae8326bf6caae8c369054ef968632 Mon Sep 17 00:00:00 2001 From: Jay Qi Date: Fri, 9 Feb 2024 01:56:04 -0500 Subject: [PATCH 3/4] Get sys_path --- hatch_conda/plugin.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hatch_conda/plugin.py b/hatch_conda/plugin.py index 117537f..3a9453f 100644 --- a/hatch_conda/plugin.py +++ b/hatch_conda/plugin.py @@ -12,6 +12,7 @@ import pexpect from hatch.env.plugin.interface import EnvironmentInterface +from hatch.utils.env import PythonInfo class ShellManager: @@ -216,9 +217,10 @@ def dependencies_in_sync(self): from hatchling.dep.core import dependencies_in_sync + python_info = PythonInfo(self.platform) with self: return dependencies_in_sync( - self.dependencies_complex, sys_path=self.virtual_env.sys_path, environment=self.virtual_env.environment + self.dependencies_complex, sys_path=python_info.sys_path, environment=self.virtual_env.environment ) def sync_dependencies(self): From 8c40665d2ac43b2d5c95eeb390c7369e02b6e828 Mon Sep 17 00:00:00 2001 From: Jay Qi Date: Fri, 9 Feb 2024 01:59:15 -0500 Subject: [PATCH 4/4] Use PythonInfo environment --- hatch_conda/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hatch_conda/plugin.py b/hatch_conda/plugin.py index 3a9453f..45fbcea 100644 --- a/hatch_conda/plugin.py +++ b/hatch_conda/plugin.py @@ -220,7 +220,7 @@ def dependencies_in_sync(self): python_info = PythonInfo(self.platform) with self: return dependencies_in_sync( - self.dependencies_complex, sys_path=python_info.sys_path, environment=self.virtual_env.environment + self.dependencies_complex, sys_path=python_info.sys_path, environment=python_info.environment ) def sync_dependencies(self):