2021-06-14 08:39:07 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, fetchFromGitHub
|
|
|
|
, pkg-config
|
|
|
|
, python3
|
2021-09-10 11:33:43 +00:00
|
|
|
, libffi
|
2021-06-14 08:39:07 +00:00
|
|
|
, readline
|
|
|
|
}:
|
2019-12-04 02:52:10 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "micropython";
|
2022-07-31 23:55:17 +00:00
|
|
|
version = "1.19.1";
|
2019-12-04 02:52:10 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2022-07-25 16:27:25 +00:00
|
|
|
owner = "micropython";
|
|
|
|
repo = "micropython";
|
|
|
|
rev = "v${version}";
|
2022-07-31 23:55:17 +00:00
|
|
|
sha256 = "sha256-BoX3Z3Zr/AQqkgRrq+UVgdoDqNESDTNsY9AtrElpzfA=";
|
2019-12-04 02:52:10 +00:00
|
|
|
fetchSubmodules = true;
|
|
|
|
};
|
|
|
|
|
2021-01-19 06:50:56 +00:00
|
|
|
nativeBuildInputs = [ pkg-config python3 ];
|
2019-12-04 02:52:10 +00:00
|
|
|
|
|
|
|
buildInputs = [ libffi readline ];
|
|
|
|
|
|
|
|
buildPhase = ''
|
2021-06-14 08:39:07 +00:00
|
|
|
runHook preBuild
|
2019-12-04 02:52:10 +00:00
|
|
|
make -C mpy-cross
|
|
|
|
make -C ports/unix
|
2021-06-14 08:39:07 +00:00
|
|
|
runHook postBuild
|
2019-12-04 02:52:10 +00:00
|
|
|
'';
|
|
|
|
|
2021-06-14 08:39:07 +00:00
|
|
|
doCheck = true;
|
|
|
|
|
|
|
|
skippedTests = ""
|
2022-01-24 22:48:03 +00:00
|
|
|
+ lib.optionalString (stdenv.isDarwin) " -e uasyncio_basic -e uasyncio_heaplock -e uasyncio_wait_task"
|
2021-06-14 08:39:07 +00:00
|
|
|
+ lib.optionalString (stdenv.isDarwin && stdenv.isAarch64) " -e ffi_callback"
|
|
|
|
+ lib.optionalString (stdenv.isLinux && stdenv.isAarch64) " -e float_parse"
|
|
|
|
;
|
|
|
|
|
2019-12-04 02:52:10 +00:00
|
|
|
checkPhase = ''
|
2021-06-14 08:39:07 +00:00
|
|
|
runHook preCheck
|
2019-12-04 02:52:10 +00:00
|
|
|
pushd tests
|
2021-06-14 08:39:07 +00:00
|
|
|
${python3.interpreter} ./run-tests.py ${skippedTests}
|
2019-12-04 02:52:10 +00:00
|
|
|
popd
|
2021-06-14 08:39:07 +00:00
|
|
|
runHook postCheck
|
2019-12-04 02:52:10 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
2021-06-06 14:12:00 +00:00
|
|
|
runHook preInstall
|
2019-12-04 02:52:10 +00:00
|
|
|
mkdir -p $out/bin
|
2021-06-06 14:12:00 +00:00
|
|
|
install -Dm755 ports/unix/micropython -t $out/bin
|
|
|
|
runHook postInstall
|
2019-12-04 02:52:10 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "A lean and efficient Python implementation for microcontrollers and constrained systems";
|
|
|
|
homepage = "https://micropython.org";
|
2021-06-14 08:39:07 +00:00
|
|
|
platforms = platforms.unix;
|
2019-12-04 02:52:10 +00:00
|
|
|
license = licenses.mit;
|
2021-09-10 11:33:43 +00:00
|
|
|
maintainers = with maintainers; [ prusnak sgo ];
|
2019-12-04 02:52:10 +00:00
|
|
|
};
|
|
|
|
}
|