dan-fritchman / Hdl21

Hardware Description Library
BSD 3-Clause "New" or "Revised" License
60 stars 13 forks source link

Drop special paths (like `__main__` especially) from exported Module paths #178

Open dan-fritchman opened 11 months ago

dan-fritchman commented 11 months ago

The paths we export, which eventually (can) become _importpaths, could get smarter.
Example:

import hdl21 as h 

m = h.Module(name="MyName")
print(m._importpath)

pkg = h.to_proto(m)
ns = h.from_proto(pkg)
print(ns.__main__.MyName._importpath)

Yields

None
['__main__']

The __main__ in that namespace-path is, well, pretty lame.
I recall thinking we should special-case that out (and maybe __init__.py as well).
I do not recall whether I ever tried, or hit any roadblocks.

Originally https://github.com/dan-fritchman/Hdl21/issues/176#issuecomment-1700280538