Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

- `edsnlp.package` now correctly detect if a project uses an old-style poetry pyproject or a PEP621 pyproject.toml.
- PEP621 projects containing nested directories (e.g., "my_project/pipes/foo.py") are now supported.
- Try several paths to find current pip executable

## v0.16.0 (2025-0.3-26)

Expand Down
16 changes: 15 additions & 1 deletion edsnlp/core/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1305,10 +1305,22 @@ def load_from_huggingface(
new_mtime = max(os.path.getmtime(x) for x in Path(path).rglob("*"))
should_install = new_mtime != mtime

pip = os.path.join(sysconfig.get_path("scripts"), "pip")
pip_paths = [
os.path.join(sys.exec_prefix, "bin", "pip"),
os.path.join(sys.executable.rsplit("/", 1)[0], "pip"),
os.path.join(sysconfig.get_path("scripts"), "pip"),
os.path.join(sys.exec_prefix, "bin", "pip3"),
os.path.join(sys.executable.rsplit("/", 1)[0], "pip3"),
os.path.join(sysconfig.get_path("scripts"), "pip3"),
]
pip = next((p for p in pip_paths if os.path.exists(p)), None)
pip = pip or shutil.which("pip")

if should_install or not any(
p.startswith(module_name) and p.endswith(".dist-info") for p in os.listdir(path)
):
if pip is None:
raise RuntimeError(f"Couldn't find pip amongst {', '.join(pip_paths)}")
subprocess.run(
[pip, "install", "-e", path, "--target", path, "--no-deps", "--upgrade"]
)
Expand Down Expand Up @@ -1344,6 +1356,8 @@ def load_from_huggingface(
f"pip install {' '.join((repr(str(dep)) for dep in missing_deps))}",
UserWarning,
)
if pip is None:
raise RuntimeError(f"Couldn't find pip amongst {', '.join(pip_paths)}")
subprocess.run([pip, "install", *(str(d) for d in missing_deps)])
module = importlib.import_module(module_name)
return module.load(**kwargs)
Expand Down
Loading