Description
(All snippets below tested with hy master and python 3.6.3)
When running a directory with a __main__
file, hy fails while python succeeds:
% ls
__main__.hy __main__.py
% python .
hey
% hy .
hy: Can't open file '.': [Errno 21] Is a directory
Same applies to egg files, but that may be its own independent problem.
Passing the -m
flag does execute the __main__
, unlike python:
% hy -m .
hy
% python -m .
python: Relative module names not supported
Fixing the first block is relatively simple: In cmdline
, run_module
already does the correct thing when running a directory/file according to the respective function in cpython.
However, making the 2nd block fail is a breaking change, as run_module
does not do the same thing as the respective function in cpython (wraps runpy._run_module_as_main
)
In the end, the question may be is this worth fixing on a lower level? Does hy want to copy the behaviour of run_file
and run_module
as implemented in cpython, or is it good enough to be able to run a directory/zip/whatever with a __main__
?