Packaging and distributing python plugins via a launcher
-
Good day fellow devs,
I'm working on a pretty complex closed source python plugin for C4D.
The time has come to think about the distribution.
More often than not I encounter .xdl64 bundles, that are easy to install and use.
I would like to:
- provide a simple launcher via a single .xdl64 file (or a .zip with all the code neatly contained in a protected container-file) that anybody can place in the Plugins folder.
- have that launcher be written in native Cinema4D way, so it has the best chance of running on different Cinema4D versions.
- the launcher figures out runtime versions and downloads python-based solution for the current version.
- the launcher also launches the main plugin.
Benefits of this approach are:
- Launcher is python independent.
- Rare updates are necessary for the launcher itself.
- Control over update process for the main plugin.
- Source code is hidden from easy access.
So, while I'm not proficient in C or C++, walking that route offers the best results so far.
Could you please point me in the right direction and point our tough spots or hidden dangers of this approach?
Side questions:
- Can there be a mixed plugin, that starts as C++ plugin, and calls on previously downloaded python libs at some point?
- Can such a C++ launcher load, unload, reload a python plugin in runtime?
- Can I pack a python plugin into .xdl64 file?
- How would you approach a question of keeping your source code private, with python being an open book?
So far the best way I know of is - Cython everything down to C and have that compiled to .pyd libraries.
Thank you.
-
Hello @DayDreamer,
Welcome to the Maxon developers forum and its community, it is great to have you with us!
Getting Started
Before creating your next postings, we would recommend making yourself accustomed with our forum and support procedures. You did not do anything wrong, we point all new users to these rules.
- Forum Overview: Provides a broad overview of the fundamental structure and rules of this forum, such as the purpose of the different sub-forums or the fact that we will ban users who engage in hate speech or harassment.
- Support Procedures: Provides a more in detail overview of how we provide technical support for APIs here. This topic will tell you how to ask good questions and limits of our technical support.
- Forum Features: Provides an overview of the technical features of this forum, such as Markdown markup or file uploads.
It is strongly recommended to read the first two topics carefully, especially the section Support Procedures: Asking Questions.
About your First Question
This is your first posting and you did well, but I would point you to our 'singular question' rule, as lined out above in the 'Asking Questions' link. While we usually cut user some slack regrading that, the rule exists for a reason, as topics otherwise tend to become gigantic. There are way too many questions in this topic, please split your questions into multiple topics in the future.
- There is no mechanism to package and ship plugins under Cinema 4D. You can just zip a plugin folder and the user unzips it then in a path where his or her Cinema 4D instance is looking for plugins.
- xdl64 is the extension Cinema 4D uses for libraries under Windows, i.e., it is more or less an alias for dll (our library linking is kind of special and right between static and dynamic libraries, hence the custom name). So, no, Python plugins cannot be packaged as xdl64 because Python is not compiled into machine code but interpreted at run time.
- You can mix C++ and Python plugins in the sense that Python plugins can depend/interact with C++ plugins with the means of the Cinema 4D API. E.g., a Python plugin can react to messages sent by a C++ plugin or data placed by a C++ plugin (or vice versa). That is how our Python API works under the hood. But C++ and Python code cannot interact directly of course, as they are vastly different languages. But you can run our Python VM from C++ and eval the results.
- When you want to protect your intellectual property, you can use our
Cinema 4D | Extensions > Tools > Source Code Protector
which will encrypt apyp
Python module. But code must of course be decrypted at runtime to be sent to the Python VM, so, this will not really stop anyone who really wants your source code (a cracker for example). C++ is the by far safer option when intellectual property is important (but also C++ can be decompiled).
Cheers,
Ferdinand