or Create a profile
Anki (Computer Version) →
27 Mar, 2020 07:18 PM
Hi Damien (and others):
I have a bunch of code which I want to operate on the Anki database. It would be inconvenient to write this code as an Anki addon.
(It's here: https://github.com/agentydragon/anki-utils/blob/master/src/deploy/d.... It non-interactively updates card templates. I could implement it as an addon, where I'd have a dialog that would take a .zip or .json or whatever file and then set the card templates. I might actually end up using this solution if there's no other way, but let's for the sake of discussion leave that option aside.)
In my module I add where I know Anki's Python sources to be into sys.path and then import anki, and then do whatever I need on the anki module.
However, this recently broke for me when I switched from using Anki from Ubuntu's repositories to the official packages from https://apps.ankiweb.net/; while the apt package actually copied over Anki's .py files and ran them using system Python, Anki's official distribution (IIUC) has a bundled Python, the packages are binaries and I haven't figured out how to actually import them from my system Python (which is 3.7, not 3.8 as the one bundled with Anki). [there might be a way to do that but I haven't just figured it out yet myself]
It would be really practical for me if I could just say that my project has Anki's pylib as a PyPI dependency.
But the anki and ankirs packages in PyPI are just stubs saying to use GitHub to get the package.
Would it be feasible to publish the core (non-Qt) parts of Anki on PyPI?
(I know there is Rust code now, which is problematic, but I assume it's not impossible to solve - other Python packages also have native parts.)
More broadly speaking, this is a question of "how to correctly write and run a program that depends on Anki".
Right now, the only working process for running code that depends on Anki I can think of is:
This should work, but it's impractical, and I would hope there would be a better solution than this :(
I assume that it's technically possible to publish Anki's Python parts on PyPI, but it's probably not being done because it might take a lot of annoying setup.
Any ideas? Thoughts?
on 28 Mar, 2020 03:58 AM
'make build' produces Python wheels you can install and redistribute to other machines. Evandro recently updated the CI infra so that they're also produced as part of the CI process, and they can be downloaded from the checks page.
on 28 Mar, 2020 01:36 PM
Neat! If I or someone else creates a process to also publish the wheels into PyPI as part of the release steps, would you be willing to merge the changes in?
on 28 Mar, 2020 06:19 PM
I could make it publish to pypi each new release (e.g., git tag 2.23) instead of each commit to master. By creating a GitHub secret https://github.com/ankitects/anki/settings/secrets on an environment variable with a token to pipy http://pyfound.blogspot.com/2019/07/pypi-now-supports-uploading-via...
git tag 2.23
on 28 Mar, 2020 06:23 PM
If Damien is OK with it and the setup works, it would be really helpful and I'd appreciate it :)
on 29 Mar, 2020 10:17 AM
I can see how it could be useful - if you guys are happy to contribute the relevant scripts, I have no objections to having this run on tagged releases.
on 30 Mar, 2020 04:29 AM
I will be working on this. When the code is done, I will open a pull request: (https://github.com/ankitects/anki/pull/535 - Created the GitHub Actions step Upload to PyPi)
on 30 Mar, 2020 11:26 AM
on 05 Apr, 2020 08:39 AM
Thanks for working on this!
Damien, would you consider cutting a release soonish? I'm looking forward for having Anki in PyPI :)
on 05 Apr, 2020 06:17 PM
He could push the tag 2.24.1 on the same commit he pushed the tag 2.24
on 05 Apr, 2020 06:55 PM
(I'd expect cutting a new release might be easier than applying the new PyPI push machinery to an old commit)
on 05 Apr, 2020 07:15 PM
After thinking, if he created a tag 2.24.1 over the old tag 2.24, it would probably not publish the package to pypi because on that time/commit, there was no such code on the GitHub checks.
Then, he could just push the tag 2.24.1 over the latest commit on the master branch, as a "hotfix" for pypi.
on 06 Apr, 2020 04:07 AM
I'm afraid it'll likely be at least a few more weeks before 2.1.24 is ready
Formatting help /
(switch to plain text)
(switch to Markdown)
You can attach files up to 10MB
If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.
A conversation has been started with the Anki staff to resolve this discussion.
This discussion is private.
Only you and Anki support staff can see and reply to it.
This discussion is public. Everyone can see and reply to it.
You can use Command ⌘ instead of Control ^ on Mac
Powered by Tender™.