-
Notifications
You must be signed in to change notification settings - Fork 92
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
zodb install on termux linux for Android doesn't work due to no os.link #257
Comments
While a pip install zodb within the termux distro for Android completes without incident, it fails to run since any attempt to import ZODB within termux's python fails. This is because their python's os.link has been disabled for some cross platform reason related to windows. I have found two issues related to this problem that other apps experience. pip was the first one and it seems that pip was modified to test to see if os.link is available for the platform and substituting another call if it is not termux/termux-packages#29 Is there a similar fix that can be made available for zodb? I want to be able to use zodb not only within my laptop's scripts but also for these same scripts to run within the termux distro on Android. |
@zennobjects The only ZODB library code which uses The |
hasattr(os, 'link') might be a reasonable check. |
In order to identify that I'm on termux, I use the following code in my scripts. It's based upon identifying certain features from within python - my platform (aka operating system) and - my device (hardware). Plus one more additional piece of information. Termux modifies the python that their "pkg install python" provides for a number of specific reasons, one being that their file system layout is different (because, because). Since termux is running within Google's android services, the app relies upon a specifc NDK in order to be built. Ergo there is an attribute patched into their python that tells us, we're running on top of Android system #21 as an example. Here is my code:
So for my purposes, putting zodb's os.link calls between
should suffice to run the necessary substitution of the shutil.copy command for os.link. |
Looking at the code within blob.py, the change might be something like this:
|
In order to test the changes, I simply used vim to change blob.py residing in the user python's site-packages/ZODB, and insert the line
between a
rather than go through the whole recompiling and wheel creation of zodb for my termux version of linux running on an Android platform. It works like a charm. So I can confirm that there are no other issues preventing zodb from working as a result of this change. There is no need to identify that zodb is running within termux, that it's on an Android platform, whatever. It's a simple change to the blob.py script that can be easily added to zodb. Shall I submit a patch? |
@zennobjects Please do submit a PR. You can add a |
@tseaver @zennobjects Was the issue solved? I don't see a linked PR. |
Wow, a long time ago. Seems like I didn’t create the pull requests. I can’t even find my clone of this app where I changed the line within the blob.py file. What I can say is this. The solution that I wrote, the one where the value for link_or_copy gets changed in the try:except clauses, works. The quickest solution is to use an editor and change that line in the blob.py file under ZODB within the termux ZODB. |
I just submitted a pull request for my proposed changes. |
There are two test failures, 1 failure for Ubuntu.lint and another for each python version on Windows. [1] I think the failure for Ubuntu.lint is due to a lint check wrt the use of '#'. I've made minor changes to those comments. [2] I am somewhat at a loss to see why the following error occurs for each python version on windows.
It could be that the following check is no longer valid, possibly due to the check for sys.platform == win32 failing
in which case link_or_copy is never set. If this is the case, then the fix that I proposed is not what breaks the code for Windows Nevertheless, the following might fix this It could be that we should remove the setting of link_or_copy completely from within the 'if' block.
and instead have a stand alone setting of link_or_copy which is at the same level as the various functions within blob.py def rename_or_copy_blob(f1, f2, chmod=True): try: I'm resubmitting the pull request with these two changes. |
Man, it doesn't pay to be fixing code just after surgery. The littlest changes result in errors due to the discomfort. |
Here is the traceback error resulting from an attempt to import ZODB into any python script running on termux for Android.
The text was updated successfully, but these errors were encountered: