Jump to content
GioPet

Encrypting Python Scripts with external libraries

Recommended Posts

Hello, 

 

I have been working on a few Python Scripts that use third party libraries - for example BeautifulSoup4.

I intend to Encryption this script into a vsm plugin so that the external libraries are bound to it and can be used on other installations of Vectorworks.

 

I realised that the Encryption/Obfuscation method through Vectorworks is not able to bind the external packages into the vsm file:

I've included the path to these libraries in the Script Options and I am using the steps indicated by Vlado in this post for the related xml file.

 

ScriptOptions.thumb.png.3ff7fcd50d33d9815d7a8120164e5b04.png

 

<?xml version="1.0" encoding="UTF-8" standalone="no"?><!-- This file defines how the corresponding script plug-in should be packaged--><Plugin>
    <Package>
        <File>code/__init__.py</File>
        <File>bS4/</File>
        <File>bS4/__init__.py</File>
        <File>bS4/.py</File>
        <File>bS4/diagnose.py</File>
		<File>bS4/element.py</File>
		<File>bS4/testing.py</File>
		<File>bS4/builder/__init__.py</File>
		<File>bS4/builder/_html5lib.py</File>
		<File>bS4/builder/_htmlparser.py</File>
		<File>bS4/builder/_lxml.py</File>        
    </Package>
</Plugin>

Can any one advise on how to resolve this?

Thank you in advance.

 

Giovanni

Share this post


Link to post

Is /7_Vectorworks 2018 your VW user folder?  It’s an unusual name, so if not, you need to add a path attribute to the xml. 

 

For this xml, the .vsm file would be in the /7_Vectorworks 2018/plug-ins folder, along with the xml file. 

 

You’re not including the main.py file if you have one — any .py files in /code that you use also need to be in the xml file. The only reason not to include them is if your main code is all directly in the vsm. I.e. if you open the vsm in the plug-in manager’s script editor and call import bs4 from there

Share this post


Link to post

Hi Joshua, 

 

thank you for your response.

Yes my user folder was set to /7_Vectorworks 2017, and I keeping the xml in the Plug-in folder within that.

For clarity - I have know reverted back to the standard path and still keeping the xml next to the vsm.

 

Indeed, I don't have a 'main.py' because all my code is in the vsm.

 

The Encryption works with no errors, but when I run the Encrypted vsm on a different installation of Vectorworks I get the error:
ImportError: No module named 'bs4'

(bs4 module is the BeautifulSoup module) 

My python call in the script is: 

from bs4 import BeautifulSoup

So something is not working in actually binding the package with the vsm file..

any idea?

here is a screenshot of my Plug-in Folder  with the Development/code and Development/bs4  folders.

 

PluginFolder.thumb.png.632af6b8d76ef1bd72283f8027651151.png

 

 

thank you

Giovanni

 

Share this post


Link to post

The include files are relative to the .vsm, so add Development/ to your file locations. 

Share this post


Link to post

That's the case:

<?xml version="1.0" encoding="UTF-8" standalone="no"?><!-- This file defines how the corresponding script plug-in should be packaged--><Plugin>
    <Package>
        <File>Development/code/__init__.py</File>
        <File>Development/bS4/</File>
        <File>Development/bS4/__init__.py</File>
        <File>Development/bS4/.py</File>
        <File>Development/bS4/diagnose.py</File>
		<File>Development/bS4/element.py</File>
		<File>Development/bS4/testing.py</File>
		<File>Development/bS4/builder/__init__.py</File>
		<File>Development/bS4/builder/_html5lib.py</File>
		<File>Development/bS4/builder/_htmlparser.py</File>
		<File>Development/bS4/builder/_lxml.py</File>        
    </Package>
</Plugin>

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×