Addon zip file execute?

is there a way to run an addon zip file directly ?

I don’t want to install it just use it ounce !

and if you install one how do you get rid of it afterward ?

thanks
happy bl

There is this to try in the console. This might work for you depending on the addon . I am pretty sure you need to unzip the addon first to get to the .py file. It should be possible with Python.

filename = "/full/path/to/myscript.py"
exec(compile(open(filename).read(), filename, 'exec'))

let say it is fast carve
the filename is it the zip file or the init_Py for fast carve ?

thanks
happy bl

If you have unzipped fastcarve to somewhere and if it only has “init.py” then it should be

filename = "/PATH TO FASTCARVE/__init__.py"
exec(compile(open(filename).read(), filename, 'exec'))

However if it also imports bunch of custom modules it might be tricky. I have not tested this but you probably need to also run this prior to the lines above.

import sys

sys.path.insert(1, '/PATH TO FASTCARVE')

I did not unzip the fast carve addon

so is there a way to run it using the zip file for this addon or not?

thanks
happy bl

1 Like

I have a local 2.81 and 2.82 bl

I added the fastcarve zip in the addon for 2.81 but I cannot see it when I
search addon in user preference
not certain why we don’t see it

I could probably install it without saving the user preferences

there was an addon in 2.79 to run different addon
not certain if this would work in 2.8
have to find the name for this addon

thanks
happy bl

Hi RickyBlender,
Are you fine?
I have an idea for you: you can just use your

__init__.cpython-37.pyc

python compiled file to use it directly with your python.
You must search docs in python binaries file interpreter…
May be!
Byebye.

never use that one !

does blender comes with Cpython ?

so this would run the complied version of the addon ?

Thanks
happy bl

1 Like

Look this code too:

class DCONFIG_OT_install_theme(bpy.types.Operator):
    bl_idname = "dconfig.install_theme"
    bl_label = "DC Install Theme"
    bl_description = "Installs custom dconfig theme"
    bl_options = {'REGISTER'}

    def execute(self, context):
        script_path = bpy.utils.user_resource('SCRIPTS')
        source_path = os.path.join(script_path, "addons", "dconfig", "dconfig.xml")
        target_path = os.path.join(script_path, "presets", "interface_theme")

        self.makedir(target_path)
        filepath = shutil.copy(source_path, target_path)
        bpy.ops.script.execute_preset(filepath=filepath, menu_idname="USERPREF_MT_interface_theme_presets")

        return {'FINISHED'}

    def makedir(self, target):
        if not os.path.exists(target):
            os.makedirs(target)

To charge a xml theme with python.
You can may be use this function:

bpy.ops.script.execute_preset()
or 
bpy.ops.script.python_file_run( filepath = "" ) 

Look here: https://docs.blender.org/api/current/bpy.ops.script.html

EDIT: I just find this about python feature with zip file:
https://pymotw.com/2/zipimport/index.html
and/or this:
https://pymotw.com/2/pkgutil/index.html#module-pkgutil

Look this if your wanted create a Cython module to import:
https://cython.readthedocs.io/en/latest/src/tutorial/cython_tutorial.html

Don’t forgot to download a compiler for Windows or linux with…