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

Hyrule isn't using bytecode files #42

Closed
shadowrylander opened this issue May 9, 2022 · 42 comments · Fixed by hylang/hy#2299 or #46
Closed

Hyrule isn't using bytecode files #42

shadowrylander opened this issue May 9, 2022 · 42 comments · Fixed by hylang/hy#2299 or #46
Labels
bug Something isn't working

Comments

@shadowrylander
Copy link

Hello!

As in the title; I tried using the master versions as well, and the issue persists. Removing hyrule imports and requires from my module, while keeping all other modules, sped up the import of my module.

Sorry if this isn't the place for this, as I don't know whether this counts as a bug or not.

Thank you kindly for the help!

@Kodiologist
Copy link
Member

Is it byte-compiled? Are you loading the bytecode instead of recompiling the source every time?

@shadowrylander
Copy link
Author

How do I check if it is?

@Kodiologist
Copy link
Member

Check the __pycache__ folder corresponding to where you installed the package.

@shadowrylander
Copy link
Author

Well __pycache__ exists, as does __init__.pyc inside, but how can I check if hy is using it?

@Kodiologist
Copy link
Member

What about bytecode for the individual source files, such as __pycache__/destructure.cpython-39.pyc?

@shadowrylander
Copy link
Author

So this is what I have in the directory:

total 54
dr-xr-xr-x 2 root root    14 Jan  1  1970 .
dr-xr-xr-x 3 root root    15 Jan  1  1970 ..
-r--r--r-- 1 root root 12306 Jan  1  1970 anaphoric.cpython-310.pyc
-r--r--r-- 1 root root  5492 Jan  1  1970 argmove.cpython-310.pyc
-r--r--r-- 1 root root 12614 Jan  1  1970 collections.cpython-310.pyc
-r--r--r-- 1 root root 10999 Jan  1  1970 control.cpython-310.pyc
-r--r--r-- 1 root root 18591 Jan  1  1970 destructure.cpython-310.pyc
-r--r--r-- 1 root root 11381 Jan  1  1970 hypprint.cpython-310.pyc
-r--r--r-- 1 root root   786 Jan  1  1970 hy_init.cpython-310.pyc
-r--r--r-- 1 root root  3819 Jan  1  1970 iterables.cpython-310.pyc
-r--r--r-- 1 root root  6447 Jan  1  1970 macrotools.cpython-310.pyc
-r--r--r-- 1 root root  9997 Jan  1  1970 misc.cpython-310.pyc
-r--r--r-- 1 root root  5091 Jan  1  1970 sequences.cpython-310.pyc
-r--r--r-- 1 root root   364 Jan  1  1970 __init__.cpython-310.pyc

@Kodiologist
Copy link
Member

The dates modified are bogus and root doesn't have write permissions on its own files, which is odd, but neither should really be the problem here. I think I'm going to add a Hy feature to peek at bytecode usage (which has historically been a difficult thing to debug) and get back to you.

@shadowrylander
Copy link
Author

Hah! Yeah, those dates are ridiculous. I'm using nixos, and this is from a custom environment. Every other module seems to work fine, though, interestingly enough.

@scauligi
Copy link
Member

To me that smells like Hy considering the .pyc files out of date and recompiling hyrule every time (but not being able to actually update/overwrite with the compiled files). My hunch is that if you can fix the permissions and modifydate weirdness then it should start working again.

@Kodiologist
Copy link
Member

Yes, belatedly, I would add that a quick thing you can try is to touch the bytecode. Bytecode that doesn't have a later modification date than the corresponding source files may be ignored.

@shadowrylander
Copy link
Author

Ah; should I touch all of them? Also, it's there a way to generate the bytecode before I import the module for the first time? That way I can have the install instructions generate them with the correct dates and times.

@Kodiologist
Copy link
Member

should I touch all of them?

Yes. touch * should do it.

Also, it's there a way to generate the bytecode before I import the module for the first time?

One thing at a time. Let's see if we can figure out your slowdown problem first.

@shadowrylander
Copy link
Author

Right, right; I'll get right on it.

@shadowrylander
Copy link
Author

