conda-forge / python-graphviz-feedstock

A conda-smithy repository for python-graphviz.
BSD 3-Clause "New" or "Revised" License
3 stars 12 forks source link

Fix windows-bat.patch #25

Closed dinya closed 5 years ago

dinya commented 5 years ago

Please, return the master version of windows-bat.patch (it's empty) to the previous one.

Without this patch the python-graphviz doesn't work correctly under Windows with graphviz from conda.

See also xflr6/graphviz/issues/65

scopatz commented 5 years ago

Can you put in a PR please?

StrikerRUS commented 5 years ago

Met the same problem after recent 0.10.1 release. @dinya Thanks for your workaround! Hope that a fix will be in next release.

scopatz commented 5 years ago

A PR would be great!

jakirkham commented 5 years ago

I think it is just a matter of reverting commit ( https://github.com/conda-forge/python-graphviz-feedstock/pull/24/commits/2a4f1a8145bbf79823c40d723821eb16c9689235 ), right?

Should we just mark packages in the current release as broken?

scopatz commented 5 years ago

Again a PR would be great!

StrikerRUS commented 5 years ago

Any news? Is it fixed in 0.11?

scopatz commented 5 years ago

I don't have a good way of testing on windows, myself.

StrikerRUS commented 5 years ago

Just checked it with 0.11 version: still fails.

## Package Plan ##

  environment location: C:\Miniconda\envs\test-env

  added / updated specs:
    - python-graphviz

The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    ca-certificates-2019.3.9   |       hecc5488_0         184 KB  conda-forge
    certifi-2018.8.24          |        py35_1001         139 KB  conda-forge
    graphviz-2.38.0            |    h6538335_1011        41.0 MB  conda-forge
    openssl-1.1.1b             |       hfa6e2cd_2         4.8 MB  conda-forge
    python-graphviz-0.11       |             py_0          17 KB  conda-forge
    ------------------------------------------------------------
                                           Total:        46.1 MB

The following NEW packages will be INSTALLED:

  graphviz           conda-forge/win-64::graphviz-2.38.0-h6538335_1011
  python-graphviz    conda-forge/noarch::python-graphviz-0.11-py_0
Error (clickable): ``` ================================== FAILURES =================================== _____________________ TestBasic.test_create_tree_digraph ______________________ cmd = ['dot', '-Tpdf', '-O', 'Tree4.gv'], input = None, capture_output = True check = True, quiet = False, kwargs = {'cwd': None, 'stderr': -1, 'stdout': -1} def run(cmd, input=None, capture_output=False, check=False, quiet=False, **kwargs): """Run the command described by cmd and return its (stdout, stderr) tuple.""" if input is not None: kwargs['stdin'] = subprocess.PIPE if capture_output: kwargs['stdout'] = kwargs['stderr'] = subprocess.PIPE try: > proc = subprocess.Popen(cmd, startupinfo=get_startupinfo(), **kwargs) C:\Miniconda\envs\test-env\lib\site-packages\graphviz\backend.py:146: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = args = ['dot', '-Tpdf', '-O', 'Tree4.gv'], bufsize = -1, executable = None stdin = None, stdout = -1, stderr = -1, preexec_fn = None, close_fds = False shell = False, cwd = None, env = None, universal_newlines = False startupinfo = creationflags = 0, restore_signals = True, start_new_session = False pass_fds = () def __init__(self, args, bufsize=-1, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=_PLATFORM_DEFAULT_CLOSE_FDS, shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0, restore_signals=True, start_new_session=False, pass_fds=()): """Create new Popen instance.""" _cleanup() # Held while anything is calling waitpid before returncode has been # updated to prevent clobbering returncode if wait() or poll() are # called from multiple threads at once. After acquiring the lock, # code must re-check self.returncode to see if another thread just # finished a waitpid() call. self._waitpid_lock = threading.Lock() self._input = None self._communication_started = False if bufsize is None: bufsize = -1 # Restore default if not isinstance(bufsize, int): raise TypeError("bufsize must be an integer") if _mswindows: if preexec_fn is not None: raise ValueError("preexec_fn is not supported on Windows " "platforms") any_stdio_set = (stdin is not None or stdout is not None or stderr is not None) if close_fds is _PLATFORM_DEFAULT_CLOSE_FDS: if any_stdio_set: close_fds = False else: close_fds = True elif close_fds and any_stdio_set: raise ValueError( "close_fds is not supported on Windows platforms" " if you redirect stdin/stdout/stderr") else: # POSIX if close_fds is _PLATFORM_DEFAULT_CLOSE_FDS: close_fds = True if pass_fds and not close_fds: warnings.warn("pass_fds overriding close_fds.", RuntimeWarning) close_fds = True if startupinfo is not None: raise ValueError("startupinfo is only supported on Windows " "platforms") if creationflags != 0: raise ValueError("creationflags is only supported on Windows " "platforms") self.args = args self.stdin = None self.stdout = None self.stderr = None self.pid = None self.returncode = None self.universal_newlines = universal_newlines # Input and output objects. The general principle is like # this: # # Parent Child # ------ ----- # p2cwrite ---stdin---> p2cread # c2pread <--stdout--- c2pwrite # errread <--stderr--- errwrite # # On POSIX, the child objects are file descriptors. On # Windows, these are Windows file handles. The parent objects # are file descriptors on both platforms. The parent objects # are -1 when not using PIPEs. The child objects are -1 # when not redirecting. (p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite) = self._get_handles(stdin, stdout, stderr) # We wrap OS handles *before* launching the child, otherwise a # quickly terminating child could make our fds unwrappable # (see #8458). if _mswindows: if p2cwrite != -1: p2cwrite = msvcrt.open_osfhandle(p2cwrite.Detach(), 0) if c2pread != -1: c2pread = msvcrt.open_osfhandle(c2pread.Detach(), 0) if errread != -1: errread = msvcrt.open_osfhandle(errread.Detach(), 0) if p2cwrite != -1: self.stdin = io.open(p2cwrite, 'wb', bufsize) if universal_newlines: self.stdin = io.TextIOWrapper(self.stdin, write_through=True, line_buffering=(bufsize == 1)) if c2pread != -1: self.stdout = io.open(c2pread, 'rb', bufsize) if universal_newlines: self.stdout = io.TextIOWrapper(self.stdout) if errread != -1: self.stderr = io.open(errread, 'rb', bufsize) if universal_newlines: self.stderr = io.TextIOWrapper(self.stderr) self._closed_child_pipe_fds = False try: self._execute_child(args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, > restore_signals, start_new_session) C:\Miniconda\envs\test-env\lib\subprocess.py:676: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = args = 'dot -Tpdf -O Tree4.gv', executable = None, preexec_fn = None close_fds = False, pass_fds = (), cwd = None, env = None startupinfo = creationflags = 0, shell = False, p2cread = Handle(1796), p2cwrite = -1 c2pread = 8, c2pwrite = Handle(1888), errread = 10, errwrite = Handle(276) unused_restore_signals = True, unused_start_new_session = False def _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_start_new_session): """Execute program (MS Windows version)""" assert not pass_fds, "pass_fds not supported on Windows." if not isinstance(args, str): args = list2cmdline(args) # Process startup details if startupinfo is None: startupinfo = STARTUPINFO() if -1 not in (p2cread, c2pwrite, errwrite): startupinfo.dwFlags |= _winapi.STARTF_USESTDHANDLES startupinfo.hStdInput = p2cread startupinfo.hStdOutput = c2pwrite startupinfo.hStdError = errwrite if shell: startupinfo.dwFlags |= _winapi.STARTF_USESHOWWINDOW startupinfo.wShowWindow = _winapi.SW_HIDE comspec = os.environ.get("COMSPEC", "cmd.exe") args = '{} /c "{}"'.format (comspec, args) # Start the process try: hp, ht, pid, tid = _winapi.CreateProcess(executable, args, # no special security None, None, int(not close_fds), creationflags, env, cwd, > startupinfo) E FileNotFoundError: [WinError 2] The system cannot find the file specified C:\Miniconda\envs\test-env\lib\subprocess.py:957: FileNotFoundError During handling of the above exception, another exception occurred: self = @unittest.skipIf(not GRAPHVIZ_INSTALLED, 'graphviz is not installed') def test_create_tree_digraph(self): gbm = lgb.LGBMClassifier(n_estimators=10, num_leaves=3, silent=True) gbm.fit(self.X_train, self.y_train, verbose=False) self.assertRaises(IndexError, lgb.create_tree_digraph, gbm, tree_index=83) graph = lgb.create_tree_digraph(gbm, tree_index=3, show_info=['split_gain', 'internal_value'], name='Tree4', node_attr={'color': 'red'}) > graph.render(view=False) ..\tests\python_package_test\test_plotting.py:125: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ C:\Miniconda\envs\test-env\lib\site-packages\graphviz\files.py:201: in render quiet=quiet) C:\Miniconda\envs\test-env\lib\site-packages\graphviz\backend.py:193: in render run(cmd, capture_output=True, cwd=cwd, check=True, quiet=quiet) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ cmd = ['dot', '-Tpdf', '-O', 'Tree4.gv'], input = None, capture_output = True check = True, quiet = False, kwargs = {'cwd': None, 'stderr': -1, 'stdout': -1} def run(cmd, input=None, capture_output=False, check=False, quiet=False, **kwargs): """Run the command described by cmd and return its (stdout, stderr) tuple.""" if input is not None: kwargs['stdin'] = subprocess.PIPE if capture_output: kwargs['stdout'] = kwargs['stderr'] = subprocess.PIPE try: proc = subprocess.Popen(cmd, startupinfo=get_startupinfo(), **kwargs) except OSError as e: if e.errno == errno.ENOENT: > raise ExecutableNotFound(cmd) E graphviz.backend.ExecutableNotFound: failed to execute ['dot', '-Tpdf', '-O', 'Tree4.gv'], make sure the Graphviz executables are on your systems' PATH C:\Miniconda\envs\test-env\lib\site-packages\graphviz\backend.py:149: ExecutableNotFound ```

https://dev.azure.com/lightgbm-ci/lightgbm-ci/_build/results?buildId=2309

jakirkham commented 5 years ago

@StrikerRUS, would you be able to submit a PR with the fix outlined above?

StrikerRUS commented 5 years ago

@jakirkham Please see #27.

jakirkham commented 5 years ago

Thanks to PR ( https://github.com/conda-forge/python-graphviz-feedstock/pull/27 ) it appears the Windows package is fixed! 🎉

Have marked the packages that did not work as broken (see below). Though please double check that I've gotten them all.


Screen Shot 2019-06-11 at 6 11 29 PM