How can I compile Python code with only the required parts or functions from a module, such as including Keras from TensorFlow but not the whole TensorFlow library? I have tried using PyInstaller and Nuitka, but they include the whole TensorFlow library, which is about 1GB, as well as NumPy and Matplotlib. My application is AINeuralNetwork-based, but after compiling it, the resulting application is a whole new application with a massive size. Is there any way to produce optimized binaries from Python that only include the necessary parts of a module? Here is an example-
# Importing only the required functions from a module
from tensorflow.keras.layers import Dense, Dropout
# Using the imported functions
model.add(Dense(64, activation='relu'))
model.add(Dropout(0.2))
here only want the selected module to compile like Dense and Dropout not the whole Tensorflow Library. Things I tried to reduce the final output size-
- Virtual Env with only selected package
- Cx_freeze
- Nuitka
- Pyinstaller
- Numpy Vanilla libraries
But i want pure compiled version of my python program which is compiled in way that it automatically contain the required code from library not the whole library?