2021-06-28 23:13:55 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, fetchFromGitHub
|
|
|
|
, pkg-config
|
|
|
|
, python3
|
2021-09-18 10:52:07 +00:00
|
|
|
, libffi
|
2021-06-28 23:13:55 +00:00
|
|
|
, readline
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "micropython";
|
2024-06-05 15:53:02 +00:00
|
|
|
version = "1.23.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2022-08-12 12:06:08 +00:00
|
|
|
owner = "micropython";
|
|
|
|
repo = "micropython";
|
|
|
|
rev = "v${version}";
|
2024-06-05 15:53:02 +00:00
|
|
|
sha256 = "sha256-sfJohmsqq5FumUoVE8x3yWv12DiCJJXae62br0j+190=";
|
2020-04-24 23:36:52 +00:00
|
|
|
fetchSubmodules = true;
|
|
|
|
};
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
nativeBuildInputs = [ pkg-config python3 ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
buildInputs = [ libffi readline ];
|
|
|
|
|
|
|
|
buildPhase = ''
|
2021-06-28 23:13:55 +00:00
|
|
|
runHook preBuild
|
2020-04-24 23:36:52 +00:00
|
|
|
make -C mpy-cross
|
|
|
|
make -C ports/unix
|
2021-06-28 23:13:55 +00:00
|
|
|
runHook postBuild
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
doCheck = true;
|
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
skippedTests = " -e select_poll_fd"
|
2021-06-28 23:13:55 +00:00
|
|
|
+ lib.optionalString (stdenv.isDarwin && stdenv.isAarch64) " -e ffi_callback"
|
|
|
|
+ lib.optionalString (stdenv.isLinux && stdenv.isAarch64) " -e float_parse"
|
|
|
|
;
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
checkPhase = ''
|
2021-06-28 23:13:55 +00:00
|
|
|
runHook preCheck
|
2020-04-24 23:36:52 +00:00
|
|
|
pushd tests
|
2021-06-28 23:13:55 +00:00
|
|
|
${python3.interpreter} ./run-tests.py ${skippedTests}
|
2020-04-24 23:36:52 +00:00
|
|
|
popd
|
2021-06-28 23:13:55 +00:00
|
|
|
runHook postCheck
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
2021-06-28 23:13:55 +00:00
|
|
|
runHook preInstall
|
2020-04-24 23:36:52 +00:00
|
|
|
mkdir -p $out/bin
|
2023-10-09 19:29:22 +00:00
|
|
|
install -Dm755 ports/unix/build-standard/micropython -t $out/bin
|
2024-02-29 20:09:43 +00:00
|
|
|
install -Dm755 mpy-cross/build/mpy-cross -t $out/bin
|
2021-06-28 23:13:55 +00:00
|
|
|
runHook postInstall
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "A lean and efficient Python implementation for microcontrollers and constrained systems";
|
|
|
|
homepage = "https://micropython.org";
|
2021-06-28 23:13:55 +00:00
|
|
|
platforms = platforms.unix;
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.mit;
|
2021-09-18 10:52:07 +00:00
|
|
|
maintainers = with maintainers; [ prusnak sgo ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|