Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdf2txt.py and pdfdump.py should have a shebang #405

Closed
fabbox opened this issue Mar 25, 2020 · 4 comments · Fixed by #408
Closed

pdf2txt.py and pdfdump.py should have a shebang #405

fabbox opened this issue Mar 25, 2020 · 4 comments · Fixed by #408

Comments

@fabbox
Copy link
Contributor

fabbox commented Mar 25, 2020

Both scripts in tools/ doesn't contain python interpreter line (#!/usr/bin/env python) which prevent their correct execution when packaged and installed.

From https://bugs.archlinux.org/task/65939 :

#!/usr/bin/env python was removed from pdf2txt.py by [1] [2] and from duppdf.py by [3] [4].
The commit messages do not explain the removal while commit [5] notes the need for them.

[1] bc034c8
[2] d93a73f
[3] 6cc78ee
[4] 7aa180d
[5] 0fdebc6

@fabbox fabbox changed the title pdf2txt.py and pdfdump.py sould contains python interpreterline pdf2txt.py and pdfdump.py should contain python interpreterline Mar 25, 2020
@pietermarsman pietermarsman changed the title pdf2txt.py and pdfdump.py should contain python interpreterline pdf2txt.py and pdfdump.py should have a shebang Mar 26, 2020
@pietermarsman
Copy link
Member

I think I removed some in the past because I did not understood what they are for. Adding them adds another way of interacting with pdfminer.six; using $ pdf2txt.py file.pdf (without prefixing it with python).

I think its a good thing if we introduce them again. Are there shebangs that work for all kinds of python environments (e.g. conda, virtualenv, pipenv, system python, etc.)?

Also see #217

@fabbox
Copy link
Contributor Author

fabbox commented Mar 27, 2020

Yes, it should work with most of python environments even if I'm not sure on the compatibility with Windows. Note that additionnaly I didn't get the opportunity to test with conda.

@pietermarsman
Copy link
Member

According to the python docs it is also compatible with windows.

@eli-schwartz
Copy link

eli-schwartz commented Apr 19, 2020

I think I removed some in the past because I did not understood what they are for.

They define how to run a program on Unix. Since they are installed as command-line executables in

pdfminer.six/setup.py

Lines 31 to 34 in d79bcb7

scripts=[
'tools/pdf2txt.py',
'tools/dumppdf.py',
],

there is no choice: they must have those shebangs, and to do otherwise is utterly broken. For compatibility with ancient Unix systems, there is a fallback to try (and fail) to execute them as shell scripts.

Are there shebangs that work for all kinds of python environments (e.g. conda, virtualenv, pipenv, system python, etc.)?

#!/usr/bin/env python3 will locate the currently active python, whether that is a venv or the system python.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants