🧪 Version 0.2.2 is our alpha release candidate. Please send us bug reports and suggestions!

Sketchingpy

Creative coding and interactive science everywhere for everyone: web, desktop, mobile, Jupyter, and more. Open source!

Deploying

Sketchingpy has different approaches for deployment depending on where you are going.

Desktop

You have some options for deployment of Python stand-alone executables which offer users programs that can be used without a system-wide Python through file formats like exe, dmg, etc. Consider reviewing cx_Freeze and PyInstaller. Here is an example setup.py for cx_Freeze adapted from their documentation:
import sys
import cx_Freeze

# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {
    'zip_include_packages': ['sketchingpy', 'pygame-ce'],
    'include_files': ['reference.png']
}

# base='Win32GUI' should be used only for Windows GUI app
base = 'Win32GUI' if sys.platform == 'win32' else None

cx_Freeze.setup(
    name='sketch',
    version='0.1',
    description='Sketch export',
    options={'build_exe': build_exe_options},
    executables=[cx_Freeze.Executable('sketch.py', base=base)]
)
This can be built with:
python setup.py build
Note that this example includes an image which is bundled with the executable. For more details, see cx_Freeze documentation.

Web

Sketchingpy can go anywhere your web development can take you. Unlike desktop Python, requirements are crafted directly in the web document itself. If you haven't written HTML before, we suggest the Mozilla Developer Network's introduction. With that, here's a minimal example:
<!doctype html>
<html>
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width,initial-scale=1.0">

        <!-- PyScript -->
        <link rel="stylesheet" href="https://pyscript.net/releases/2023.11.2/core.css">
        <script type="module" src="https://pyscript.net/releases/2023.11.2/core.js"></script>
    </head>
    <body>
        <py-config>
        {
            "packages": ["sketchingpy==0.2.2"]
        }
        </py-config>

        <!-- You may need to change this ID to match your code. -->
        <div id="sketch-load-message">Loading...</div>
        <canvas id="sketch-canvas"></canvas>

        <!-- You can link the script as shown below or use py-script to inline -->
        <script type="py" src="main.py"></script>
    </body>
</html>
This will work with the defaults:
<script type="py">
sketch = sketchingpy.Sketch2DWeb(width, height)
</script>
Note that the CDN above uses sources from other open source projects including those from the PyScript project subject to their permissive license. Regardless, for more configuration details including self-hosting, multiple Python files, and web fonts see, detailed web instructions.

Server

The static renderer only requires Pillow and Sketchingpy where the later is a pure-Python distribution. For more details on how to install Pillow, see the Pillow installation documentation.