Skip to content

Commit

Permalink
temporary debug messages
Browse files Browse the repository at this point in the history
  • Loading branch information
mbway committed Feb 29, 2024
1 parent 5408172 commit 6a17180
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 2 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/test_pypy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: TestPyPy

on:
workflow_dispatch:

jobs:
test:
name: Test
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: pypy3.10
architecture: "x64"
- name: Create venv
run: python -m venv venv
- name: Run test
run: |
set PATH="%PWD%\venv\Scripts;%PATH%"
set VIRTUAL_ENV="%PWD%\venv"
"venv\Scripts\python.exe" example.py
19 changes: 19 additions & 0 deletions example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import multiprocessing
import os
import sys


def worker() -> None:
print(f"worker process executable: {sys.executable}")
print(f"worker process exec_prefix: {sys.exec_prefix}")
print(f"worker process env: {os.environ}")


if __name__ == "__main__":
print(f"main process executable: {sys.executable}")
print(f"main process exec_prefix: {sys.exec_prefix}")
print(f"main process env: {os.environ}")

p = multiprocessing.Process(target=worker)
p.start()
p.join()
2 changes: 2 additions & 0 deletions src/maturin_import_hook/project_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def find_spec(
logger.debug(
'%s searching for "%s"%s', type(self).__name__, package_name, " (reload)" if already_loaded else ""
)
logger.debug("search paths: %s", sys.path)

start = time.perf_counter()

Expand All @@ -133,6 +134,7 @@ def find_spec(
spec = None
rebuilt = False
for search_path in search_paths:
logger.debug("contents of %s:\n%s", search_path, sorted(os.listdir(search_path)))
project_dir, is_editable = _load_dist_info(search_path, package_name)
if project_dir is not None:
logger.debug('found project linked by dist-info: "%s"', project_dir)
Expand Down
11 changes: 9 additions & 2 deletions tests/test_import_hook/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,16 @@ def run_python(
) -> Tuple[str, float]:
start = time.perf_counter()

cmd = [sys.executable]
interpreter_path = sys.executable

msg = f"python executable on the subprocess: {sys.executable} ({sys.exec_prefix})"
raise PythonProcessError(msg)

cmd = [interpreter_path]
if profile is not None:
cmd += ["-m", "cProfile", "-o", str(profile.resolve())]
cmd.extend(args)
log.info("running python")
log.info("running python ('%s')", interpreter_path)
try:
proc = subprocess.run(
cmd,
Expand All @@ -161,6 +166,8 @@ def run_python(
"-" * 40,
"Called Process Error:",
subprocess.list2cmdline(cmd),
"Env:",
str(os.environ),
"Output:",
output,
"-" * 40,
Expand Down
1 change: 1 addition & 0 deletions tests/test_import_hook/test_project_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ def test_concurrent_import(workspace: Path, initially_mixed: bool, mixed: bool)

args = {"python_script": check_installed_with_hook, "quiet": True}

log.info("python executable on the main thread: %s (%s)", sys.executable, sys.exec_prefix)
outputs = run_concurrent_python(3, run_python_code, args)

num_compilations = 0
Expand Down

0 comments on commit 6a17180

Please sign in to comment.