Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement part of Github direct upload method #137

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

shaunakg
Copy link

This adds some methods into the exporter class and export wrapper class to facilitate the direct export of the JSON representation into Github. It also adds some config entry fields where the user can put their Github personal access token, username and repository name.

This is not ready for merging yet because it does not actually show up in the UI as an export option. I am working on doing this but it will likely require the rewriting of part of the export dialog.

It includes the dependency PyGithub because it is much easier to use the API of Github over natively implementing Git through preexisting dependencydulwich and pushing the files. This might be able to be done but would be much more complicated (in my opinion).

@Stvad
Copy link
Owner

Stvad commented Jul 15, 2021

Hi @shaunakg,

thanks for contributing this!
I'm currently travelling and have reduced availability, but I should be ablet to look at this in ~1.5 weeks.

re PyGithub - it's ok, as long as it does not transitively pull in dependency on native things (e.g. native git binary?)

@aplaice I'd appreciate you taking a look as-well if you have a chance!

@aplaice
Copy link
Collaborator

aplaice commented Jul 23, 2021

This would be really convenient to have, so thanks very much for writing it!

Unfortunately, I haven't had time to look at or test it.

re PyGithub - it's ok, as long as it does not transitively pull in dependency on native things (e.g. native git binary?)

On a very cursory glance, it seems that PyGithub depends on PyNaCl which is a wrapper around libsodium — according to the relevant documentation "PyNaCl ships as a binary wheel on macOS, Windows and Linux manylinux1". However, I haven't dug too deeply, so I'm hopefully wrong!

@Stvad
Copy link
Owner

Stvad commented Aug 6, 2021

If it is bringing in a binary dependency - I don't know of a way to properly package it into the anki plugin such that it'd work properly on all platforms 🙁

@ahmedyarub
Copy link

If it is bringing in a binary dependency - I don't know of a way to properly package it into the anki plugin such that it'd work properly on all platforms 🙁

By "all platforms" do you mean mobile platforms also? In that case you can enable the feature only in Desktop platforms and disable it for the mobile ones.

@aplaice
Copy link
Collaborator

aplaice commented Jan 5, 2022

By "all platforms" do you mean mobile platforms also? In that case you can enable the feature only in Desktop platforms and disable it for the mobile ones.

No. The issue is that it seems that PyNaCl requires a compiled C component.

The maintainers of PyNaCl have uploaded binary wheels to pypi, so that when installing with pip (or pipenv etc.), pip simply downloads the wheels from pypi, appropriate for the given platform (Windows, Linux, MacOS, etc.) and the given processor type (x86, arm(32|64) etc.), provided these wheels are available, so there's little issue.

However, an Anki add-on has to be self-contained, so for PyNaCl to function we'd have to include all the many different binary wheels and use the correct ones at run-time. The problems are:

  1. I'm not sure if this (choosing among different packaged wheels at run-time) is even possible.
  2. If it is, it's tricky to get right, and would increase complexity.
  3. It'd likely considerably increase add-on size.
  4. I'm not sure if uploading compiled code to AnkiWeb is even allowed.
  5. We'd have to be very careful to include the binary components for all possible desktop platforms.

(Anki add-ons aren't available on mobile (iOS or Android) at all, so mobile Anki isn't the issue.)

@ahmedyarub
Copy link

Thank you for the detailed reply. I'll try testing this on my machine but I remember a similar case of XGBoost where the binaries for all target platforms were included in the final package. I'll test and come back to you later.

@aplaice
Copy link
Collaborator

aplaice commented Jan 5, 2022

An alternative might be to use a different python GitHub API — e.g. ghapi — instead of PyGitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants