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

Add support for other Python implementations #934

Open
gilch opened this issue Sep 8, 2015 · 10 comments
Open

Add support for other Python implementations #934

gilch opened this issue Sep 8, 2015 · 10 comments
Labels

Comments

@gilch
Copy link
Member

gilch commented Sep 8, 2015

There are other implementations of Python that we're not testing with Hy. We should add them to our testing if possible.

If Hy is fundamentally incompatible with a given implementation, we should say so in our docs. I searched Hy's docs for "IronPython", "Jython", "Cython", "ShedSkin", and "Pyjamas" but found nothing.

Even "PyPy" wasn't mentioned, but we do appear to be testing that.

@refi64
Copy link
Contributor

refi64 commented Sep 8, 2015

I seriously doubt that eithee Shedskin or Cython would work: the former is very, very restrictive; and the latter, I believe, uses a custom parser.

@zackmdavis
Copy link
Contributor

I was not able to install Hy with Jython 2.7.0 due a problem installing our clint dependency (looks likely to be issue no. 2158, the fix for which didn't make the release):

(jirtualenv)zmd@ExpectedReturn:~/Code/Misc/Jython_Sandbox/jirtualenv$ pip install hy
Collecting hy
  Using cached hy-0.11.0.tar.gz
Collecting rply>=0.7.0 (from hy)
  Using cached rply-0.7.4-py2.py3-none-any.whl
Collecting astor>=0.5 (from hy)
  Using cached astor-0.5-py2.py3-none-any.whl
Collecting clint>=0.4 (from hy)
  Using cached clint-0.5.1.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/tmp/pip-build-R_NesT/clint/setup.py", line 12, in <module>
        import clint
      File "clint/__init__.py", line 21, in <module>
        from .arguments import *
    ImportError: No module named arguments

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-R_NesT/clint

@gilch
Copy link
Member Author

gilch commented Oct 17, 2015

I also wonder about mobile Python implementations. For Android, I'm aware of SL4A and Kivy (actually the sister project https://github.com/kivy/python-for-android). I think someone (Edit: xikuuky) mentioned getting Hy working on Android over IRC, but I don't know which one. I'm not familiar with any Python on iOS, but that possibility might also be worth looking into.

@Foxboron
Copy link
Member

@paultopia
Copy link

Newbie here poking around looking for ways to get involved.

Re mobile, there is a python implementation for iOS, actually a few, but the most popular is a closed-source paid implementation called pythonista. It's a little restricted due to apple sandboxing---only supports 2.7, currently no way I know of to get many modules in (anything that depends on C for example) unless the guy who writes it packages it in the core "app" in an update (for example, I haven't been able to get sci-kit learn in). But there are a variety of hacks to get modules written in pure Python in. It's all very samizdat, lots of scripts to download other scripts off github and the like, because Apple has Feelings about sideloading code.

I may try and muck around a bit to see if I can get hy to install in a few days, will report back.

@paultopia
Copy link

Ok, I've done a little experimenting. I can get hy installed via the latest (2.0) version of pythonista on ios, but only after a bit of rigmarole. I can also get a repl. But I haven't managed yet to get it to execute anything else, I suspect simply because the way I've hacked it together it needs manual imports of basically everything.

Steps so far:

  1. Manually install stash (a commandline clone): https://github.com/ywangd/stash
  2. From stash command line, manually install dependencies in the following order via pip: 1) appdirs, 2) the listed dependencies in setup.py (astor, clint, rply)
  3. Close stash command line (trying the below without doing this first led to a crash, I suspect because of memory)
  4. Switch to pythonista console (repl). Then, in console:
>>> import hy
>>> import hy.cmdline
>>> hy.cmdline.hy_main()
hy 0.11.1 using CPython(default) 2.7.5 on Darwin
=> 

