Skip to content

Commit

Permalink
new: pip loader will explicitly import the installed package
Browse files Browse the repository at this point in the history
  • Loading branch information
evilsocket committed Jan 18, 2025
1 parent eed3260 commit 4559439
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions dyana/loaders/npm/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
package_name = re.split("[^a-zA-Z0-9_-]", args.package)[0]
result = subprocess.run(["node", "-e", f"require('{package_name}')"], capture_output=True, text=True)

profiler.track("require_exit_code", result.returncode)
profiler.track("require_stdout", result.stdout)
profiler.track("require_stderr", result.stderr)
profiler.track("exit_code", result.returncode)
profiler.track("stdout", result.stdout)
profiler.track("stderr", result.stderr)

except Exception as e:
profiler.track_error("npm", str(e))
Expand Down
9 changes: 9 additions & 0 deletions dyana/loaders/pip/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import argparse
import json
import re
import subprocess
import sys

Expand All @@ -17,6 +18,14 @@
)
profiler.track_memory("after_installation")
profiler.track_disk("after_installation")

# explicitly require the package to make sure it's loaded
package_name = re.split("[^a-zA-Z0-9_-]", args.package)[0]
result = subprocess.run(["python3", "-c", f"import {package_name}"], capture_output=True, text=True)

profiler.track("exit_code", result.returncode)
profiler.track("stdout", result.stdout)
profiler.track("stderr", result.stderr)
except Exception as e:
profiler.track_error("pip", str(e))

Expand Down

0 comments on commit 4559439

Please sign in to comment.