-
Notifications
You must be signed in to change notification settings - Fork 2
Core: Fix pytest rebuilder and improve editable installation detection #108
Conversation
src/faebryk/core/cpp/__init__.py
Outdated
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]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hit an issue and apparently this is a more robust way to detect editable installation: https://stackoverflow.com/questions/43348746/how-to-detect-if-module-is-installed-in-editable-mode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice!
src/faebryk/core/cpp/__init__.py
Outdated
@@ -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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes a venv issues I had causing pytest failures
1777d88
to
c9a921c
Compare
c9a921c
to
4d88d57
Compare
|
||
def test_add(): | ||
from faebryk.core.cpp import add |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Importing here yields vastly better errors on import failures. It's common/recommended with pytest anyway
@@ -1082,3 +1084,54 @@ def setdefault(self, key: T, default: U) -> U: | |||
except KeyError: | |||
self[key] = default | |||
return default | |||
|
|||
|
|||
def run_live( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had a little help from our dear friend Claude to go a bit bananas here. Was very helpful for debugging. I'd dump the streams just afterwards, but it's quite hard to tell in what order something was sent to stdout
or stderr
like that
Fixes # (issue)
Checklist
Please read and execute the following:
Code of Conduct
By submitting this issue, you agree to follow our Code of Conduct: