about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/python-modules/objgraph
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2019-02-07 15:19:21 +0000
committerAlyssa Ross <hi@alyssa.is>2019-02-07 23:35:47 +0000
commite5013c05a2f845255debf94318ab38ecef1c186b (patch)
treebec11a0bd31d3432a16899e5539f1098f1c168a4 /nixpkgs/pkgs/development/python-modules/objgraph
parent4fc07c92ec07cafcf6d56143ea7334693143ef88 (diff)
parent2d2f10475138b7206572dc3ec288184df2be022e (diff)
downloadnixlib-e5013c05a2f845255debf94318ab38ecef1c186b.tar
nixlib-e5013c05a2f845255debf94318ab38ecef1c186b.tar.gz
nixlib-e5013c05a2f845255debf94318ab38ecef1c186b.tar.bz2
nixlib-e5013c05a2f845255debf94318ab38ecef1c186b.tar.lz
nixlib-e5013c05a2f845255debf94318ab38ecef1c186b.tar.xz
nixlib-e5013c05a2f845255debf94318ab38ecef1c186b.tar.zst
nixlib-e5013c05a2f845255debf94318ab38ecef1c186b.zip
Merge commit '2d2f10475138b7206572dc3ec288184df2be022e'
Diffstat (limited to 'nixpkgs/pkgs/development/python-modules/objgraph')
-rw-r--r--nixpkgs/pkgs/development/python-modules/objgraph/default.nix9
-rw-r--r--nixpkgs/pkgs/development/python-modules/objgraph/hardcode-graphviz-path.patch61
2 files changed, 70 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/python-modules/objgraph/default.nix b/nixpkgs/pkgs/development/python-modules/objgraph/default.nix
index 16dc60fc28a3..0eb1deee0d39 100644
--- a/nixpkgs/pkgs/development/python-modules/objgraph/default.nix
+++ b/nixpkgs/pkgs/development/python-modules/objgraph/default.nix
@@ -2,6 +2,8 @@
 , buildPythonPackage
 , fetchPypi
 , isPyPy
+, substituteAll
+, graphvizPkg
 , graphviz
 , mock
 }:
@@ -18,6 +20,13 @@ buildPythonPackage rec {
   # Tests fail with PyPy.
   disabled = isPyPy;
 
+  patches = [
+    (substituteAll {
+      src = ./hardcode-graphviz-path.patch;
+      graphviz = graphvizPkg;
+    })
+  ];
+
   propagatedBuildInputs = [ graphviz ];
 
   checkInputs = [ mock ];
diff --git a/nixpkgs/pkgs/development/python-modules/objgraph/hardcode-graphviz-path.patch b/nixpkgs/pkgs/development/python-modules/objgraph/hardcode-graphviz-path.patch
new file mode 100644
index 000000000000..c5be5de64eed
--- /dev/null
+++ b/nixpkgs/pkgs/development/python-modules/objgraph/hardcode-graphviz-path.patch
@@ -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')