dflook / python-minifier

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

Add recursive minification functionality #41

Closed clbarnes closed 2 years ago

clbarnes commented 2 years ago

New methods allow recursively minifying a (nested) directory of python files. Optionally, non-'*.py' files are copied across directly.

This is also reflected in the CLI.

Also:

See #21. Also addresses #40 by making everything read a str. I don't know how this will affect usage in py2 but can we just agree to not care about that dead language?

This passes all existing (regular) tests but does not yet introduce any new ones, which it should. But the functionality/ design choices are ready for review.

Open question: I'm in two minds about whether --in-place is a good idea, because nobody should ever replace their source code with a minified artefact. Similarly, I'd be happy to always throw an error if you try to write to a non-empty directory, rather than doing some special handling. However, these might be useful for minifying site-packages in-place.

clbarnes commented 2 years ago

May I ask the reason for the close? Is the functionality not wanted, or the design totally wrong, or what?

dflook commented 2 years ago

Hello @clbarnes, thanks for raising this PR!

The next release will be focused on improving the pyminify command, but I'm still considering what that will look like. Recursive processing will almost certainly be implemented in some form. File copying probably won't be part of it.

The main interface to this package is the minify function, and the pyminify command is currently a fairly thin wrapper around it. It could stand to get some more features, but the intention is that if you can always write a purpose specific command that calls minify to do exactly what you need.

This PR won't be merged at this time but it looks fine, you should have no problem continuing to use it.