pve

pve


Keywords
python, export, blender, ast, transform, houdini, maya, variant, c4d
License
GPL-3.0
Install
pip install pve==10.10.10

Documentation

3D Ninjas Python Variant Exporter

Exports variants of your Python projects, e.g., to create a free and a commercial variant of your add-on from the same codebase.

If you have code like this:

__VARIANT__ = 'DEV'

def example():
    if __VARIANT__ in ['DEV', 'PRO']:
        print('PRO')
    elif __VARIANT__ == 'FREE':
        print('FREE')

example()

Python Variant Exporter can export it for you to fit:

pve -d __VARIANT__=PRO example.py example_pro.py
__VARIANT__ = 'PRO'

def example():
    print('PRO')

example()

Look at the examples to see what the exporter is capable of.

Installation

Python Variant Exporter itself requires Python 3.9 or later. It can transform code for older Python versions, though.

pip install pve

Usage

usage: pve [-h] [-e {replace,overwrite,skip}] [-i wildcard] [-t wildcard] [-c wildcard] [-d name[:type]=value] input output

positional arguments:
  input                 input path
  output                output path

optional arguments:
  -h, --help            show this help message and exit
  -e {replace,overwrite,skip}
                        defines behaviour when a target file or folder exists: "r" removes the entire output first, "o" overwrites existing files, "s" skips existing files (default: replace)
  -i wildcard           files and folders to be ignored, e.g. ".*" (default: ".*", "*.pyc")
  -t wildcard           files to be transformed if not ignored, e.g. "*.py" (default: "*.py")
  -c wildcard           files to be copied if not ignored or transformed, e.g. "*" (default: "*")
  -d name[:type]=value  define variables to be replaced, e.g. -d __VARIANT__=PRO -d __LICENSE_CHECK__:bool=True

Examples

# Transform examples/simple
pve -d __VARIANT__=PRO -d __LICENSE_CHECK__:bool=True examples/simple examples/simple_pro
pve -d __VARIANT__=LITE -d __LICENSE_CHECK__:bool=True examples/simple examples/simple_lite
pve -d __VARIANT__=FREE -d __LICENSE_CHECK__:bool=False examples/simple examples/simple_free

# Transform examples/blender_addon
pve -d __VARIANT__=PRO -c pro.png examples/blender_addon examples/blender_addon_pro
pve -d __VARIANT__=FREE -c free.png examples/blender_addon examples/blender_addon_free