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

[Suggestions] Make readelf.py a "console_script" rather than a "script" in setup.cfg #471

Open
tlansec opened this issue Apr 26, 2023 · 4 comments

Comments

@tlansec
Copy link

tlansec commented Apr 26, 2023

https://python-packaging.readthedocs.io/en/latest/command-line-scripts.html#the-scripts-keyword-argument

At present (unless I'm doing something wrong) when pyelftools is installed in a Windows environment the readelf.py script does not become available on the command line.

This is because setup.cfg currently uses the scripts=[] keyword rather than `console_scripts.

@eliben
Copy link
Owner

eliben commented Jul 6, 2023

The documentation of console_scripts says:

This allows Python functions (not scripts!) to be directly registered as command-line accessible tools.

Is this really related to what you ask?

Unfortunately I don't even have a way to test on Windows these days, so I'll need someone with Windows expertise to help figure this out.

@sevaa
Copy link
Contributor

sevaa commented Jul 6, 2023

I sort of see a use case for readelf.py under Windows. GNU readelf is available for Windows under Cygwin and under WSL, but setting up either of those is a bit of a chore.

That said, it's unfair to say that readelf.py is not available. You have to provide a full path on the command line, that's all:

python C:\Users\seva\appdata\roaming\python\python310\Scripts\readelf.py -wi myfile.elf

That's assuming per user setup in the default Python; your path may vary.

@tlansec
Copy link
Author

tlansec commented Jul 7, 2023

Regarding some of the points above:

Is this really related to what you ask?

If you read further on in the same section you've already structured realelf.py in the same way as would be required. The only nuance they're talking about (I think) is that specifying it in the scripts variable requires that you don't specify an input function, but since readelf.py immediately calls main() this isn't an issue.

You have to provide a full path on the command line, that's all:

I know you can call it, in the same way I could alias it etc, what i'm proposing is purely for convenience on first installation.

@sevaa
Copy link
Contributor

sevaa commented Jul 7, 2023

OBTW, I've just checked, readelf.py is somehow in PATH on my Windows machine. Merely typing readelf.py on the command line brings up its help screen.

Maybe that's because C:\Program Files\Python310\Scripts\ is in PATH. I don't recall right now whether or not putting Scripts in PATH might be an optional checkbox during Python installation or a default behavior.

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

No branches or pull requests

3 participants