push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
{
lib,
buildPythonPackage,
fetchPypi,
graphviz,
graphvizPkgs,
isPyPy,
python,
pythonOlder,
replaceVars,
setuptools,
}:
buildPythonPackage rec {
pname = "objgraph";
version = "3.6.2";
pyproject = true;
disabled = pythonOlder "3.7" || isPyPy;
src = fetchPypi {
inherit pname version;
hash = "sha256-ALny9A90IuPH9FphxNr9r4HwP/BknW6uyGbwEDDlGtg=";
};
patches = [
(replaceVars ./hardcode-graphviz-path.patch {
graphviz = graphvizPkgs;
})
];
build-system = [
setuptools
];
optional-dependencies = {
ipython = [ graphviz ];
};
pythonImportsCheck = [ "objgraph" ];
checkPhase = ''
runHook preCheck
${python.interpreter} tests.py
runHook postCheck
'';
meta = with lib; {
description = "Draws Python object reference graphs with graphviz";
homepage = "https://mg.pov.lt/objgraph/";
changelog = "https://github.com/mgedmin/objgraph/blob/${version}/CHANGES.rst";
license = licenses.mit;
maintainers = with maintainers; [ dotlambda ];
};
}

View File

@@ -0,0 +1,61 @@
diff --git a/objgraph.py b/objgraph.py
index 88e307b..0369f49 100755
--- a/objgraph.py
+++ b/objgraph.py
@@ -1045,12 +1045,12 @@ def _present_graph(dot_filename, filename=None):
if not filename and _program_in_path('xdot'):
print("Spawning graph viewer (xdot)")
subprocess.Popen(['xdot', dot_filename], close_fds=True)
- elif _program_in_path('dot'):
+ elif True: # path to dot is hardcoded and hence always in $PATH
if not filename:
print("Graph viewer (xdot) not found, generating a png instead")
filename = dot_filename[:-4] + '.png'
stem, ext = os.path.splitext(filename)
- cmd = ['dot', '-T' + ext[1:], '-o' + filename, dot_filename]
+ cmd = ['@graphviz@/bin/dot', '-T' + ext[1:], '-o' + filename, dot_filename]
dot = subprocess.Popen(cmd, close_fds=False)
dot.wait()
if dot.returncode != 0:
diff --git a/tests.py b/tests.py
index 7db2888..bdb666e 100755
--- a/tests.py
+++ b/tests.py
@@ -557,7 +557,7 @@ class PresentGraphTest(CaptureMixin, TemporaryDirectoryMixin,
self.programsInPath(['dot'])
objgraph._present_graph('foo.dot', 'bar.png')
self.assertOutput("""
- subprocess.Popen(['dot', '-Tpng', '-obar.png', 'foo.dot'])
+ subprocess.Popen(['@graphviz@/bin/dot', '-Tpng', '-obar.png', 'foo.dot'])
Image generated as bar.png
""")
@@ -566,11 +566,12 @@ class PresentGraphTest(CaptureMixin, TemporaryDirectoryMixin,
objgraph.subprocess.should_fail = True
objgraph._present_graph('f.dot', 'b.png')
self.assertOutput("""
- subprocess.Popen(['dot', '-Tpng', '-ob.png', 'f.dot'])
- dot failed (exit code 1) while executing "dot -Tpng -ob.png f.dot"
+ subprocess.Popen(['@graphviz@/bin/dot', '-Tpng', '-ob.png', 'f.dot'])
+ dot failed (exit code 1) while executing "@graphviz@/bin/dot -Tpng -ob.png f.dot"
""")
- def test_present_png_no_dot(self):
+ @unittest.skip("empty $PATH has no effect")
+ def no_test_present_png_no_dot(self):
self.programsInPath([])
objgraph._present_graph('foo.dot', 'bar.png')
self.assertOutput("""
@@ -591,10 +592,11 @@ class PresentGraphTest(CaptureMixin, TemporaryDirectoryMixin,
objgraph._present_graph('foo.dot')
self.assertOutput("""
Graph viewer (xdot) not found, generating a png instead
- subprocess.Popen(['dot', '-Tpng', '-ofoo.png', 'foo.dot'])
+ subprocess.Popen(['@graphviz@/bin/dot', '-Tpng', '-ofoo.png', 'foo.dot'])
Image generated as foo.png
""")
+ @unittest.skip("empty $PATH has no effect")
def test_present_no_xdot_and_no_not(self):
self.programsInPath([])
objgraph._present_graph('foo.dot')