Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
Core: Fix pytest rebuilder and improve editable installation detection
Browse files Browse the repository at this point in the history
  • Loading branch information
mawildoer committed Oct 28, 2024
1 parent d28810e commit 1584e7e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/faebryk/core/cpp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
# This file is part of the faebryk project
# SPDX-License-Identifier: MIT

import json
import logging
import pathlib
import shutil
import site
from importlib.metadata import Distribution
from typing import Callable

logger = logging.getLogger(__name__)


# Check if installed as editable
def is_editable_install():
site_packages = site.getsitepackages()
return not any((pathlib.Path(sp) / "faebryk").exists() for sp in site_packages)
distro = Distribution.from_name(__name__.split(".")[0])
return (
json.loads(distro.read_text("direct_url.json"))
.get("dir_info", {})
.get("editable", False)
)


def compile_and_load():
Expand Down Expand Up @@ -43,7 +48,7 @@ def _do(*args, **kwargs):
"cmake not found, needed for compiling c++ code in editable mode"
)

pybind11_dir = _do(["python", "-m", "pybind11", "--cmakedir"]).strip()
pybind11_dir = _do([sys.executable, "-m", "pybind11", "--cmakedir"]).strip()

# Force recompile
# subprocess.run(["rm", "-rf", str(build_dir)], check=True)
Expand Down

0 comments on commit 1584e7e

Please sign in to comment.