Nope; didn't seem to fix it. I touched all the files, updated their timestamps, and tried again with the hyrule imports enabled, but they lagged by a second or so.

@Kodiologist
Copy link
Member

Okay, try updating Hy and Hyrule and then running your program with HY_MESSAGE_WHEN_COMPILING=1. That will show you whether Hyrule is being recompiled each run.

@shadowrylander
Copy link
Author

shadowrylander commented May 31, 2022

Er, quick error with the master branches of hy and hyrule:

Check whether the following modules can be imported: hyrule
Traceback (most recent call last):
  File "/nix/store/w25s9scimsmw0d0pz84i53rbx5309z85-python3.10-funcparserlib-1.0.0a0/lib/python3.10/site-packages/funcparserlib/parser.py", line 217, in parse
    (tree, _) = self.run(tokens, State(0, 0, None))
  File "/nix/store/w25s9scimsmw0d0pz84i53rbx5309z85-python3.10-funcparserlib-1.0.0a0/lib/python3.10/site-packages/funcparserlib/parser.py", line 377, in _shift
    (v, s2) = self.run(tokens, s)
  File "/nix/store/w25s9scimsmw0d0pz84i53rbx5309z85-python3.10-funcparserlib-1.0.0a0/lib/python3.10/site-packages/funcparserlib/parser.py", line 301, in _add
    (v2, s3) = other.run(tokens, s2)
  File "/nix/store/w25s9scimsmw0d0pz84i53rbx5309z85-python3.10-funcparserlib-1.0.0a0/lib/python3.10/site-packages/funcparserlib/parser.py", line 524, in finished
    raise NoParseError("got unexpected token", s2)
funcparserlib.parser.NoParseError: got unexpected token

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/nix/store/fb2a2cjyqj3kpwwgnwllmbrl2dr5dnnr-python3.10-hy-1.0a4/lib/python3.10/site-packages/hy/macros.py", line 58, in require
    parse_tree = pattern.parse(args)
  File "/nix/store/w25s9scimsmw0d0pz84i53rbx5309z85-python3.10-funcparserlib-1.0.0a0/lib/python3.10/site-packages/funcparserlib/parser.py", line 239, in parse
    raise NoParseError(msg, e.state)
