Sublime Forum

Bundling Multiple Packages into One?

#1

Is it possible to bundle multiple packages into a single one?

I’m working on a syntax package for an interactive fiction language which supports multiple libraries in different locales. So I’d like to bundle two other packages providing snippets for English and Italian, but since these are mutually exclusive I’d also like to provide a command in the main package that enables one locale package at the time, excluding the other one.

For maintainance and distribution purposes, it would be much simpler if these could be shipped together since they are parts of the same whole. Also, it wouldn’t make any sense to install the snippets packages without the main syntax package.

Can this be done?

0 Likes

#2

from what I’ve seen, rather than trying to have multiple related/dependent packages, other packages get round this using a Python script to rename resources they don’t want active so that ST won’t pick them up automatically. For example, your package could have an English subfolder with sublime-snippet files in, and an Italian subfolder with sublime-snippet-ignored files in, and then the command can rename the files in the English subfolder to sublime-snippet-ignored and those in the Italian to sublime-snippet to switch to Italian. I guess this means you’d need the package to be installed unpacked though.

0 Likes

#3

Thanks @kingkeith.

That’s a reasonable workaround, although having to mass rename all files extensions is not as elegant as I hoped. I had though of this before, but I had doubts regarding a few points:

  • Package update concern — What happens when the package manager needs to update the package? Won’t these changed files prevent an update?
  • Zip Archived packaged — Aren’t packages distributed via packagecontrol deployed as Zip archive? How can renaming archived files be handled?

As for the current package, which is only avialable via Git, renaming files directly in the versioned package folder could also stand in the way of integrating updates via Git. I guess this only requires discarding changes, but if package switching could be handled outside the package folder it would be better for both cases.

0 Likes

#4

https://packagecontrol.io/docs/submitting_a_package#Step_5

0 Likes

#5

Rather than renaming/moving files, you can copy files from your package to a user directory (e.g. from Packages/MyPackage/lang/en/foo.sublime-snippet.ignore Packages/User/MyPackage/foo.sublime-snippet). Then, when the active language is changed or the package is updated, you clear out Packages/User/MyPackage and copy the appropriate files.

0 Likes

#6

Just a note: For performance reasons, if properly implemented, renaming files is much more optimal than deleting and copy files.

0 Likes

#7

Thanks to all of you for the precious info! I’ll do some testing and see which solution works out best.

@addons_zz:

For performance reasons, if properly implemented, renaming files is much more optimal than deleting and copy files.

I’ll have to consider this, for switching from one locale to another could occur frequently when working on parallel i18n versions of a project.

0 Likes

#8

This is a valid concern. It will depend on the size and number of files.

0 Likes