mikitex70 / plantuml-markdown

PlantUML plugin for Python-Markdown
BSD 2-Clause "Simplified" License
192 stars 55 forks source link

Getting this working in a windows context #11

Closed Analect closed 6 years ago

Analect commented 6 years ago

@mikitex70 I've been trying to get this working on windows 7, but am somehow stuck. Perhaps you may have some pointers.

The jar file is located here: c:\plantuml\plantuml.jar

I have created a bash file and saved it as c:\plantuml\plantuml.sh

#!/bin/bash
java -jar c:\\plantuml\\plantuml.jar ${@}

I'm running mkdocs in a conda environment called 'client-docs', so have copied plantuml.py to c:\Users\xxxx\AppData\Local\Continuum\Miniconda3\envs\client-docs\Lib\site-packages\markdown\extensions\plantuml.py.

In order to call the bash file above with a single plantuml command, I have set an alias using doskey:

doskey plantuml=bash "c:\plantuml\plantuml.sh"

In the mkdocs.yml, I have:

markdown_extensions:
  - plantuml

However, when I try to run mkdocs serve -a 0.0.0.0:8000, I get an exception from the plantuml.py above:

... plantuml.py, line 166, in generate_uml_image
raise Exception('Failed to run plantuml: %s' % exc)
Exception: Failed to run plantuml: [WinError 2] The system cannot find the file specified

Any thoughts on what I might be doing wrong here? Thanks

mikitex70 commented 6 years ago

I don't have a Windows machine to test, bu try this plantuml.bat:

"C:\Program Files\Java\java" -jar plantuml.jar %1 %2 %3 %4

Check where is the java.exe in your system and adjust the path in the above script. Place the plantuml.jar in the same folder of the plantuml.bat. Then add then path where you placed the plantuml.bat to the system path (search in Internet how to change the PATH variable in Windows). Or, for a quick test, copy the plantuml.bat and plantuml.jar in C:\Windows; it's a bit dirty but for testing may be done. To test if the installation is working, simply try the command plantuml, without arguments and it should open a dialog.

Analect commented 6 years ago

Thanks @mikitex70 ... I think that probably works ... except I'm hitting this other problem in running plantuml related to java. It seems to be a know issue here and here. However, I lack Admin priveleges on this work machine so am a bit stuck. Frustrating.

henn1001 commented 5 years ago

@mikitex70 On my win10 machine python subprocess has problems finding the .bat file.

I need add either the .bat extension to the command ( ugly )

cmdline = ['plantuml.bat', '-p', outopt ]

or add the shell = True option

p = Popen(cmdline, stdin=PIPE, stdout=PIPE, stderr=PIPE, shell=True)

in plantuml.py. The latter would make it compatible both under linux and win.

my plantuml.bat:

@echo off
set mypath=%~dp0

setlocal
set GRAPHVIZ_DOT=%mypath%\Graphviz\bin\dot.exe

java -jar %mypath%\plantuml.jar %*

I also placed the graphviz folder in the same path

mikitex70 commented 5 years ago

Hi @henn1001, thanks for your suggestions. I've commited the version 1.2.5, that can now be installed with a simple pip install plantuml-markdown. In this version I've added a workaround to let Windows find and run the batch file. I've added a test for the operating system because using shell=True for some reason will broke automated tests under Linux (plantuml will open a dialog). I hope the workaround will work fine. Thanks again for your Windows batch file, it is now mentioned in the documentation.

vstriz commented 5 years ago

When will 1.2.5 be available on "pip install" ? I'm only able to get 1.2.4 and I need the above fix.

Thanks a lot.

mikitex70 commented 5 years ago

Hi @vstriz, sorry for the mistake: I've uploaded only the package for Python 3. It's my first release and I still learning. But now I've uploaded also the package for Python 2.7, so try again with pip.

vstriz commented 5 years ago

Thank you @mikitex70 for answering. I was really hoping it would work but it still doesn't seem to find it. I'm a little beyond my depth here to figure out why though. AFAICT it still doesn't find python-2.7 package for version 1.2.5 with pip

vstriz commented 5 years ago

You can check on pypi.org available packages:

https://pypi.org/project/plantuml-markdown/1.2.5/#files

vs.

https://pypi.org/project/plantuml-markdown/1.2.4/#files

You will see that 1.2.5 still doesn't have "py2" package

mikitex70 commented 5 years ago

Ok, now there is also a 1.2.5 package for Python 2.7. I hope now is all ok.

vstriz commented 5 years ago

Thank you @mikitex70. It works now.