diff --git a/fpga/__init__.py b/fpga/__init__.py index 6b29208..48e0ec3 100644 --- a/fpga/__init__.py +++ b/fpga/__init__.py @@ -6,16 +6,18 @@ __version__ = '0.1.0' def populate_environ(): import os, shutil - for env_name, program in [ - ("YOSYS", "yowasp-yosys"), - ("NEXTPNR_ICE40", "yowasp-nextpnr-ice40"), - ("NEXTPNR_ECP5", "yowasp-nextpnr-ecp5"), + for nmigen_envvar, expected_path, alternative_path in [ + ("YOSYS", "yosys", "yowasp-yosys"), # nmigen-yosys is handled by nmigen + ("NEXTPNR_ICE40", "nextpnr-ice40", "yowasp-nextpnr-ice40"), + ("NEXTPNR_ECP5", "nextpnr-ecp5", "yowasp-nextpnr-ecp5"), ]: - if shutil.which(program): - os.environ[env_name] = program + if nmigen_envvar in os.environ: continue + if shutil.which(expected_path): continue + if not shutil.which(alternative_path): continue + os.environ[nmigen_envvar] = alternative_path populate_environ() del populate_environ # dogelang: Slow. Stupid. Absolutely adorable. -import dg # install import hook +import dg # setup the dg import hook