diff --git a/hw-tests/upy-minimal/meson.build b/hw-tests/upy-minimal/meson.build
index d674b5df47ac5e50e1a45c978b8c4bc3764e9d26..b38cf95235fb7d76a5952767896937438fd8db45 100644
--- a/hw-tests/upy-minimal/meson.build
+++ b/hw-tests/upy-minimal/meson.build
@@ -13,12 +13,7 @@ modsrc = files(
 version_h = custom_target(
   'mpversion.h',
   output: 'mpversion.h',
-  command: [
-    micropython_gen_version,
-    python3,
-    micropython_dir,
-    '@OUTPUT@',
-  ],
+  command: [micropython_gen_version, '@OUTPUT@'],
 )
 
 modules_h = custom_target(
diff --git a/lib/micropython/meson.build b/lib/micropython/meson.build
index 27b847033d5497fa6eac7794f18e3beafbff504e..bca808fa4a12af50c0a2a12396b99ec692910205 100644
--- a/lib/micropython/meson.build
+++ b/lib/micropython/meson.build
@@ -5,8 +5,11 @@ micropython_gen_modules = [
   meson.current_source_dir(),
 ]
 
-micropython_dir = meson.current_source_dir()
-micropython_gen_version = files('./gen-version.sh')
+micropython_gen_version = [
+  files('./gen-version.sh'),
+  python3,
+  meson.current_source_dir(),
+]
 
 micropython_gen_qstr = [
   files('gen-qstr.sh'),