Gathering your files in a .pype
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 18/07/2012 at 06:41, xxxxxxxx wrote:
Hi everyone!
I have just finished my first Python plugin and am about to hand it out to the public.
When I started writing it I was closely following this fantastic tutorial on smart-page.net. He suggests a modular approach where every major bit of the code sits in it's own .py file.
The problem I'm having now, is that when I encrypt my .pyp file into a .pype all the other .py files still remain readable. I was hoping that in the end I'd get a single .pype file that includes all the imports. I know I could compile the .py files to .pyc but I'd like my release of the plugin to be a simple .pype + res folder affair (You know, keep it compact :)).
Is my only chance to go the extra mile and copy paste all my files into one (plus fixing the sourcecode) or am I missing something?Best
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 18/07/2012 at 09:57, xxxxxxxx wrote:
One thing you could do is to bring all your libs into an extra-folder or into a zip-file. For example, you
could have a folder called "libs" which contains all your compiled python modules.my-plugin\
res\
libs\
superduperlib.pyc
my-plugin.pypeYou would need to insert the full path to the "libs" directory to sys.path. You could also bring all your files from the "libs" folder into a zip archive.
my-plugin\
res\
libs.zip {
superduperlib.pyc
}
my-plugin.pypeYou would need to insert the full path to the zip archive into sys.path. (I.e. ~/plugins/my-plugin/libs.zip )
IMHO, keeping it modular is fine, but don't write every single class or function into a seperate file.
There is not reason to do so in Python as there is in C or C++.-Nik
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/07/2012 at 00:13, xxxxxxxx wrote:
Hi Nik!
Splitting my code into different modules was mainly for reasons of convenience and overview. This way I have one file for my dialog one where my plugin is defined and one where the actual work is done. This way I didn't have to browse through one big chunk of code when debugging a specific part of the plugin.
With my current plugin it's not a big deal combining all sources into one by hand, but for larger scale projects this would be quiet a task. I just wish there would be a way to quasi-compile them all into one .pype
Thanks for your solution with the zip file. That might be an acceptable way to go when combining the files by hand isn't an option anymore.In my case I think I'm gonna bite in the sour apple like we say in Germany.