pyelftools icon indicating copy to clipboard operation
pyelftools copied to clipboard

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

Open tlansec opened this issue 2 years ago • 4 comments

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.

tlansec avatar Apr 26 '23 09:04 tlansec

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.

eliben avatar Jul 06 '23 12:07 eliben

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.

sevaa avatar Jul 06 '23 13:07 sevaa

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.

tlansec avatar Jul 07 '23 11:07 tlansec

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.

sevaa avatar Jul 07 '23 13:07 sevaa