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-09-19 14:19:46 +00:00
|
|
|
hash = "sha256-coUFIepbCRuz+766E7VCTQLm0oWB1CTO20ATriC86dc=";
|
2020-04-24 23:36:52 +00:00
|
|
|
fetchSubmodules = true;
|
2024-09-19 14:19:46 +00:00
|
|
|
|
|
|
|
# remove unused libaries from rp2 port's SDK. we leave this and the other
|
|
|
|
# ports around for users who want to override makeFlags flags to build them.
|
|
|
|
# https://github.com/micropython/micropython/blob/a61c446c0b34e82aeb54b9770250d267656f2b7f/ports/rp2/CMakeLists.txt#L17-L22
|
|
|
|
#
|
|
|
|
# shrinks uncompressed NAR by ~2.4G (though it is still large). there
|
|
|
|
# doesn't seem to be a way to avoid fetching them in the first place.
|
|
|
|
postFetch = ''
|
|
|
|
rm -rf $out/lib/pico-sdk/lib/{tinyusb,lwip,btstack}
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
nativeBuildInputs = [ pkg-config python3 ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
buildInputs = [ libffi readline ];
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
makeFlags = [ "-C" "ports/unix" ]; # also builds mpy-cross
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
doCheck = true;
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
__darwinAllowLocalNetworking = true; # needed for select_poll_eintr test
|
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
skippedTests = " -e select_poll_fd"
|
2024-09-26 11:04:55 +00:00
|
|
|
+ lib.optionalString (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) " -e ffi_callback -e float_parse -e float_parse_doubleproc"
|
|
|
|
+ lib.optionalString (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) " -e float_parse"
|
2021-06-28 23:13:55 +00:00
|
|
|
;
|
|
|
|
|
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; {
|
2024-06-20 14:57:18 +00:00
|
|
|
description = "Lean and efficient Python implementation for microcontrollers and constrained systems";
|
2020-04-24 23:36:52 +00:00
|
|
|
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
|
|
|
};
|
|
|
|
}
|