aappleby / hancho

A simple pleasant build system in Python.
MIT License
359 stars 10 forks source link

Config property `repo_path` evaluated inconsistently #8

Open claui opened 1 month ago

claui commented 1 month ago

When I try to run the hello_gtk example on its own, I get:

# From Hancho’s root directory
$ python hancho.py -f hello_gtk.hancho -C examples/hello_gtk
Loading module /build/hancho/src/hancho-0.2.0/examples/hello_gtk/hello_gtk.hancho
Loading module /build/hancho/src/hancho-0.2.0/examples/hello_gtk/rules.hancho
Traceback (most recent call last):
  File "/build/hancho/src/hancho-0.2.0/hancho.py", line 1530, in <module>
    sys.exit(app.main())
             ^^^^^^^^^^
  File "/build/hancho/src/hancho-0.2.0/hancho.py", line 1238, in main
    self.load_hanchos()
  File "/build/hancho/src/hancho-0.2.0/hancho.py", line 1318, in load_hanchos
    self.load_module(
  File "/build/hancho/src/hancho-0.2.0/hancho.py", line 1470, in load_module
    types.FunctionType(code, module.__dict__)()
  File "hello_gtk.hancho", line 3, in <module>
  File "/build/hancho/src/hancho-0.2.0/hancho.py", line 395, in load
    return load_file(file_name, as_repo=False, args=args, kwargs=kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/build/hancho/src/hancho-0.2.0/hancho.py", line 392, in load_file
    return app.load_module(repo_path, repo_name, file_path, file_name, mod_config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/build/hancho/src/hancho-0.2.0/hancho.py", line 1439, in load_module
    with open(file_pathname, encoding="utf-8") as file:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/build/hancho/src/hancho-0.2.0/examples/hello_gtk/rules.hancho'

The hello_gtk example clearly tries to get rules.hancho from the project root, but repo_path seems to be ./examples/hello_gtk, so the load command fails.

Surprisingly, the debug output actually says that repo_path is the project root:

$ python hancho.py -f hello_gtk.hancho -C examples/hello_gtk -d
[…]
global_config = {
  […]
  repo_path = "/build/hancho/src/hancho-0.2.0",
  repo_name = "",
  base_path = "/build/hancho/src/hancho-0.2.0",
  […]
  root_target = "",
  root_name = "hello_gtk.hancho",
  root_path = "/build/hancho/src/hancho-0.2.0/examples/hello_gtk",
}
[…]
FileNotFoundError: [Errno 2] No such file or directory: '/build/hancho/src/hancho-0.2.0/examples/hello_gtk/rules.hancho'
  1. Shouldn’t the debug output be consistent to the value to which Hancho actually evaluates the property?

  2. What would be a correct command line to run the hello_gtk example directly?
    I’ve tried several combinations but none worked.

claui commented 1 month ago

Hancho even allows me to control repo_path by passing --repo_path=…, which clearly affects the global config (according to the debug output). But Hancho still resolves {repo_path}/rules.hancho to examples/hello_gtk/rules.hancho.

aappleby commented 1 month ago

You caught me in the middle of merging v0.2 into main and adding some tweaks from other forks I'd made. I'm going through the examples and stuff now trying to fix everything, just give me a day or so. :D

claui commented 1 month ago

Thanks @aappleby for clarifying!

I had noticed the v0.2.0 release so I assumed it was meant to be stable.