Best way to distribute Python Script without exposing the source code

Hi,

This is my first post. I’m new to Rhino and Python.
I’m writing a script in python using Rhino Python Editor and I would like to distribute it to my customers who are using both Windows and Mac versions of Rhino. But I would not like to expose the source code to them.

Thanks,
Kentaroh

Probably one method would be to use the clr.CompileModules function.
Have a look at this function on these two pages, so you can have an idea on how it works:

Giulio

Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

1 Like

Hi
I compiled a dll file as shown on these websites but how do I call it form rhino? I created a following script:

import clr
clr.AddReference(“bracket.dll”)
import bracket
bracket.Main()

but it returns:
Message: No module named bracket

I am no expert - but I usually manage to get this to work. Is the file that you compiled called “bracket.py”? That is the meaning of module here.

Giulio

Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Hello again
Sorry for late answer but I had a lot on my head lately.
So I am creating a script called dummy.py:

def tester():
    print 'Hello world’
tester()

then another one called compiler.py:

import clr
clr.CompileModules(“test.dll”, “dummy.py”)

Then I run compiler.py and it gives me test.dll

In next step I create exec.py to run it:

import clr
clr.AddReference(“test.dll”)
import test
test.tester()

and run it which gives me a result:
Message: No module named test

All the files are in a single folder AppData\Roaming\McNeel\Rhinoceros\5.0\scripts
Any help would be greatly appreciated.

has anyone gotten this error when trying to compile modules?

import clr
clr.CompileModules(“testdll.dll”,“test_compile.py”)
IOError: System.IO.IOException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

I am not sure what you are trying to do exactly (this discussion is 2 year old). A possibility is that the process does not have access to the local folder, or the .dll “testdll.dll” is already in use so it cannot be rewritten, or something similar.