Sublime Forum

Testing a dependency on other os

#1

Hi all,

I’m working on a plugin which uses sublime-paramiko as as dependency. Sadly this library is not available on all operating systems. Recently (about 3 months ago) the library however got an update, adding various files for windows compatibility. But it seems this is not tested yet.

Is there any way, how I can test this dependency on a windows machine? I have tried to copy it to the Sublime Package directory, but it does not get loaded during the startup.

Thank in advanced,
Steffen

0 Likes

#2

Package Control manipulates sys.path to make libraries from within Packages folder.

You could put the library into Data/Lib/ folder for testing which is part of sys.path by default.

0 Likes

#3

Thank you for yout resonse! Sadly this doesn’t seem to work either. Have copied the dependency directory to Lib, but it won’t get loaded during Sublime Text startup.

0 Likes

#4

Did you put it directly into the Lib folder or into the python3.3 directory inside of Lib? The Lib folder itself isn’t in sys.path.

0 Likes

#5

I’ve tested it with both directories.
However, the version on github is missing the sublime.dependency file. Could this maybe be a problem?

0 Likes

#6

Just for the sake of clarity, the Lib folder mentioned above is for putting “bare” Python libraries into place for use in the plugin host, which is different than the mechanism that Package Control uses for dependency libraries, which works by putting specially constructed packages into the Packages folder and doing some extra setup behind the scenes to make them appear to plugins.

As such, the two things end up doing the same thing, but in very different ways.

If you want to go the Lib folder route for testing things, you need the paramiko folder to be inside of $DATA/Lib/python3-3; don’t include the sublime-paramiko part or the all folder that exists inside of it, just the paramiko folder. This mimics what would happen if you were using standard Python and installed the library.

If you do that, then import paramiko should work (assuming that’s how you use that library; I’m unfamiliar with it) and as far as your plugin is concerned, that’s how it would work if it was a Sublime dependency as well.

If you want to test it as an actual dependency package as if Package Control installed it, then you’d clone the entire repository into the Packages folder, so that you’d have $DATA/Packages/sublime-paramiko/ (which itself contains an all folder, which then contains the paramiko folder).

Once you do that, inside of the sublime-paramiko folder create a file named .sublime-dependency with the content being a single line with the number 51 in it, and then choose Package Control: Install Local Dependency to get Package Control to do its own setup work. Essentially this creates an entry inside of the special 0_package_control_loader package that gets Package Control to adjust the sys.path for you.

If it works, then if you were to go into the console and check, you’ll see an entry for sublime-paramiko/all being added to the sys.path (here I tested it on Linux, but the idea is the same):

>>> import sys
>>> sys.path
['/tmp/bob/sublime_text_3_3211', 
'/tmp/bob/sublime_text_3_3211/python3.3.zip',
 '/tmp/bob/sublime_text_3_3211/Data/Lib/python3.3',
 '/tmp/bob/sublime_text_3_3211/Data/Packages',
 '/tmp/bob/sublime_text_3_3211/Data/Packages/sublime-paramiko/all']

Package Control has an entry for this dependency (see below), which is explicitly locking it to be only available on osx; in order for this to work in the general case, that entry has to be modified to also include windows as a supported platform.

I don’t think that should affect anything for testing purposes (since it works for me here on Linux, for example) but if you were to add a package that said that it relied on this dependency, Package Control would only be able to install it on OSX unless the entry was changed.

1 Like

#7

Thank you really much for this long and complete answer.
Now both ways work to include the library for testing purposes. :slight_smile:

0 Likes