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

Install the supplied console scripts without the ".py" file extension #724

Closed
knobix opened this issue Feb 27, 2022 · 4 comments · Fixed by #793
Closed

Install the supplied console scripts without the ".py" file extension #724

knobix opened this issue Feb 27, 2022 · 4 comments · Fixed by #793
Labels
status: accepted type: ux Related to the development process of users

Comments

@knobix
Copy link

knobix commented Feb 27, 2022

Feature request

Would it be possible to install the two console scripts pdf2txt.py and dumppdf.py without their .py file extension?

Most Python packages, that I'm aware of, provide their console scripts without the .py extension.

@pietermarsman
Copy link
Member

pietermarsman commented Mar 13, 2022

Yes, I would like that as well.

Docs: https://python-packaging.readthedocs.io/en/latest/command-line-scripts.html

@pietermarsman pietermarsman added this to new in pdfminer.six via automation Mar 13, 2022
@pietermarsman pietermarsman moved this from new to accepted in pdfminer.six Mar 13, 2022
@pietermarsman pietermarsman added the type: ux Related to the development process of users label Mar 13, 2022
@hholst80
Copy link

This is how the flask script works:

#!/usr/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from flask.cli import main
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(main())

However I would say that this is non-optimal. Better:

#!/bin/sh
exec python3 -m flask -- "$@"

@pietermarsman
Copy link
Member

I realized that this is not as easy as I thought. The console script needs to be in the pdfminer package, but it is not. It is in the tools/ directory.

Maybe we should move the content of tools/ to the package as well and just keep some aliases there to not have any breaking changes?

@hholst80
Copy link

hholst80 commented Nov 9, 2022

Create a __main__.py in the library ping @pietermarsman

when the package is invoved as a program __main__.py will be executed (after __init__.py if I remember correctly)

you would still need a CLI wrapper that wraps the tool as a non-.py suffix executable and for that my code snippet should work just fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepted type: ux Related to the development process of users
Projects
No open projects
pdfminer.six
  
accepted
Development

Successfully merging a pull request may close this issue.

3 participants