Nuitka / Nuitka

Nuitka is a Python compiler written in Python. It's fully compatible with Python 2.6, 2.7, 3.4-3.13. You feed it your Python app, it does a lot of clever things, and spits out an executable or extension module.
http://nuitka.net
Apache License 2.0
12.11k stars 650 forks source link

AntiBloat patch when no_docstring #2006

Closed interseba5 closed 1 year ago

interseba5 commented 1 year ago

Installed using pip

Explanation

Hi, i have a similar problem as #1855 for the xgboost package. So i was trying to follow @kayhayen advice by patching the code with the anti-bloat plugin. I have write this in the yaml config:

- module-name: 'xgboost.sklearn'
  anti-bloat:
    - description: 'remove docstring dependency' 
      replacements-plain:
        'assert XGBModel.fit.__doc__ is not None' : 'XGBModel.fit.__doc__ = "Fit gradient boosting model"'
      when: 'no_docstrings and no_asserts'

But when i try to compile i obtain the following error:

FATAL: anti-bloat: Identifier 'no_docstrings' in 'when' configuration of module 'xgboost.sklearn' is unknown

Am i missing something?

kayhayen commented 1 year ago

Very interesting. Are you saying you are using these options? Currently, the Python flags as given with --python-flag=no_asserts are not exposed, but indeed, there is no reason to not add them. I will do so right away.

kayhayen commented 1 year ago

Thanks for your report, this is fixed on the factory branch, which is a development version under rapid development. You can try it out by going here: https://nuitka.net/doc/factory.html

This has the tags you proposed added, and also no_annotations which is however very flaky etc. but one day, these can be per module decisions, then it will useful too.

interseba5 commented 1 year ago

Tested and worked like a charm! Later i'll send a PR to fix this xgboost issue. With this change i can also fix #1855 but i have given a quick look to https://github.com/microsoft/LightGBM/blob/master/python-package/lightgbm/dask.py and it seems much more complicated to patch because there are a lot of dependencies on doc

kayhayen commented 1 year ago

Makes me really happy.

kayhayen commented 1 year ago

Closing this early, since it's not a too generally relevant issue.

kayhayen commented 1 year ago

This is part of the stable release 1.5 that I just made.