dflook / python-minifier

Transform Python source code into its most compact representation
MIT License
558 stars 41 forks source link

The shebang is stripped from the minified python code #34

Closed blikjeham closed 2 years ago

blikjeham commented 2 years ago

Some code requires a shebang (#!) to be present at the beginning of the file to instruct the program loader which python interpreter to use (e.g. "#!/usr/bin/python"). Since the shebang starts with a #, it is seen as a comment by python-minifier, and gets stripped from the minified code.

Could you add an exception to the minifier to leave the #! at the very beginning of the file alone?

blikjeham commented 2 years ago

This is related to https://github.com/dflook/python-minifier/pull/8, but I don't see any progress in that pull request for a year and a half. I had to do the following workaround to retain the shebang:

pyminify script.py > script.py.min
echo "#!/usr/bin/python" > script.py
cat script.py.min >> script.py
dflook commented 2 years ago

2.6.0 has been released which preserves the shebang by default.