python-minifier icon indicating copy to clipboard operation
python-minifier copied to clipboard

python version compatibilty

Open indexofrefraction opened this issue 4 years ago • 9 comments

hi, i tried this to minify code that needs to run on python 2.7 and python 3.7 sadly print() gets translated to print if minifying is run on 2.7 which breaks compatibilty exec(...) gets minified to: exec ... also triggering errors on 3.x

it would be nice if there was a compatibilty mode not downgrading all code to 2.x standard best, index

indexofrefraction avatar May 24 '21 22:05 indexofrefraction

If you run python-minifier using python 3.7, the output will be compatible with 3.7 Do you have any problems running the 3.7 minified code on 2.7?

dflook avatar May 25 '21 11:05 dflook

i'd have to test if 3.7 minified code works on 2.7, that would be a workaround. but for me ideally minification would work from both python versions with results working on both versions, too. hence the idea of a compat mode without syntax changes. (the code itself works on both versions)

indexofrefraction avatar May 25 '21 11:05 indexofrefraction

Python-minifier relies on the running interpreter for parsing, so it won't have greater compat than python itself. If there is any code that works on a lower version than it's being minified with but breaks after being minified, that might be worth a compatability mode.

On that note, did you from __future__ import print_function in the code where print() is transformed to print? That would be a bug

dflook avatar May 25 '21 13:05 dflook

Is 3.10 support on the roadmap?

rochacbruno avatar Oct 05 '21 19:10 rochacbruno

@rochacbruno Yes. It's been implemented, but must be validated against the release version. If all goes well it will be released today 🤞.

dflook avatar Oct 06 '21 07:10 dflook

thanks @dflook I am bumping https://GitHub.com/rochacbruno/dynaconf to run CI on 3.10 and looks like the missing package is minify, we use it for our vendoring script.

Thanks

rochacbruno avatar Oct 06 '21 08:10 rochacbruno

@rochacbruno python-minifier 2.5.0 is now available on PyPI with Python3.10 support

dflook avatar Oct 06 '21 14:10 dflook

Thanks @dflook now dynaconf install test on 3.10 is passing :)

https://github.com/rochacbruno/dynaconf/runs/3816321083?check_suite_focus=true

rochacbruno avatar Oct 06 '21 14:10 rochacbruno