packagecontrol / channel

Package Control Libraries Channel
https://packagecontrol.github.io/channel/
3 stars 5 forks source link

Question regarding renamed dependency/library. #1

Closed writeml closed 8 months ago

writeml commented 8 months ago

I've been working (on and off, inconsistently) on a new package, and I added a dependency (https://github.com/wbond/package_control_channel/blob/master/repository/dependencies.json#L842-L856) to "python-docx" (https://pypi.org/project/python-docx/) awhile ago, and named it "python-docx" (since that's its name in PyPi...)

And I see that in the new v4 schema this dependency was ported over as a library, and has been renamed to just "docx" (https://github.com/packagecontrol/channel/blob/main/repository.json#L380-L392)...

Since I've been away from package development for awhile, I'm just now catching up on all the new Package Control v4 stuff, and the question I have is this:

Can I / Should I develop (in a "future proof" way) my package (v1 of which I hope to submit/publish sometime in the next few months) so that it works with the current Package Control v3 and the new v4, or do I basically have to decide to target one or the other and either:

  1. Target v3 and then update to v4 whenever it becomes officially supported, or...
  2. Go ahead and target v4 now, and potentially wait to release it until whenever v4 ships (and is there a current estimate for that?)

Specifically, I assume that if they both had the same name, then I could reference it once from my dependencies.json file (if that's even still how it'll work in v4?) and then whenever the switchover happens, it would be seemless... But since they have different names, I don't know if referencing both together would cause conflicts, etc...

Either way (1 or 2 above, or some way to support both simultaneously) is fine, I just want to know what's possible, and how to even support the new v4 stuff from a package, and then figure out the best way to approach this, again just from a "future proofing" and/or "what will be the most seemless user experience once v4 launches" standpoint... Also, is there any new documentation anywhere for developing a package with v4 in mind, since the current docs at https://packagecontrol.io/docs are still only for the currently supported v3...? If there is, they probably already answer all my questions, but I just couldn't find them 🙃

Thanks, for whatever guidance you can offer, and also just for all the work and dedication over the years on this project, and Sublime Text in general 🎉

Edit to add: I kinda doubt anyone's actually using the old dependency (not sure anyone but me would need docx support/capabilities in their package), so I could potentially rename that one to just "docx" to match the new library, if that helps streamline them... Anyway, thx again!

deathaxe commented 8 months ago

Package Control 4.0 is able to install libraries directly from pypi.org - even though they still need to be registered in a repository_v4.json.

Some libraries actually are already shipped via pypi for python 3.8. Therefore it's crucial to avoid naming conflicts - as it may cause libraries to overwrite each other - depending on where they are installed from.

Package Control 4.0 therefore maintains a dependency-to-library-name-map to transparently translates old dependency names to ensure backward compatibility with existing packages.

That said it is safe to use the old names.

Actually Package Control 3.x is end of life. It is expected to auto-update itself to 4.x on normal setups, so there's basically little requirement to still support the old one.

If we had write access to packagecontrol.io server we would already have upgraded it to only support 4.x and ship latest sublime-package via ST's installer. The only person who could do that is currently (in worst case no longer?) available.


python-docx has been renamed to docx with the assumption its counterpart being https://pypi.org/project/docx/.

As it seems there are various packages targeting docx registered on pypi.

We can also point to another pypi package.

_Supporting python-docx however requires an update of Package Control as its .dist-info directory name is python_docx. It seems hyphen needs to be translated to underscore._

deathaxe commented 8 months ago

The dependency has been renamed back to its original name.

Once Package Control 4.0.3 has landed we can also update the channel to point to a release on pypi, in case the original ST dependency is no longer maintained/updated.

writeml commented 8 months ago

The dependency has been renamed back to its original name.

That's great, I see that change here in the latest version, thanks so much!

python-docx has been renamed to docx with the assumption its counterpart being https://pypi.org/project/docx/.

As it seems there are various packages targeting docx registered on pypi.

I didn't know about https://pypi.org/project/docx/, and looking at it I see that A) it's still a pre-release version, B) the last update was in 2014, and C) one of the contributors is scanny, who is also the maintainer of https://pypi.org/project/python-docx/, which had it's official production release in October, and is the project that's actively being maintained, etc... So, obviously, 'docx' must have been, like, a test version, or is now a seemingly abandoned first attempt, or something... 🤷

Package Control 4.0 therefore maintains a dependency-to-library-name-map to transparently translates old dependency names to ensure backward compatibility with existing packages.

I see that DEPENDENCY_NAME_MAP still has this entry: "python-docx": "docx" ... Should that be removed now that the library has been renamed...? And assuming, of course, that we agree 'python-docx' is the right PyPI project to track, and not the older/unmaintained 'docx'...?

Once Package Control 4.0.3 has landed we can also update the channel to point to a release on pypi, in case the original ST dependency is no longer maintained/updated.

Technically I can keep it maintained, but there's really no reason to now that we can just point these libraries directly to PyPI... Me maintaining that 'man-in-the-middle' GitHub repo going forward would just be an extra, unnecessary expense at this point...

I'll open a PR to change this library to just point directly to PyPI, so it's ready to go whenever we feel it's appropriate...

_Supporting python-docx however requires an update of Package Control as its .dist-info directory name is pythondocx. It seems hyphen needs to be translated to underscore.

You're saying there's work that still needs to be done to support this case...? Would you like me to open a separate Issue to track that work?

Thanks again for all your help here, it's much appreciated!

writeml commented 8 months ago

For posterity: I did a little more digging, and I see that the GitHub repo for the 'docx' project has been archived, and the README now says that the 'python-docx' project is, in fact, the official one...

This Project Has Moved!

Python DocX is now part of Python OpenXML. There's all kinds of new stuff, including Python 3 support, sister libraries for doing Excel files, and more. Check out the current Python DocX GitHub and the current Python DocX docs.

Info below is kept for archival purposes. Go use the new stuff!

deathaxe commented 8 months ago
  1. Dependency name map has been updated to remove python-docx.
  2. PEP491 library name escaping has been added.

see: https://github.com/wbond/package_control/releases/tag/4.0.3

writeml commented 8 months ago

Thanks for all the help @deathaxe!