Skip to content

Latest commit

 

History

History
96 lines (68 loc) · 3.28 KB

README_en.md

File metadata and controls

96 lines (68 loc) · 3.28 KB

py2sec

中文 Readme

OS Support

Linux && MacOS && Windows

P.S. Windows User May encounter the error

error: command 'cl.exe' failed: No such file or directory

Please install Visual C++ Build Tools matches your Win version

What is py2sec

  1. py2sec is a Cross-Platform, Fast and Flexible tool to change the .py to .so(Linux and Mac) or .pdy(Win).
  2. You can use it to hide the source code of py.
  3. Py2Sec can also speed up the running time of the code, up to 30 times than before.
  4. py2sec can transfer a single file, more of this, it can certainly transfer the whole project at one time!.
  5. The .so(or .pyd) file generated by the .py file can be called by the main func as "from module import * ".
  6. py2sec can detect the .py file and transfer to .so(or .pyd) file, also you can determin which file or directory you don't want to change.
  7. py2sec doesn't affect the origin code, it generate a new file or directory.
  8. py2sec work well with python2 and python3, use -p(--py) to change the python version you want to encrypt.
  9. Provide the multithread option to accelerate the speed of py encryption.

How to config it

Please copy the directory or files to the root path of the py2sec.

pip install requirements.txt

How to use py2sec

Usage

python py2sec.py [options] ...

Options

-v,  --version      Show the version of the py2sec
-h,  --help         Show the help info
-p,  --python       Python version, default is based on the version of python you bind with command "python"
                    Example: -p 3  (means you tends to encrypt python3)
-d,  --directory    Directory of your project (if use -d, you encrypt the whole directory)
-f,  --file         File to be transfered (if use -f, you only encrypt one file)
-m,  --maintain     List the file or the directory you don't want to transfer
                    Note: The directories should be suffix by path separate char ('\\' in Windows or '/'),
                    and must be the relative path to -d's value
                    Example: -m setup.py,mod/__init__.py,exclude_dir/
-x,  --nthread      number of parallel thread to build jobs
-q   --quiet        Quiet Mode, Default: False
-r   --release      Release Mode, clear all the tmp files, only output the result, Default: False

Example

python py2sec.py -f test.py
python py2sec.py -f example/test1.py -r
python py2sec.py -d example/ -m test1.py,bbb/

# some OS use command "python3" to run python3, like Ubuntu, you can use -p to solve it
python3 py2sec.py -p 3 -d example/

Project Structure

  • build/ temp files, .o, .so files
  • tmp_build/ temp files, .c files
  • result/ the final result dir, the results store here
  • result/log.txt the log file
  • py2sec.py main run file
  • py2sec_build.py.template to generate setup.py file
  • requirements.txt env to run py2sec

LICENSE

The Project follow the MIT LICENSE.

Demo

The whole project before:

demo1

After py2sec:

demo2