And we have a hy repl! Unfortunately, trying to use it blows up ugly. Viz.: (sorry for lousy formatting, I'm pasting this in straight from ipad)

Maybe I'll try importing everything individually...

=> (print "hello hy!")
Traceback (most recent call last):
File "/private/var/mobile/Containers/Shared/AppGroup/3CA811DC-91BC-4964-9CFE-81FFABD1596F/Documents/site-packages/hy/hy/compiler.py", line 2304, in hy_compile
compiler = HyASTCompiler(module_name)
File "/private/var/mobile/Containers/Shared/AppGroup/3CA811DC-91BC-4964-9CFE-81FFABD1596F/Documents/site-packages/hy/hy/compiler.py", line 378, in init
load_stdlib()
File "/private/var/mobile/Containers/Shared/AppGroup/3CA811DC-91BC-4964-9CFE-81FFABD1596F/Documents/site-packages/hy/hy/compiler.py", line 73, in load_stdlib
mod = importlib.import_module(module)
File "/var/mobile/Containers/Bundle/Application/575025AB-2EF8-4348-BA3E-A7FBA91E5011/Pythonista.app/Frameworks/PythonistaKit.framework/pylib/importlib/init.py", line 38, in import_module
import(name)
File "/private/var/mobile/Containers/Shared/AppGroup/3CA811DC-91BC-4964-9CFE-81FFABD1596F/Documents/site-packages/hy/hy/importer.py", line 180, in load_module
self.path)
File "/private/var/mobile/Containers/Shared/AppGroup/3CA811DC-91BC-4964-9CFE-81FFABD1596F/Documents/site-packages/hy/hy/importer.py", line 75, in import_file_to_module
_ast = import_file_to_ast(fpath, module_name)
File "/private/var/mobile/Containers/Shared/AppGroup/3CA811DC-91BC-4964-9CFE-81FFABD1596F/Documents/site-packages/hy/hy/importer.py", line 67, in import_file_to_ast
return hy_compile(import_file_to_hst(fpath), module_name)
File "/private/var/mobile/Containers/Shared/AppGroup/3CA811DC-91BC-4964-9CFE-81FFABD1596F/Documents/site-packages/hy/compiler.py", line 2305, in hy_compile
result = compiler.compile(tree)
File "/private/var/mobile/Containers/Shared/AppGroup/3CA811DC-91BC-4964-9CFE-81FFABD1596F/Documents/site-packages/hy/compiler.py", line 428, in compile
ret = self.compile_atom(_type, tree)
File "/private/var/mobile/Containers/Shared/AppGroup/3CA811DC-91BC-4964-9CFE-81FFABD1596F/Documents/site-packages/hy/compiler.py", line 420, in compile_atom
ret = _compile_table[atom_type](self, atom)
File "/private/var/mobile/Containers/Shared/AppGroup/3CA811DC-91BC-4964-9CFE-81FFABD1596F/Documents/site-packages/hy/compiler.py", line 596, in compile_raw_list
ret = self._compile_branch(entries)
File "/private/var/mobile/Containers/Shared/AppGroup/3CA811DC-91BC-4964-9CFE-81FFABD1596F/Documents/site-packages/hy/compiler.py", line 483, in _compile_branch
return _branch(self.compile(expr) for expr in exprs)
File "/private/var/mobile/Containers/Shared/AppGroup/3CA811DC-91BC-4964-9CFE-81FFABD1596F/Documents/site-packages/hy/compiler.py", line 313, in _branch
results = list(results)
File "/private/var/mobile/Containers/Shared/AppGroup/3CA811DC-91BC-4964-9CFE-81FFABD1596F/Documents/site-packages/hy/compiler.py", line 483, in
return _branch(self.compile(expr) for expr in exprs)
File "/private/var/mobile/Containers/Shared/AppGroup/3CA811DC-91BC-4964-9CFE-81FFABD1596F/Documents/site-packages/hy/compiler.py", line 442, in compile
raise HyCompileError(Exception("Unknown type: %s'" % _type)) HyCompileError: Internal Compiler Bug 😱 ⤷ Exception: Unknown type:<class 'hy.models.expression.HyExpression'>'
Compilation traceback:
No traceback available. 😟
=>

@zackmdavis
Copy link
Contributor

works on Android using Termux

hy_on_android

@Kodiologist Kodiologist changed the title Add other Python implementations (like IronPython and Jython) to tox or docs Add support for other Python implementations Apr 18, 2022
@Kodiologist
Copy link
Member

RPython may have worked at one point (#29) but probably doesn't now (#780). At any rate, we can't really say we support an implementation that we're not testing on, so for the time being, we support CPython, PyPy, and nothing else.

@Kodiologist
Copy link
Member

Most interesting to me personally would be support for Pyodide, a WebAssembly-based Python, so you could run Hy in a web browser without having to go through JavaScript, as with Brython.

@Kodiologist
Copy link
Member

Pyodide is in as of #2388.

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

No branches or pull requests

6 participants