funcparserlib.parser.NoParseError: got unexpected token: :readers, expected: end of file

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<string>", line 1, in <lambda>
  File "/nix/store/40n9pd613v8fc3x39yjrgs1i7d4q8yl0-python3-3.10.4/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/nix/store/cbm3rkxn7viml7cv00phlasmmrmh0mmb-python3.10-hyrule-0.1/lib/python3.10/site-packages/hyrule/__init__.py", line 7, in <module>
    hy.macros.require('hyrule.hy_init',
  File "/nix/store/fb2a2cjyqj3kpwwgnwllmbrl2dr5dnnr-python3.10-hy-1.0a4/lib/python3.10/site-packages/hy/macros.py", line 168, in require
    source_module = importlib.import_module(source_module, package)
  File "/nix/store/40n9pd613v8fc3x39yjrgs1i7d4q8yl0-python3-3.10.4/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 879, in exec_module
  File "<frozen importlib._bootstrap_external>", line 1017, in get_code
  File "/nix/store/fb2a2cjyqj3kpwwgnwllmbrl2dr5dnnr-python3.10-hy-1.0a4/lib/python3.10/site-packages/hy/importer.py", line 121, in _hy_source_to_code
    data = hy_compile(hy_tree, module)
  File "/nix/store/fb2a2cjyqj3kpwwgnwllmbrl2dr5dnnr-python3.10-hy-1.0a4/lib/python3.10/site-packages/hy/compiler.py", line 814, in hy_compile
    result = compiler.compile(tree)
  File "/nix/store/fb2a2cjyqj3kpwwgnwllmbrl2dr5dnnr-python3.10-hy-1.0a4/lib/python3.10/site-packages/hy/compiler.py", line 351, in compile
    raise e
  File "/nix/store/fb2a2cjyqj3kpwwgnwllmbrl2dr5dnnr-python3.10-hy-1.0a4/lib/python3.10/site-packages/hy/compiler.py", line 342, in compile
    ret = self.compile_atom(tree)
  File "/nix/store/fb2a2cjyqj3kpwwgnwllmbrl2dr5dnnr-python3.10-hy-1.0a4/lib/python3.10/site-packages/hy/compiler.py", line 336, in compile_atom
    return Result() + _model_compilers[type(atom)](self, atom)
  File "/nix/store/fb2a2cjyqj3kpwwgnwllmbrl2dr5dnnr-python3.10-hy-1.0a4/lib/python3.10/site-packages/hy/compiler.py", line 476, in compile_expression
    expr = macroexpand(expr, self.module, self)
  File "/nix/store/fb2a2cjyqj3kpwwgnwllmbrl2dr5dnnr-python3.10-hy-1.0a4/lib/python3.10/site-packages/hy/macros.py", line 322, in macroexpand
    obj = m(compiler, *tree[1:])
  File "/nix/store/fb2a2cjyqj3kpwwgnwllmbrl2dr5dnnr-python3.10-hy-1.0a4/lib/python3.10/site-packages/hy/macros.py", line 64, in do
    return fn(hy_compiler, expr, root, *parse_tree)
  File "/nix/store/fb2a2cjyqj3kpwwgnwllmbrl2dr5dnnr-python3.10-hy-1.0a4/lib/python3.10/site-packages/hy/core/result_macros.py", line 48, in compile_do
    return self._compile_branch(body)
  File "/nix/store/fb2a2cjyqj3kpwwgnwllmbrl2dr5dnnr-python3.10-hy-1.0a4/lib/python3.10/site-packages/hy/compiler.py", line 423, in _compile_branch
    for x in map(self.compile, exprs[:-1]):
  File "/nix/store/fb2a2cjyqj3kpwwgnwllmbrl2dr5dnnr-python3.10-hy-1.0a4/lib/python3.10/site-packages/hy/compiler.py", line 351, in compile
    raise e
  File "/nix/store/fb2a2cjyqj3kpwwgnwllmbrl2dr5dnnr-python3.10-hy-1.0a4/lib/python3.10/site-packages/hy/compiler.py", line 342, in compile
    ret = self.compile_atom(tree)
  File "/nix/store/fb2a2cjyqj3kpwwgnwllmbrl2dr5dnnr-python3.10-hy-1.0a4/lib/python3.10/site-packages/hy/compiler.py", line 336, in compile_atom
    return Result() + _model_compilers[type(atom)](self, atom)
  File "/nix/store/fb2a2cjyqj3kpwwgnwllmbrl2dr5dnnr-python3.10-hy-1.0a4/lib/python3.10/site-packages/hy/compiler.py", line 476, in compile_expression
    expr = macroexpand(expr, self.module, self)
  File "/nix/store/fb2a2cjyqj3kpwwgnwllmbrl2dr5dnnr-python3.10-hy-1.0a4/lib/python3.10/site-packages/hy/macros.py", line 322, in macroexpand
    obj = m(compiler, *tree[1:])
  File "/nix/store/fb2a2cjyqj3kpwwgnwllmbrl2dr5dnnr-python3.10-hy-1.0a4/lib/python3.10/site-packages/hy/macros.py", line 60, in require
    raise hy_compiler._syntax_error(
  File "/nix/store/cbm3rkxn7viml7cv00phlasmmrmh0mmb-python3.10-hyrule-0.1/lib/python3.10/site-packages/hyrule/hy_init.hy", line 2
    hyrule.anaphoric * :readers *
                       ^
hy.errors.HySyntaxError: parse error for pattern macro 'require': got unexpected token: :readers, expected: end of file
error: builder for '/nix/store/2gzb002gdnf44c2dlcmb0znniq56lxxg-python3.10-hyrule-0.1.drv' failed with exit code 1;
       last 10 log lines:
       >   File "/nix/store/fb2a2cjyqj3kpwwgnwllmbrl2dr5dnnr-python3.10-hy-1.0a4/lib/python3.10/site-packages/hy/compiler.py", line 476, in compile_expression
       >     expr = macroexpand(expr, self.module, self)
       >   File "/nix/store/fb2a2cjyqj3kpwwgnwllmbrl2dr5dnnr-python3.10-hy-1.0a4/lib/python3.10/site-packages/hy/macros.py", line 322, in macroexpand
       >     obj = m(compiler, *tree[1:])
       >   File "/nix/store/fb2a2cjyqj3kpwwgnwllmbrl2dr5dnnr-python3.10-hy-1.0a4/lib/python3.10/site-packages/hy/macros.py", line 60, in require
       >     raise hy_compiler._syntax_error(
       >   File "/nix/store/cbm3rkxn7viml7cv00phlasmmrmh0mmb-python3.10-hyrule-0.1/lib/python3.10/site-packages/hyrule/hy_init.hy", line 2
       >     hyrule.anaphoric * :readers *
       >                        ^
       > hy.errors.HySyntaxError: parse error for pattern macro 'require': got unexpected token: :readers, expected: end of file
       For full logs, run 'nix log /nix/store/2gzb002gdnf44c2dlcmb0znniq56lxxg-python3.10-hyrule-0.1.drv'.
error: build of '/nix/store/2gzb002gdnf44c2dlcmb0znniq56lxxg-python3.10-hyrule-0.1.drv', '/nix/store/4rcbacjv8pv5wf81yvpfjan9cai08aig-python3.10-hy-1.0a4.drv' failed

@shadowrylander
Copy link
Author

Wait, no, sorry; my fault.

@shadowrylander
Copy link
Author

@Kodiologist: Actually, since I'm using the master branch for these tests, how do decorators work now? I saw your comment, but I still don't quite understand it.

@Kodiologist
Copy link
Member

https://docs.hylang.org/en/master/api.html#defn

@shadowrylander
Copy link
Author

And how do you define a tuple, now, as opposed to the previous (, ...)?

@Kodiologist
Copy link
Member

https://github.com/hylang/hy/blob/master/NEWS.rst

@shadowrylander
Copy link
Author

Alright; here's the final result:

oreo on  main [!] is 📦 v1.0.0.0 via 🐍 v3.11.0a4 via ❄️  impure (nix-shell) took 7s 
❯ HY_MESSAGE_WHEN_COMPILING=1 hy tests.hy
Compiling /nix/store/fhf82rjsj233xid5qghqm2sr5jxmxwqs-python3.10-hy-1.0a4/lib/python3.10/site-packages/hy/core/macros.hy
Compiling /home/shadowrylander/shadowrylander/sylveon/oreo/tests.hy
Compiling /nix/store/gdgy0y206s083zdh6gwkm8kb5hs923jj-python3.10-hyrule-0.1/lib/python3.10/site-packages/hyrule/hy_init.hy
Compiling /nix/store/gdgy0y206s083zdh6gwkm8kb5hs923jj-python3.10-hyrule-0.1/lib/python3.10/site-packages/hyrule/anaphoric.hy
Compiling /nix/store/gdgy0y206s083zdh6gwkm8kb5hs923jj-python3.10-hyrule-0.1/lib/python3.10/site-packages/hyrule/macrotools.hy
Compiling /nix/store/gdgy0y206s083zdh6gwkm8kb5hs923jj-python3.10-hyrule-0.1/lib/python3.10/site-packages/hyrule/iterables.hy
Compiling /nix/store/gdgy0y206s083zdh6gwkm8kb5hs923jj-python3.10-hyrule-0.1/lib/python3.10/site-packages/hyrule/collections.hy
Compiling /nix/store/gdgy0y206s083zdh6gwkm8kb5hs923jj-python3.10-hyrule-0.1/lib/python3.10/site-packages/hyrule/argmove.hy
Compiling /nix/store/gdgy0y206s083zdh6gwkm8kb5hs923jj-python3.10-hyrule-0.1/lib/python3.10/site-packages/hyrule/control.hy
Compiling /nix/store/gdgy0y206s083zdh6gwkm8kb5hs923jj-python3.10-hyrule-0.1/lib/python3.10/site-packages/hyrule/misc.hy
Compiling /nix/store/gdgy0y206s083zdh6gwkm8kb5hs923jj-python3.10-hyrule-0.1/lib/python3.10/site-packages/hyrule/destructure.hy
Compiling /nix/store/fhf82rjsj233xid5qghqm2sr5jxmxwqs-python3.10-hy-1.0a4/lib/python3.10/site-packages/hy/pyops.hy
Compiling /nix/store/gdgy0y206s083zdh6gwkm8kb5hs923jj-python3.10-hyrule-0.1/lib/python3.10/site-packages/hyrule/sequences.hy
Compiling /nix/store/gdgy0y206s083zdh6gwkm8kb5hs923jj-python3.10-hyrule-0.1/lib/python3.10/site-packages/hyrule/hypprint.hy
Compiling /nix/store/fhf82rjsj233xid5qghqm2sr5jxmxwqs-python3.10-hy-1.0a4/lib/python3.10/site-packages/hy/core/hy_repr.hy
tests                                ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
69611341-cf92-48bb-8cda-79c7fe28d9f2 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00%                                                                                                               

oreo on  main [!] is 📦 v1.0.0.0 via 🐍 v3.11.0a4 via ❄️  impure (nix-shell) took 5s 
❯ HY_MESSAGE_WHEN_COMPILING=1 hy tests.hy
Compiling /nix/store/fhf82rjsj233xid5qghqm2sr5jxmxwqs-python3.10-hy-1.0a4/lib/python3.10/site-packages/hy/core/macros.hy
Compiling /nix/store/gdgy0y206s083zdh6gwkm8kb5hs923jj-python3.10-hyrule-0.1/lib/python3.10/site-packages/hyrule/hy_init.hy
Compiling /nix/store/gdgy0y206s083zdh6gwkm8kb5hs923jj-python3.10-hyrule-0.1/lib/python3.10/site-packages/hyrule/anaphoric.hy
Compiling /nix/store/gdgy0y206s083zdh6gwkm8kb5hs923jj-python3.10-hyrule-0.1/lib/python3.10/site-packages/hyrule/macrotools.hy
Compiling /nix/store/gdgy0y206s083zdh6gwkm8kb5hs923jj-python3.10-hyrule-0.1/lib/python3.10/site-packages/hyrule/iterables.hy
Compiling /nix/store/gdgy0y206s083zdh6gwkm8kb5hs923jj-python3.10-hyrule-0.1/lib/python3.10/site-packages/hyrule/collections.hy
Compiling /nix/store/gdgy0y206s083zdh6gwkm8kb5hs923jj-python3.10-hyrule-0.1/lib/python3.10/site-packages/hyrule/argmove.hy
Compiling /nix/store/gdgy0y206s083zdh6gwkm8kb5hs923jj-python3.10-hyrule-0.1/lib/python3.10/site-packages/hyrule/control.hy
Compiling /nix/store/gdgy0y206s083zdh6gwkm8kb5hs923jj-python3.10-hyrule-0.1/lib/python3.10/site-packages/hyrule/misc.hy
Compiling /nix/store/gdgy0y206s083zdh6gwkm8kb5hs923jj-python3.10-hyrule-0.1/lib/python3.10/site-packages/hyrule/destructure.hy
Compiling /nix/store/fhf82rjsj233xid5qghqm2sr5jxmxwqs-python3.10-hy-1.0a4/lib/python3.10/site-packages/hy/pyops.hy
Compiling /nix/store/gdgy0y206s083zdh6gwkm8kb5hs923jj-python3.10-hyrule-0.1/lib/python3.10/site-packages/hyrule/sequences.hy
Compiling /nix/store/gdgy0y206s083zdh6gwkm8kb5hs923jj-python3.10-hyrule-0.1/lib/python3.10/site-packages/hyrule/hypprint.hy
Compiling /nix/store/fhf82rjsj233xid5qghqm2sr5jxmxwqs-python3.10-hy-1.0a4/lib/python3.10/site-packages/hy/core/hy_repr.hy
tests                                ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
69611341-cf92-48bb-8cda-79c7fe28d9f2 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00%                                                                                                               

oreo on  main [!] is 📦 v1.0.0.0 via 🐍 v3.11.0a4 via ❄️  impure (nix-shell) took 5s 
❯

@Kodiologist
Copy link
Member

Yeah, so it's as I guessed, the bytecode isn't being installed or isn't being read. I can replicate it on my machine. Hy has the same problem, so, no big surprise, I guess.

@Kodiologist Kodiologist changed the title Importing and Requiring from Hyrule is 1 - 2 seconds slower than other modules Hyrule isn't using bytecode files May 31, 2022
@Kodiologist Kodiologist added the bug Something isn't working label May 31, 2022
@shadowrylander
Copy link
Author

Makes sense; is it an OS issue, or a hy[rule] issue?

@Kodiologist
Copy link
Member

I think it's an issue on our end of how the installation works. We need to get setup.py to build and install the bytecode in both Hy and Hyrule. I used to have some code in Hy's setup.py that was supposed to do this, but it didn't work.

@shadowrylander
Copy link
Author

Ah; that's unfortunate. If you would like me to run any more tests, just let me know; nix makes it very easy! 😹

@scauligi
Copy link
Member

scauligi commented Jun 1, 2022

Doing some initial digging into this as part of a larger project revamping Hy's import system;
turns out the structure of *.pyc files is to keep a timestamp in the pyc data itself, which must match the mtime of the corresponding source exactly (i.e. source files both in the past and the future will invalidate the pyc data).

Potential solutions:

  1. Get the timestamp in the *.pyc files to match whatever the mtime of the source files ends up as (such as for the nix environment)
  2. Update the mtime of the source files to match the timestamp contained inside the *.pyc files (e.g. the latest distribution of hyrule has pyc files containing timestamps around 2022-05-20 09:36:27)
  3. Distribute hash-based *.pyc files instead of timestamp-based *.pyc files. These were introduced into python to help support reproducible builds; the downside is python will be reading and hashing the source files every time which is a little slower than just checking timestamps (although our source files are relatively small).

I can look into the first two to see if there's an easy way to do either of those in the setup.py process.

@Kodiologist
Copy link
Member

We already have reading and writing bytecode working in common cases, including the management of the timestamp stored in the bytecode, because we're letting Python's import system handle it. Are you sure mismatching timestamps is the problem here?

@scauligi
Copy link
Member

scauligi commented Jun 1, 2022

In the nix environment, it is, since the source files all have timestamps reset to 1970. When python tries to load the pyc, it sees the mismatch between the timestamp in the pyc data and the mtime of the source, so it reloads the file (triggering recompilation).

@Kodiologist
Copy link
Member

I see. Well, one can reproduce the problem in Ubuntu, and presumably other conventional Unices, so let's focus on that first. Then maybe NixOS's package manager can deal with its own problems.

@scauligi
Copy link
Member

scauligi commented Jun 1, 2022

Do you have reproduction steps for Ubuntu? I can't reproduce this using virtualenvs

@Kodiologist
Copy link
Member

I can't reproduce it in a virtualenv, either, only for system-wide installation. Presumably this is because of permissions: my normal user account can't save a bytecode file to the system-wide Python directory.

@shadowrylander
Copy link
Author

With the master branches for both hy and hyrule, I'm still having the same problem, though I believe that's because Hyrule has not been updated to use the current version of hy yet, correct?

@Kodiologist
Copy link
Member

Oh shoot, I didn't mean to close this. Sunjay used the magic word "fix" that triggered a closure. I didn't even know that worked cross-repository.

I'm still having the same problem, though I believe that's because Hyrule has not been updated to use the current version of hy yet, correct?

No, it's because no changes have been made to Hyrule to make it precompile and install its own bytecode.

@Kodiologist Kodiologist reopened this Jun 7, 2022
@shadowrylander
Copy link
Author

Hah! Fair enough.

I guess I'll wait for the update, then.

@scauligi
Copy link
Member

@shadowrylander if you have some time before we bake the new changes into 1.0a5 (or 0.21.0?), can you confirm that the combination of hylang/hy#2309 and #46 work in your nix setup?

@shadowrylander
Copy link
Author

Will do; I'll report back in a bit!

@shadowrylander
Copy link
Author

shadowrylander commented Jun 20, 2022

Okay, while I can disable the following test, is there any way to fix it?

==================================== ERRORS ====================================
____________________ ERROR collecting tests/test_slicing.hy ____________________
ImportError while importing test module '/tmp/nix-build-python3.10-hyrule-0.1.drv-0/source/tests/test_slicing.hy'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/nix/store/zgv6h355ssr2dxydxx4hiagn2sdx9356-python3-3.10.4/lib/python3.10/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_slicing.hy:3: in <module>
    (import
E   ModuleNotFoundError: No module named 'hy.lex'
=========================== short test summary info ============================
ERROR tests/test_slicing.hy
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 3.73s ===============================
error: builder for '/nix/store/prb2rybzrn6gwkvblkjb7vkrccdpzsc2-python3.10-hyrule-0.1.drv' failed with exit code 2;
       last 10 log lines:
       > Traceback:
       > /nix/store/zgv6h355ssr2dxydxx4hiagn2sdx9356-python3-3.10.4/lib/python3.10/importlib/__init__.py:126: in import_module
       >     return _bootstrap._gcd_import(name[level:], package, level)
       > tests/test_slicing.hy:3: in <module>
       >     (import
       > E   ModuleNotFoundError: No module named 'hy.lex'
       > =========================== short test summary info ============================
       > ERROR tests/test_slicing.hy
       > !!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
       > =============================== 1 error in 3.73s ===============================
       For full logs, run 'nix log /nix/store/prb2rybzrn6gwkvblkjb7vkrccdpzsc2-python3.10-hyrule-0.1.drv'.
error: 1 dependencies of derivation '/nix/store/0y5dnicnv389yz061izb5dv3rh47xn8w-python3.10-oreo-1.0.0.0.drv' failed to build

Otherwise, @scauligi, it works! In case you use nix as well, I am pasting the shell.nix file below, with the hy[rule] master and your branch:

with builtins; let
    pkgs = import (fetchGit { url = "https://github.com/shadowrylander/nixpkgs"; ref = "j"; }) {};
    hy = pkgs.python310Packages.hy.overridePythonAttrs (prev: {
      src = fetchGit { url = "https://github.com/scauligi/hy"; ref = "the_wheel_deal"; };
      # src = fetchGit { url = "https://github.com/hylang/hy"; ref = "master"; };
      postPatch = ''substituteInPlace setup.py --replace "\"funcparserlib ~= 1.0\"," ""'';
      disabledTests = [ "test_bin" "test_hy2py" ];
    });
    hyrule = pkgs.python310Packages.hyrule.overridePythonAttrs (prev: {
      src = fetchGit { url = "https://github.com/scauligi/hyrule"; ref = "precompile_hy"; };
      # src = fetchGit { url = "https://github.com/hylang/hyrule"; ref = "master"; };
      postPatch = ''substituteInPlace setup.py --replace "'hy @ git+https://github.com/scauligi/hy@the_wheel_deal#egg=hy'," ""'';
      propagatedBuildInputs = [ hy ];
      disabledTestPaths = [ "tests/test_slicing.hy" ];
    });
in with pkgs; mkShell {
    buildInputs = with python310Packages; [ (oreo.overridePythonAttrs (prev: {
        src = ./.;
        propagatedBuildInputs = (filter (p: ! elem p.pname [ "hy" "hyrule" ]) prev.propagatedBuildInputs) ++ [ hy hyrule ];
    })) ];
    # shellHook = "hy tests.hy; exit";
}

@scauligi
Copy link
Member

ModuleNotFoundError: No module named 'hy.lex'

Ah, one of the recent commits on master renamed hy.lex to hy.reader. You might need to clean some stale __pycache__ files?

it works!

Heck yeah!

I am pasting the shell.nix file below, with the hy[rule] master and your branch

Awesome, thanks! I'm still a nix noob so this helps a ton.

@shadowrylander
Copy link
Author

Ah; might need to collect the nix garbage, then. 😹 And if you ever need help with nix, don't hesitate to ask! I'm still learning as well, but I'll be glad to help! Thanks again to the both of you, @scauligi and @Kodiologist! Should I choose this issue now, or when both hy and hyrule are updated?

@scauligi
Copy link
Member

No prob! And no need to do anything with the issue, github should close it automatically once the PRs land.

@shadowrylander
Copy link
Author

Got it; thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants