From 0c30b9ef730770cf6ddd8b0c8c846affd8c30404 Mon Sep 17 00:00:00 2001 From: Robert Schütz Date: Sun, 14 Jun 2020 15:10:07 +0200 Subject: python.pkgs.dot2tex: enable python3 and run tests --- .../development/python-modules/dot2tex/default.nix | 24 ++++- pkgs/development/python-modules/dot2tex/path.patch | 104 +++++++++++++++++++++ pkgs/development/python-modules/dot2tex/test.patch | 12 +++ pkgs/top-level/python-packages.nix | 4 +- 4 files changed, 140 insertions(+), 4 deletions(-) create mode 100644 pkgs/development/python-modules/dot2tex/path.patch create mode 100644 pkgs/development/python-modules/dot2tex/test.patch (limited to 'pkgs') diff --git a/pkgs/development/python-modules/dot2tex/default.nix b/pkgs/development/python-modules/dot2tex/default.nix index f671cdc9642..03445f79117 100644 --- a/pkgs/development/python-modules/dot2tex/default.nix +++ b/pkgs/development/python-modules/dot2tex/default.nix @@ -1,8 +1,11 @@ { stdenv +, python , buildPythonPackage , fetchPypi -, isPy3k +, substituteAll , pyparsing +, graphviz +, texlive }: buildPythonPackage rec { @@ -14,11 +17,26 @@ buildPythonPackage rec { sha256 = "1kp77wiv7b5qib82i3y3sn9r49rym43aaqm5aw1bwnzfbbq2m6i9"; }; - # Tests fail with 3.x. Furthermore, package is no longer maintained. - disabled = isPy3k; + patches = [ + (substituteAll { + src = ./path.patch; + inherit graphviz; + }) + ./test.patch # https://github.com/kjellmf/dot2tex/issues/5 + ]; propagatedBuildInputs = [ pyparsing ]; + checkInputs = [ + (texlive.combine { + inherit (texlive) scheme-small preview pstricks; + }) + ]; + + checkPhase = '' + ${python.interpreter} tests/test_dot2tex.py + ''; + meta = with stdenv.lib; { description = "Convert graphs generated by Graphviz to LaTeX friendly formats"; homepage = "https://github.com/kjellmf/dot2tex"; diff --git a/pkgs/development/python-modules/dot2tex/path.patch b/pkgs/development/python-modules/dot2tex/path.patch new file mode 100644 index 00000000000..4e05b7a8dff --- /dev/null +++ b/pkgs/development/python-modules/dot2tex/path.patch @@ -0,0 +1,104 @@ +diff --git a/dot2tex/dotparsing.py b/dot2tex/dotparsing.py +index 391b5dc..6dc77a3 100644 +--- a/dot2tex/dotparsing.py ++++ b/dot2tex/dotparsing.py +@@ -180,18 +180,8 @@ def __find_executables(path): + def find_graphviz(): + """Locate Graphviz's executables in the system. + +- Tries three methods: +- +- First: Windows Registry (Windows only) +- This requires Mark Hammond's pywin32 is installed. +- +- Secondly: Search the path +- It will look for 'dot', 'twopi' and 'neato' in all the directories +- specified in the PATH environment variable. +- +- Thirdly: Default install location (Windows only) +- It will look for 'dot', 'twopi' and 'neato' in the default install +- location under the "Program Files" directory. ++ It will look for 'dot', 'twopi' and 'neato' in ++ @graphviz@/bin. + + It will return a dictionary containing the program names as keys + and their paths as values. +@@ -199,75 +189,9 @@ def find_graphviz(): + If this fails, it returns None. + """ + +- # Method 1 (Windows only) +- # +- if os.sys.platform == 'win32': +- try: +- import win32api, win32con +- +- # Get the GraphViz install path from the registry +- # +- hkey = win32api.RegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE, +- "SOFTWARE\AT&T Research Labs\Graphviz", 0, win32con.KEY_QUERY_VALUE) +- +- path = win32api.RegQueryValueEx(hkey, "InstallPath")[0] +- win32api.RegCloseKey(hkey) +- +- # Now append the "bin" subdirectory: +- # +- path = os.path.join(path, "bin") +- progs = __find_executables(path) +- if progs is not None: +- # print("Used Windows registry") +- return progs +- +- except ImportError: +- # Print a messaged suggesting they install these? +- # +- log.debug('The win32api is not installed') +- pass +- except: +- log.debug('Failed to access the registry key') +- +- # Method 2 (Linux, Windows etc) +- # +- if 'PATH' in os.environ: +- for path in os.environ['PATH'].split(os.pathsep): +- progs = __find_executables(path) +- if progs is not None: +- return progs +- +- # Method 3 (Windows only) +- # +- if os.sys.platform == 'win32': +- # Try and work out the equivalent of "C:\Program Files" on this +- # machine (might be on drive D:, or in a different language) +- # +- if 'PROGRAMFILES' in os.environ: +- # Note, we could also use the win32api to get this +- # information, but win32api may not be installed. +- +- path = os.path.join(os.environ['PROGRAMFILES'], 'ATT', 'GraphViz', 'bin') +- +- else: +- # Just in case, try the default... +- path = r"C:\Program Files\att\Graphviz\bin" +- +- progs = __find_executables(path) +- +- if progs is not None: +- # print("Used default install location") +- return progs +- +- for path in ( +- '/usr/bin', '/usr/local/bin', +- '/opt/local/bin', +- '/opt/bin', '/sw/bin', '/usr/share', +- '/Applications/Graphviz.app/Contents/MacOS/'): +- progs = __find_executables(path) +- if progs is not None: +- # print("Used path") +- return progs ++ progs = __find_executables('@graphviz@/bin') ++ if progs is not None: ++ return progs + + # Failed to find GraphViz + # diff --git a/pkgs/development/python-modules/dot2tex/test.patch b/pkgs/development/python-modules/dot2tex/test.patch new file mode 100644 index 00000000000..9ead8ac5ee5 --- /dev/null +++ b/pkgs/development/python-modules/dot2tex/test.patch @@ -0,0 +1,12 @@ +diff --git a/tests/test_dot2tex.py b/tests/test_dot2tex.py +index 74b01ed..7be9aba 100644 +--- a/tests/test_dot2tex.py ++++ b/tests/test_dot2tex.py +@@ -147,6 +147,7 @@ class NeedsQuotesTests(unittest.TestCase): + + class MultipleStatements(unittest.TestCase): + # https://github.com/kjellmf/dot2tex/issues/5 ++ @unittest.skip('fails upstream') + def test_semicolon(self): + """Test for issue 5""" + testgraph1 = """ diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 00960b45725..f984ed6f89b 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -6773,7 +6773,9 @@ in { jenkins-job-builder = callPackage ../development/python-modules/jenkins-job-builder { }; - dot2tex = callPackage ../development/python-modules/dot2tex { }; + dot2tex = callPackage ../development/python-modules/dot2tex { + inherit (pkgs) graphviz; + }; poezio = callPackage ../applications/networking/instant-messengers/poezio { inherit (pkgs) pkgconfig; -- cgit 1.4.1 From 423552868506d4ff8d7eef9e7fba34e5c367a665 Mon Sep 17 00:00:00 2001 From: Robert Schütz Date: Sun, 14 Jun 2020 15:10:39 +0200 Subject: dot2tex: use python3 --- pkgs/top-level/all-packages.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pkgs') diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index bd298ce24ea..1d1ab18fbed 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -10357,7 +10357,7 @@ in dolt = callPackage ../servers/sql/dolt { }; - dot2tex = pythonPackages.dot2tex; + dot2tex = with python3.pkgs; toPythonApplication dot2tex; doxygen = callPackage ../development/tools/documentation/doxygen { qt4 = null; -- cgit 1.4.1