Sublime Forum

[Question] How install Package Control package as dependency?

#1

1. Briefly

I don’t find:

—— if user install package via Package Control:

———— what should make package developer, that another packages install in user
———— machine as Package Control dependencies?

Can someone show examples, how I can realize this behavior?

2. Argumentation

  1. If user don’t need install each dependency of each package manually, this can save the user time.
  2. In all package managers, which I use — PyPI/pip, npm, Chocolatey — dependencies (programs, modules, packages) can install automatically.

3. Settings

For example, I have package CriticMarkup.

4. Steps to reproduce

User install CriticMarkup via Package Control.

5. Expected behavior

  1. If Sublime MarkdownEditing or/and Sublime AcademicMarkdown or/and Sublime Suricate already install in user computer:

——— nothing occurs.

  1. If MarkdownEditing or/and AcademicMarkdown or/and Suricate don’t install in user computer:

——— missing packages will be automatically installed.

6. Did not help

  1. I find similar issues in Package Control issue tracker as #1089 → I don’t find working examples.
  2. Similar Local Packages package doesn’t solve this task.

7. Do not offer

  1. Yes, I understand:

——— if with the package install another packages:

————— developer must write it in package description/documentation.

Thanks.

1 Like

#2

Package Control doesn’t resolve “Sublime package” dependencies as of right now. However, it’s possible to list “Python package” dependencies, like requests, bs4, pygments etc. Although, somebody has to convert it to something Package Control understands, and then maintain it. So there is still a lot of manual labour involved in getting a Python package onto Package Control. The full list of all maintained Python packages is here.

You can list your Python dependencies in a dependencies.json file at the root of your plugin folder.

Anyhow, one way to check if a “Sublime package” is installed, is to check if it’s present in sys.modules:

import sys

try:
    mymod = sys.modules["Package Name.mymod"]
except KeyError:
    sublime.error_message('Please install "Package Name"')

From this recent thread.

1 Like

#3

Yes, I know it. See first section of my post.

I’m sorry, that I use incorrect markup in first edition of my question.

It check, but no auto-install except package. It not expected behavior for me.

Thanks.

0 Likes

#4

Package Control just doesn’t allow this kind of dependency installation as of now. You just need to document it in your plugin and say “You need to install XXXX plugin before installing this plugin”. It’s just the way it is currently.

0 Likes

#5
  1. Yes, I understood, that it no possible by default, but are there not built-in methods? For example, auto-install GitHub repositories.
  2. @randy3k quote:

As what it has stated, currently, there is no official support for
installing dependent sublime packages. Although there are ad-hoc methods
to install dependecies, eg, @FichteFoll 's code in #747 or using advanced_install_package command…

Thanks.

0 Likes

#6

It isn’t possible because no one has taken the time to do the work of implementing the functionality. There are plenty of decisions to be made about what exactly should be done for dependencies:

  • Are dependencies going to have version specifiers
  • What if two packages both list versions of another package as a dependency, but those versions conflict?
  • How are dependencies indicated in the user interface?
  • If the user tried to uninstall a dependency, does it deinstall all packages that rely on it?

My personal opinion is that instead of package “dependencies”, the concept of “bundles” should be created where a user can pick a set of packages and some default configuration and make it available to other users. This is a less-structured approach, and it leaves some work on the end user, such as individually removing packages, and removing configuration by hand. It also would allow ad-hoc distribution and wouldn’t require that bundles be submitted to the default channel. Instead, anyone could host a JSON file specifying the bundle information on any URL and any user could paste that in to their Package Control to install the related packages.

That said, I haven’t really had much time to work on open source in a while, due to family commitments.

4 Likes