<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[External dependencies question]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto">I have a plugin that contain multiple subplugins (.pyp files) and want to know how to insert my lib modules to the system path and that affect all the plugin .pyp files.  (I have already seen the post: <a href="https://developers.maxon.net/forum/topic/7016/7915_external-dependencies-the-right-way-to-do" target="_blank" rel="noopener noreferrer nofollow ugc">External dependencies: The right way to do</a> and I did not find an answer concerning this point )</p>
<pre><code>lib\n    module1.py, module2.py, module3.py,...
res\n    &lt;resource files&gt;
plugin_1.pyp
plugin_2.pyp
plugin_3.pyp
...
</code></pre>
<p dir="auto">Must I use the "sys.path.inser()" method on each of my subplugins?<br />
I noticed that the subplugins is loaded one by one and in alphabetical order. so, for a test I created a  new file and I rename it "a.pyp" (to be loaded in the first) and then I put inside it the following code:</p>
<pre><code>import os
import sys
  
dirname = os.path.dirname(__file__)
lib_path = os.path.join(dirname, 'lib')
sys.path.insert(0, lib_path)
</code></pre>
<p dir="auto">This it works, and affect all the .pyp files of my plugin.</p>
<p dir="auto">Is there a right way to do that?</p>
<p dir="auto">Thanks.</p>
]]></description><link>http://developers.maxon.net/forum/topic/13229/external-dependencies-question</link><generator>RSS for Node</generator><lastBuildDate>Sat, 06 Jun 2026 20:40:45 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum/topic/13229.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 06 Mar 2021 09:50:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to External dependencies question on Mon, 08 Mar 2021 10:28:34 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/mfersaoui">@<bdi>mfersaoui</bdi></a> there is nothing wrong with the way you are doing, but I would like to point out that the sys.path is a global variable shared over the current python environment. Meaning that 3rd party will be able also to import your own module so it's recommended to have an ambiguous name (e.g. if your <a href="http://module1.py" target="_blank" rel="noopener noreferrer nofollow ugc">module1.py</a> is called <a href="http://util.py" target="_blank" rel="noopener noreferrer nofollow ugc">util.py</a>) people will be able to do import util and this can be really misleading so it's preferred to have a unique name (maybe you can start with a prefix).</p>
<p dir="auto">Finally, the solution offered by <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/mp5gosu">@<bdi>mp5gosu</bdi></a> is the cleanest one as it will create a local import space, so your <a href="http://util.py" target="_blank" rel="noopener noreferrer nofollow ugc">util.py</a> will only be importable by your own pyp file that actually calls the local import so it's so far the cleanest way as you are not "polluting" the global sys.path.</p>
<p dir="auto">But which one is the best, only you can decide according to what you are aiming to produce.<br />
Cheers,<br />
Maxime.</p>
]]></description><link>http://developers.maxon.net/forum/post/66041</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/66041</guid><dc:creator><![CDATA[m_adam]]></dc:creator><pubDate>Mon, 08 Mar 2021 10:28:34 GMT</pubDate></item><item><title><![CDATA[Reply to External dependencies question on Sat, 06 Mar 2021 10:23:37 GMT]]></title><description><![CDATA[<p dir="auto">Here you go: <a href="https://github.com/NiklasRosenstein/py-localimport" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/NiklasRosenstein/py-localimport</a><br />
That helper is also available as a minified version.</p>
]]></description><link>http://developers.maxon.net/forum/post/66038</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/66038</guid><dc:creator><![CDATA[mp5gosu]]></dc:creator><pubDate>Sat, 06 Mar 2021 10:23:37 GMT</pubDate></item></channel></rss>