Closed wbond closed 1 year ago
It means both, the module and the dist-info
path should exist in Lib then?
Yes. There is code to do that already for the migration of existing dependencies. See https://github.com/wbond/package_control/blob/four-point-oh/package_control/wheel.py.
Just found it some minutes later.
Hmm, well. Introducing the most non-pythonic part of python in ST.
While it opens the door to install packages via pip, I always disliked the way how normal libraries and such meta folders are cluttered next to each other, especially if meta file folders have different names than the package itself.
@wbond I'm currently looking at tackling this. Could you help me understand why the concept of load_order
was introduced?
@shardulbee Just be aware that https://github.com/wbond/package_control/issues/1516 really needs to happen before this.
The load_order
was introduced because I didn't write a Python loader for dependencies. Thus we needed to make sure all dependencies of a dependency were added to sys.path
by the time they were needed.
Can't we assume right now that all dependencies should be installed to the python33 folder, and then update to install to python38 once the schema is updated?
I'm not going to do a release with part of the work, and I'd much rather the code for installing dependencies make sure it has the info necessary to know where to install it. If we don't take into account the fact that we need to get version info from the package and then filter dependencies to find one that is compatible, we'll probably end up throwing away a bunch of code.
Packages will indicate what plugin_host they want to use via a file named .python-version
in the root of the package. We'll need to extract this data from the package, and then make sure downloads exist for the correct version of Python.
On a related note, the dependency installer code needs to be updated to handle a few things:
linux_arm64
, nor Python 3.8 dependencies..whl
files, which are zip files with some structureI wonder whether dependecies should be handled in a dedicated manager module and/or class rather than enlarging PackageManager class any further especially as the way they need to be handled changes a lot compared to normal packages.
Once dependencies are migrated, PC still starts downloading "missing dependencies" into the $packages folder. I'm not sure if that's intended?
This part is not yet implemented. That's the next step.
@rchl Unfortunately you'll have to find a different method to do what you were doing before. Dependencies were never really intended to do that.
At this point, it doesn't matter much if it was intended or not because it was possible and it has happened. :)
I don't know how many dependencies are affected by it but mdpopups is one that is rather widely used at least. I'm not trying to be difficult or demand anything but it could still be considered to handle that somehow.
mdpopups needs some changes to be compatible later on. Dependencies are meant to be libraries only without plugin-like behaviour. Those not have been respected it, will break.
At this point, it doesn't matter much if it was intended or not because it was possible and it has happened. :)
Unfortunately sometimes things have to break to move forward. There is no way to preserve dependencies with package files moving forward with multiple plugins hosts.
Plugins using mdpopups will just need to bundle whatever resources mdpopups provided before. There will be a release of PC4 and if mdpopups hasn’t migrated at that point, plugins will break.
There will be some time before PC4 is released to fix this, but packages can start moving away from putting package files in dependencies now.
If someone wants to highlight how package files are being used in mdpopups, I’m sure we can suggest an alternative approach.
mdpopups (which the only known dependency with package level resources next to lsp_utils) uses sublime-settings files and default.css as a "package level resource".
The default.css can easily be moved to the library.
If a dependency uses sane hard coded defaults for settings, the only effort is to provide an alternatative to "edit_settings" command, which pulls the default settings file from another resource.
Both of those breaking changes are fixable.
If a dependency uses sane hard coded defaults for settings, the only effort is to provide an alternatative to "edit_settings" command, which pulls the default settings file from another resource.
It wouldn't be possible for a dependency to provide a command in any way though since none of the files that can provide those (.sublime-commands, .sublime-menu, ...) would be read from the Lib folder.
There is nothing precluding a dependency creating a base command class and having plugins extend that. Sublime Text just won’t directly instantiate the command from the dependency, which makes sense.
It's not about that in that specific case though. The dependency wants to expose its settings to the user. It's not the job of a plugin to do that because there can be multiple plugins using a dependency and should all of them do that?
I’m sorry?
Dependencies won’t be able to do these things anymore, you’ll have to do something else.
The simplest options are:
mdpopups.get_default()
for the base configuration.The sooner this process starts, the less likely things will get broken.
I feel like we should rename dependencies to “libraries” during this “rewrite”. It will open up the term dependencies for future use if someone wants to make packages depend on each other, and it will make their intent more clear.
Hard +1 on the rename. That will make their role way more obvious and people won't expect to be able to depend on other packages either.
Throughout the last 4 years or so (basically ever since ST3 got the Lib folder) I have strongly discouraged anyone adding a dependency to the channel to depend on either loader.py
or ST loading bundled resource files, meaning we should have very few dependencies doing so. And indeed, it appears only mdpopups is (didn't check myself).
If such depenedency wants to streamline its configuration, it should find a different way to do that, such as by providing a command that performs the necessary UI setup for user configuration and then suggesting dependant packages to include a certain snippet in some menu file (that will deduplicate if every level is bound by an id). Unfortunately, that won't do for the command palette, where packages would need to either namespace these commands or the user would end up with multiple entries.
Maybe sublime_plugin
is interested in exposing an actual endpoint for registering custom commands like that?
I was keen enough to push the open PR towards this direction, already, as it just feels right this way.
What's the status on this now?
According to https://github.com/wbond/package_control/tree/wbond-four-point-oh in the middle of heavy changes to rework infrastructure, I'd say.
With 1b34ff1ea12af2ac4a8109f6963e880a11d96b82 four-point-oh has reached a state of being able to install/upgrade/remove ST3-style dependencies into Lib/ folder.
Since Sublime Text 3.0, we've shipped a
Data/Lib/
folder that contains Python-version-sepcific folders that are automatically added to thesys.path
. The intention of adding these was to set the environment up so that Package Control would switch to using a more sane way to install dependencies.Currently, PC puts dependencies into a package folder with the name of the dependency. However, this was messy, and due to the load order of packages in Sublime Text, a special packages was created to inject the dependencies in the environment before any real packages were loaded.
The work on this has started, and https://github.com/wbond/package_control/blob/four-point-oh/2_bootstrap.py works on migrating dependencies in
0_package_control_loader
to theLib/python33/
folder.The approach to installing dependencies moving forward will be:
0_package_control_loader
. Thus all code related to this will be ripped out.Lib/
folder for the appropriate Python version. At a high level, the installation should be done in such a way that it will look like a.whl
was installed. The reason for this is that we'd like to support the ability to install.whl
files in the future.There will end up being quite a bit of code in https://github.com/wbond/package_control/blob/four-point-oh/package_control/package_manager.py modified to deal with the new approach to dependencies.
The concept of
load_order
for dependencies can be dropped since the Python import functionality will deal with what we used to handle via0_package_control_loader
.