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

Import from zip files #659

Closed
rcarmo opened this issue Sep 17, 2014 · 7 comments · Fixed by #2354
Closed

Import from zip files #659

rcarmo opened this issue Sep 17, 2014 · 7 comments · Fixed by #2354
Labels

Comments

@rcarmo
Copy link

rcarmo commented Sep 17, 2014

It would be handy to be able to import .hy files from .zip archives (for those of us who like to deploy stuff in single file bundles).

Right now I'm working around this by doing:

BUNDLE=sushy.zip

clean:
    rm *.zip

bundle:
    hyc sushy/*.hy
    zip -r9 $(BUNDLE) . -i *.py *.pyc

test-bundle:
    PYTHONPATH=$(BUNDLE) python -m sushy
@paultag
Copy link
Member

paultag commented Oct 6, 2014

Not a bad idea -- we should likely implement this as a second PEP302 loader -- after all, it is what they were designed for :)

@rcarmo
Copy link
Author

rcarmo commented Jun 29, 2015

bump

I'm also getting trouble with Hy under PyPy. hy -m foo isn't working for some reason, will investigate that on other issues...

@Kodiologist
Copy link
Member

@allison-casey What do you think needs to be documented yet? It seems to just plain not work at the moment.

@allison-casey
Copy link
Contributor

I believe this was documenting that, because Hy is a python dependency you can only make zip apps via shiv which packages the dependencies with the module unlike Python zipapp

@Kodiologist
Copy link
Member

I think that's about the distinct issue #1774. This issue is about import from a ZIP archive, not about self-contained executables. shiv shouldn't be necessary in this case.

@allison-casey
Copy link
Contributor

ahhh i misread. then we can remove the doc me and leave the feature.

@Kodiologist
Copy link
Member

Adapting the example from the documentation of zipimport:

$ echo '(print "zawinski")' >jwzthreading.hy
$ zip example.zip jwzthreading.hy
  adding: jwzthreading.hy (stored 0%)
$ rm jwzthreading.hy
$ unzip -l example.zip
Archive:  example.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
       19  2022-11-05 16:25   jwzthreading.hy
---------                     -------
       19                     1 file
$ python3
Python 3.11.0 (main, Nov  5 2022, 14:58:16) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import hy, sys
>>> sys.path.insert(0, 'example.zip')
>>> import jwzthreading
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'jwzthreading'

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

Successfully merging a pull request may close this issue.

5 participants