kxxoling / markdown2pdf

[Deprecated] A command line tool to convert markdown file to pdf.
https://pypi.python.org/pypi/Markdown2PDF
63 stars 23 forks source link

Fix: python interpreter should be explicitly set to python2 #4

Closed lemoer closed 8 years ago

lemoer commented 8 years ago

Discussion head in #1

@kxxoling wrote:

python always means Python 2 and Python 3 should always be python3. This's specified in PEP 0394.

No. For time beeing it should refer to python2.

Furthermore PEP 0394 says:

in preparation for an eventual change in the default version of Python, Python 2 only scripts should either be updated to be source compatible with Python 3 or else to use python2 in the shebang line.

ArchLinux has already done this step.

kxxoling commented 8 years ago

I've noticed this, but I think Arch users are always having the newest version of program and OS installed, this won't be any issue. :)

Actually, what really matters is that the shebang will only have meaning when this file is running directly as a system script, but this won't ever happen in my case. This means, event there issue in the shebang line, matters noting.

lemoer commented 8 years ago

Actually, what really matters is that the shebang will only have meaning when this file is running directly as a system script, [...]

I tried to install the script via pip and use it via md2pdf (as you propose it in your readme). This means executing as a "system script".

[...] but this won't ever happen in my case.

Well... What would be the disadvantage if you merge my changes? This would not cause any issues on any system. It would only repair it on ArchLinux.

If you really don't care about others, you should mention it in your banner. Not to mention this, is really disrespectful to the opensource community. Other people (like me) take their free time to write pull requests! ;)

kxxoling commented 8 years ago

When you're writing a script, and give it the executable priority, then execute it like ./your_script.script_ext, the shell won't know which program should be used to execute the script file. This is the problem that shebang solved. In other case, like running script like python your_script.py, the shell knows you'd like to use python to run your script, so that shebang is nessecary any more.

In my case, the python files in my repo are part of the lib markdown2pdf. They all are Python modules not script file, so shebang would never be useful.

On the other hand, when you're writing Python scripts, you should use #!/usr/bin/env python which is chosen by almost all the popular Python projects like Django, Fabric etc.