Skip to content

Commit

Permalink
Merge pull request #204 from mgorny/fix-helper-install
Browse files Browse the repository at this point in the history
Install cysignals-CSI-helper as package data for better portability
  • Loading branch information
dimpase authored Nov 19, 2024
2 parents 6633f1e + a639d62 commit 9f39b7d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
5 changes: 4 additions & 1 deletion src/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
from _pytest.nodes import Collector
from _pytest.doctest import DoctestModule

# cysignals-CSI only works from gdb, i.e. invoke ./testgdb.py directly
collect_ignore = ["cysignals/cysignals-CSI-helper.py"]

if platform.system() == "Windows":
collect_ignore = [
collect_ignore += [
"cysignals/alarm.pyx",
"cysignals/pselect.pyx",
"cysignals/pysignals.pyx",
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions src/cysignals/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ configure_file(output: 'cysignals_config.h', configuration: config, install_dir:

py.install_sources(
'__init__.py',
'cysignals-CSI-helper.py',
'memory.pxd',
'pysignals.pxd',
'signals.pxd',
Expand Down
16 changes: 7 additions & 9 deletions src/scripts/cysignals-CSI
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import site
from argparse import ArgumentParser
from datetime import datetime
from shutil import which
import importlib.resources as importlib_resources


def pid_exists(pid):
Expand All @@ -65,15 +66,12 @@ def gdb_commands(pid, color):
cmds += b'import sys; sys.stdout.flush()\n'
cmds += b'end\n'
cmds += b'bt full\n'
cysignals_share = os.path.join(os.path.dirname(sys.argv[0]), '..',
'share', 'cysignals')
script = os.path.join(cysignals_share, 'cysignals-CSI-helper.py')
with open(script, 'rb') as f:
cmds += b'python\n'
cmds += b'color = %r; ' % color
cmds += b'sys_path = %r; ' % sys.path
cmds += f.read()
cmds += b'end\n'
script = importlib_resources.files('cysignals') / 'cysignals-CSI-helper.py'
cmds += b'python\n'
cmds += b'color = %r; ' % color
cmds += b'sys_path = %r; ' % sys.path
cmds += script.read_bytes()
cmds += b'end\n'
cmds += b'detach inferior 1\n'
cmds += b'quit\n'
return cmds
Expand Down
3 changes: 2 additions & 1 deletion src/scripts/meson.build
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
install_data('cysignals-CSI-helper.py', install_dir: py.get_install_dir(pure: false) / 'cysignals' / 'data')
install_data('cysignals-CSI', install_dir : get_option('bindir'))

0 comments on commit 9f39b7d

Please sign in to comment.