Skip to content

Commit

Permalink
Merge branch 'master' into fix-module-issues
Browse files Browse the repository at this point in the history
  • Loading branch information
emeryberger authored Aug 12, 2023
2 parents 47b90ef + 63a5514 commit 4bd6e75
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 80 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-and-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ jobs:
- os: ubuntu-latest
container: quay.io/pypa/manylinux_2_24_x86_64 # https://github.com/pypa/manylinux
- os: macos-latest
python_version: 3.7
python_version: 3.11
upload_source: true # just need ONE of them to do it
exclude:
- os: windows-latest
python_version: 3.7
python_version: 3.11

container: ${{ matrix.container }}

Expand Down
1 change: 1 addition & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ vendor/printf/printf.cpp:
mkdir -p vendor && cd vendor && git clone https://github.com/mpaland/printf
cd vendor/printf && ln -s printf.c printf.cpp
sed -e 's/^#define printf printf_/\/\/&/' vendor/printf/printf.h > /tmp/printf.h.$$ && mv /tmp/printf.h.$$ vendor/printf/printf.h
sed -e 's/^#define vsnprintf vsnprintf_/\/\/&/' vendor/printf/printf.h > /tmp/printf.h.$$ && mv /tmp/printf.h.$$ vendor/printf/printf.h
# sed $(SED_INPLACE) -e 's/^#define printf printf_/\/\/&/' vendor/printf/printf.h

clear-vendor-dirs:
Expand Down
149 changes: 79 additions & 70 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 8 additions & 6 deletions scalene/scalene_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2028,20 +2028,22 @@ def run_profiler(
progs.extend((sys.argv[0], __file__))
if not progs:
raise FileNotFoundError
with open(progs[0], "r", encoding="utf-8") as prog_being_profiled:
# Use the full absolute path of the program being profiled, expanding ~ if need be.
prog_name = os.path.abspath(os.path.expanduser(progs[0]))
with open(prog_name, "r", encoding="utf-8") as prog_being_profiled:
# Read in the code and compile it.
code: Any = ""
try:
code = compile(
prog_being_profiled.read(),
os.path.abspath(progs[0]),
prog_name,
"exec",
)
except SyntaxError:
traceback.print_exc()
sys.exit(1)
# Push the program's path.
program_path = os.path.dirname(os.path.abspath(progs[0]))
program_path = os.path.dirname(prog_name)
if not module:
sys.path.insert(0, program_path)
# If a program path was specified at the command-line, use it.
Expand All @@ -2066,7 +2068,7 @@ def run_profiler(
the_locals = __main__.__dict__
the_globals = __main__.__dict__
# Splice in the name of the file being executed instead of the profiler.
the_globals["__file__"] = os.path.abspath(progs[0])
the_globals["__file__"] = prog_name
# This part works because of the order in which Python attempts to resolve names--
# Within a given context, it first tries to look for __package__, and then for __spec__.
# __spec__ is a ModuleSpec object that carries a lot of extra machinery and requires
Expand All @@ -2082,7 +2084,7 @@ def run_profiler(
# Do a GC before we start.
gc.collect()
# Start the profiler.
profiler = Scalene(args, Filename(os.path.abspath(progs[0])))
profiler = Scalene(args, Filename(prog_name))
try:
# We exit with this status (returning error code as appropriate).
exit_status = profiler.profile_code(
Expand All @@ -2103,7 +2105,7 @@ def run_profiler(
print(traceback.format_exc())
except (FileNotFoundError, IOError):
if progs:
print(f"Scalene: could not find input file {progs[0]}")
print(f"Scalene: could not find input file {prog_name}")
else:
print("Scalene: no input file specified.")
sys.exit(1)
Expand Down
4 changes: 2 additions & 2 deletions scalene/scalene_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Current version of Scalene; reported by --version."""

scalene_version = "1.5.23"
scalene_date = "2023.07.26"
scalene_version = "1.5.24"
scalene_date = "2023.08.09"

0 comments on commit 4bd6e75

Please sign in to comment.