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

Support the Windows "embeddable zip file" releases of Python #1856

Closed
dev-namespace opened this issue Dec 24, 2019 · 14 comments
Closed

Support the Windows "embeddable zip file" releases of Python #1856

dev-namespace opened this issue Dec 24, 2019 · 14 comments
Labels

Comments

@dev-namespace
Copy link

dev-namespace commented Dec 24, 2019

Hy fails to find hy modules when used in an embedded Python version.

given two files main.py and foo.hy

import hy
import foo

ModuleNotFoundError: No module named foo

Any chance support for this or pyinstaller can be added so we can create stand-alone Hy programs?

@Kodiologist
Copy link
Member

Which embedded Python version?

@dev-namespace
Copy link
Author

Python 3.8.1 - Dec. 18, 2019

  • Embeddable zip file
    here

@Kodiologist
Copy link
Member

Huh, I didn't know that was a thing.

In answer to your question, it's a valid feature request, but don't hold your breath, since generally we haven't put too much effort into Windows support. Personally, I do all my programming on Linux.

@Kodiologist Kodiologist changed the title Support Hy in embedded Python Support the Windows "embedded zip file" releases of Python Dec 24, 2019
@Kodiologist Kodiologist changed the title Support the Windows "embedded zip file" releases of Python Support the Windows "embeddable zip file" releases of Python Dec 24, 2019
@dev-namespace
Copy link
Author

Yeah I'm a Linux user too but I need to distribute to Windows machines and I can't expect all users to have Python installed.

Anyway thanks for accepting the feature request and merry Christmas ;)

@Kodiologist
Copy link
Member

I've escalated this issue from "feature" to "bug" because we officially support Windows now and this is an official release of CPython.

@rujialiu
Copy link

I've escalated this issue from "feature" to "bug" because we officially support Windows now and this is an official release of CPython.

I've just come across hylang a few days ago and am very much interested in it. Since I regularly develop on Windows, I thought maybe I can contribute some Windows-specific stuffs to make Hy 1.0 come earlier so I picked up this issue.

However, after trying CPython 3.10.4 embedded zip on Windows 10, it works as expected.

foo.hy:

(print "1")

main.py:

import hy
import foo

result:

D:\embedpy>python main.py
1

Is this bug fixed (and forgot to close this issue)?

BTW: Although people have succeeded installing pip with embedded python, I've copied hy's source codes along with its dependencies (currently only four: funcparserlib, colorama, rply and appdirs), directly in embedded python's directory because embedded python doesn't bundle pip.

@Kodiologist
Copy link
Member

Nobody fixed this bug intentionally, but it might've been fixed as a side-effect of other changes. We should probably add a test before closing it. The test can be as simple as downloading the embedded release and getting hy -c '(2 + 2)' to run on it; I don't think we need to run the whole test suite with the embedded release in addition to the run on standard CPython for Windows.

@rujialiu
Copy link

Yes, no need to run the whole test suite, but since in the original post import hy didn't throw an exception, I assumed some basic features actually worked. So maybe a slightly more complex test suite (at least involving a module with .hy suffix) is needed?

@Kodiologist
Copy link
Member

That's a good point. Yes, since the issue was importing a stub Hy module, let's test that. I would say, first, see if you can reproduce the bug with Hy 0.18.0, since I don't think anybody ever checked that. If you can reproduce it, write a failing test and then port it to Hy master and check that it passes.

@rujialiu
Copy link

I tried Hy 0.18.0 with embedded Python. It doesn't work, but with a different error.
It looks like the error is actually "broader" than importing Hy module because hy.read_str + hy.eval gives the same error.

Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)] on win32
>>> import hy
>>> hy.eval(hy.read_str('(+ 1 1)'))
Traceback (most recent call last):
  File "D:\dev\embedpy2\hy\compiler.py", line 1684, in compile_eval_and_compile
    hy_eval(new_expr + body,
  File "D:\dev\embedpy2\hy\compiler.py", line 2094, in hy_eval
    eval(ast_compile(_ast, filename, "exec"),
  File "D:\dev\embedpy2\hy\compiler.py", line 64, in ast_compile
    return compile(ast, filename, mode, hy_ast_compile_flags)
TypeError: required field "lineno" missing from alias

During handling of the above exception, another exception occurred:

And I can confirm the latest Hy doesn't have this error. Unfortunately, I'm not familiar with changing github workflow files (you wanted me to change tests.yml?)

@Kodiologist
Copy link
Member

Hy 0.18.0 is too old to support Python 3.10, embedded or not. As a sanity check, be sure that your test passed on the same version of Hy with the standard Python with the same version number.

you wanted me to change tests.yml?

No, it should be enough to add a test with a pytest.mark.skipif that checks you're on Windows.

@rujialiu
Copy link

Now I'm using embedded Python 3.8.1, exactly the version used by OP. It works...

Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] on win32
>>> import hy
>>> import foo
1
>>> hy.eval(hy.read_str('(+ 1 1)'))
2

What should I do now? Is it possible that OP installed Hy and dependencies in a different way (e.g. with pip, which is not officially supported I think) or some other library conflicts with Hy?

@Kodiologist
Copy link
Member

We conclude that we can't reproduce the bug, so we close the issue, and reopen it if it ever comes up again. Let this be a reminder to me to check that I can reproduce an issue before marking it as a bug. Thanks for looking into this.

@rujialiu
Copy link

You're welcome :)

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

3 participants