Installing modules with .tar.bz2
I'm trying to install a module with pipista. The module is packaged with .tar.bz2. Installation fails with 'ERROR: Something went wrong'. After reviewing pipista.py file my (python novice) assumption is the .bz2 extension is not handled in pipista.py. Is there a work around to get .bz2 extracted so I can then install the module into Pythonista? The module is pure python library.
http://omz-forums.appspot.com/pythonista/post/5794924494585856 According to this post pipista does not uncompressed/unpack (unzip / ungzip / unbz2 / untar) its results. There are several modules in Pythonista for doing that: http://omz-software.com/pythonista/docs/library/archiving.html but the current pypista does not do that uncompressing/unpacking for you.
Funny, I was just working on modifying pipista version 2 to add in bz2, and get rid of some of the pythonista 1.4 workarounds, which are now OBE. pipista version 2 had auto unpack and attempted to auto install too.
Is there a GitHub repo for pipista v2? https://github.com/search?q=pipista
I was just playing around with generalizing the unpack functionality to allow bz2 tars. In going through the code, there is a bunch of stuff which is workarounds for pythonista quirks, some of which may no longer exist in recent versions. Haven't really dug into it much yet. It would appear he once had setup.py functionality working, which would be cool. I think we'd use site-packages now, rather than the pypi-modules folder.
Ahhh yes. The "unstable branch" comment always scared me ;-) It would be nice to get this in a repo instead of a gist so that multiple folks can contribute to improvements to a common codebase. Same for DropboxSync.
CCC thanks for the assist. Still haven't got the module unpacked and installed, between a lack of time and understanding how to accomplish this in pythonista. I have looked around the forum and I'm glad the topic came up in this thread. Having packages in github will probably help newcomers find the most current rev. Instead of finding a recommended package in gist then stumbling across a newer gist with hundereds of additional lines of code. Maybe there can be a sticky post in the forum to always keep the git repo at the top.
JonB, just wondering, when you finish updating will you share to the Git?
import pipista #import bz2 import tarfile #from bz2 import decompress #from bz2 import BZ2Decompressor pipista.pypi_download('apache-libcloud') print () print type('apache-libcloud-0.15.1.tar.bz2') apachelibcloud = tarfile.open('apache-libcloud-0.15.1.tar.bz2') apachelibcloud.extractall() apachelibcloud.close() print (apachelibcloud) pipista.pypi_install('apachelibcloud') #<<< this is where it errors out with no pypi error: no package by that name.
The pypi error makes sense as pypi_install is still looking into pypi package list.
After I've downloaded the package and extracted it (apachelibcloud) how do I go about installing it in Pythonista?
Pypi install would have used the same name as download...
In general, you can usually just look at the untar'do folder, and there will be another folder. Forget about the setup.py, and just copy the real folder someplace useful. Inside that real package folder is the actual py file you want, or in the case of a package, you want the whole folder.
In the libcloud case, after untar you have a new folder. Navigate to that folder in editor file browser, and then you will see a libcloud subfolder. Move the libcloud folder to site-packages, if you want to be able to import regardless of where you've chdir'd.then
Then, you should be able to
JonB you are correct. Thank you for the suggestion to move libcloud folder to site-packages. I'm sure that would have probably been the next question from me in this thread.
I will say yesterday I didn't notice the folder and after you mentioned it I looked and noticed it. Also upon your suggestion to move libcloud to the site-packages folder I was only able to import from the the compute module. I though it was an issue with the download or extraction, but I restarted Pythonista before looking at the issue. The restart appears to have resolved the issue with accessing other modules than just the compute.
from libcloud.compute.types import Provider #<<<worked without any issue from libcloud.storage.types import Provider #<<<didn't work said ImportError: # Could not import name. After restarting pythonista I was able to run the script with no script # modification. No import error was returned.
Should pythonista be restarted when files are added, moved or changed?
The above syntax is importing two different things yet calling them by exactly the same name. If you were to
print(Provider.__version__)which one would you expect to get the version number of?!? I would have used a syntax such as:
from libcloud.compute.types import Provider as compute_Provider from libcloud.storage.types import Provider as storage_Provider print(compute_Provider.__version__, storage_Provider.__version__)
When things are moved, added, changed, you can always call
reload(<module name>)to ensure that Pythonista has loaded the latest and greatest.