I am using a custom library I created in git to create an application. I want to be able to edit the source code directly and have it update in the library imported in Anvil.
After pushing an update to my library, I tried re-building the packages I am using in Anvil to get the latest version of my library. The only way I was able to do this is by either adding another package or changing the base package choice. However when I remove the extra package I added for the new build, I noticed that there was no loading time at all. Now I am not sure if Anvil just switched to the old build or if deleting the extra package was just that fast.
Is there a way to just rebuild directly without going through this loop?
I am not speaking about Anvil git integration, I use that and it is working well for me too.
I have an external private git repo that I import into the project as a package/library in Settings->Python versions->Python versions and packages.
I push daily updates to my private library repo (again, this repo is an external repo and has nothing to do with the repo my app is integrated in). However, unless the Anvil app rebuilds the program, the version of my library used in the app always remains the old version. To rebuild the app, I need to add an extra package that I don’t need.
Right now, I don’t know a direct way to just rebuild the whole app and pull the git latest versions. I need a way that forces “re-build” the application so that the newest version of my library is always pulled into the app.
I thought you’d simply incorporated it into your Anvil App’s local repository. (I think it’s called “vendoring” a package.) Would that work in your case?
I have done something similar, with pip (not with anvil).
You can follow the instructions on how to add a project to pypi, but not actually publish it there.
If you then use the ability to add a package to an anvil app via pip, you can use a link to your git repo.
If you have daily builds, you can change the version number in the projects .toml to a yyyy.m.d date format and have anvil update to the latest version of your repo whenever you like.
…if I were to do this automated tests would kind of be a pre-requisite.
Hmm, not sure. From the way I understand vendoring in this scenario, I’d have to have all my library locally under my app. This defeats my purpose of keeping it as a git repo that I can access to work on in different environments. Please correct me if I am wrong.
Actually, that is exactly how I have it. My version number is also a datetime value so it’s always a new version. My issue was never with importing it, my issue is with importing the latest version after a push. Anvil goes back to the old builds without rebuilding the program, which results in using an old version.
For example, let’s call my library Lib1. In Anvil packages, I use Boto3 and Lib1 (V1.0).
After a push, I’d have Lib1 (V1.1). Since the build for Boto3 + Lib1 is already built from a previous time, Anvil doesn’t rebuild or check for the version number, it directly uses the old build with Boto3 + Lib1 (V1.0).
The only solution I found is to then add another library so that Anvil will have to rebuild. So I add Boto3 again; Boto3, Boto3, Lib1. With this, I get the latest version of my app. But with my next push in the repo, I have to add yet another boto3 to enforce a rebuild. So I’d have : Boto3, Boto3, Boto3, Lib1. This is actually how I have it now, lol.
I was looking for a way to just manually re-build the whole app dependencies, but I guess it’s not implemented (yet?).
Ahh I understand now, I don’t really use the beta or the new pip install features, so others will have to tell you if their experiences contain any workarounds for this.
With vendoring, it’s more like a copy of the relevant parts of the latest stable version of that library. The library’s original repo remains as-is.
Edit: the advantage is that you update the App’s copy of the library on your own schedule. You control when it gets updated. Which, if I understand correctly, is what you wanted.
If nobody knows, this might be a question for @daviesian ?
( I only think this because he is the one who announced the feature, I am not completely sure if he is connected with it’s implementation)
@ahmed.zeitoun is right - manual rebuild is not yet implemented, but it’s on our list to add. In the meantime, you’ve found the correct workaround: Change the list of packages. The cleanest way to do this is probably to install a particular version of your library. For example, I can see that the latest commit in the dateutil library is 7c5c98959bd0e9eea3c55fdf78bef3ae5b8c995e, so I can do: