Use Cython to convert Python source code (.py, .pyw, .pyx) into dynamic link libraries
to achieve the purpose of protecting the source code
# create venv
uv venv --python 3.12
# in a uv env, install requirements
uv sync
# build package dist
uv build
# install
cd dist
pip install ./cy_encrypt-0.3.0-py3-none-any.whlconfig.json example
{
"source_dir": "/home/user/project/example",
"skip_dirs": [
"apps",
"apps/threads",
"apps/views"
],
"skip_cp_dirs": [
".git",
".idea"
]
}example project structure tree
.
├── apps
│ ├── const.py
│ ├── log.py
│ ├── setting.py
│ ├── signal.py
│ ├── threads
│ │ ├── main.py
│ │ └── setting.py
│ ├── views
│ │ ├── main.py
│ │ └── setting.py
│ └── work.py
command
cy_encrypt -c ./config.json executeThen Will Auto Process /home/user/project/example
cp source_dir to {source_dir}_{now}
Compile .py files to dynamically linked libraries (.so/.pyd), keeping the relative path unchanged
not install cy_encrypt
python -m cy_encrypt.cli --help