Protect Python Code

How to protect Python Code?

Option 1: Convert Python into Binaries, which client can’t decompile.
http://cython.org/ – Free, Apache License

Article on Cython: https://medium.com/@xpl/protecting-python-sources-using-cython-dcd940bb188e

Option 2: Minify / Obfuscate
Minify: Remove empty lines, comments,…etc
Obfuscate: Convert human-readable names to nonreadable format.

List of Obfuscation software:
https://mnfy.readthedocs.io/en/latest/
https://github.com/QQuick/Opy

Article: https://www.smallsurething.com/how-to-obfuscate-python-source-code/


Article:
https://stackoverflow.com/questions/261638/how-do-i-protect-python-code

How to decompile “.PYC” Files?
https://stackoverflow.com/questions/5287253/is-it-possible-to-decompile-a-compiled-pyc-file-into-a-py-file


Option 3: Please add copyright and other file headers to get a legal edge.

Note: Combination of all above based on business need.

Advertisements

Connecting Hive with Python

In production environment we need to connect with multiple Hive Instances.

Option 1: Use ODBC for Python.
https://github.com/mkleehammer/pyodbc
This is not proved product to use.

Option 2: Use Pyhs2 driver.
https://cwiki.apache.org/confluence/display/Hive/Setting+Up+HiveServer2#SettingUpHiveServer2-PythonClientDriver
This helps to connect to only one instance of Hive.

Conclusion:
Stay away from connecting to Hive with Python in BigData production environment.
Better to decouple technology. Let Python write data to flat files. Load those files to Hive.

Working with Python in Mac

How to install and work with Python in mac?

Step 1:
https://www.jetbrains.com/pycharm/download/#section=mac

Step 2: How to install missing module?
On bottom left side of PyCharm, click on computer icon and choose terminal.
select package in import statement. Press Alt+Enter, choose install package.
>sudo easy_install pip
Search for package here https://pypi.python.org/pypi
>sudo pip install package_name