2021-06-14 09:39:07 +01:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, fetchFromGitHub
|
|
|
|
, fetchpatch
|
|
|
|
, pkg-config
|
|
|
|
, libffi
|
|
|
|
, python3
|
|
|
|
, readline
|
|
|
|
}:
|
2019-12-04 02:52:10 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "micropython";
|
2021-06-06 15:12:00 +01:00
|
|
|
version = "1.15";
|
2019-12-04 02:52:10 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "micropython";
|
|
|
|
repo = "micropython";
|
|
|
|
rev = "v${version}";
|
2021-06-06 15:12:00 +01:00
|
|
|
sha256 = "11bf1lq4kgfs1nzg5cnshh2dqxyk5w2k816i04innri6fj0g7y6p";
|
2019-12-04 02:52:10 +00:00
|
|
|
fetchSubmodules = true;
|
|
|
|
};
|
|
|
|
|
2021-06-14 09:39:07 +01:00
|
|
|
# drop the following patches when upgrading to 1.16
|
|
|
|
patches = [
|
|
|
|
# fix build with modern clang https://github.com/micropython/micropython/pull/7254
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/micropython/micropython/commit/126b1c727118352923703719a2a3d45b9fad3c97.patch";
|
|
|
|
sha256 = "13a2bmz24syhd1qsqbx39dcjkjdhf05ln7lanh816m94lkfib21j";
|
|
|
|
})
|
|
|
|
# fix build with modern clang https://github.com/micropython/micropython/pull/7254
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/micropython/micropython/commit/7ceccad4e2f1e9d073f5781c32e5b377e8391a25.patch";
|
|
|
|
sha256 = "04mbxmb5yr6pbhhf9villq8km4wy579r46v9p4n0ysivrxij7i6f";
|
|
|
|
})
|
|
|
|
# fix build on aarch64-darwin https://github.com/micropython/micropython/pull/7393
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/micropython/micropython/commit/95048129b1d93854c25f501c02801929aeeb23f0.patch";
|
|
|
|
sha256 = "1cngcwq4jviyhdnfcrrkdadfikhffzbj0d634j0344cp247jb41n";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
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 09:39:07 +01:00
|
|
|
runHook preBuild
|
2019-12-04 02:52:10 +00:00
|
|
|
make -C mpy-cross
|
|
|
|
make -C ports/unix
|
2021-06-14 09:39:07 +01:00
|
|
|
runHook postBuild
|
2019-12-04 02:52:10 +00:00
|
|
|
'';
|
|
|
|
|
2021-06-14 09:39:07 +01:00
|
|
|
doCheck = true;
|
|
|
|
|
|
|
|
skippedTests = ""
|
|
|
|
+ lib.optionalString (stdenv.isDarwin) " -e uasyncio_basic -e uasyncio_wait_task"
|
|
|
|
+ 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 09:39:07 +01:00
|
|
|
runHook preCheck
|
2019-12-04 02:52:10 +00:00
|
|
|
pushd tests
|
2021-06-14 09:39:07 +01:00
|
|
|
${python3.interpreter} ./run-tests.py ${skippedTests}
|
2019-12-04 02:52:10 +00:00
|
|
|
popd
|
2021-06-14 09:39:07 +01:00
|
|
|
runHook postCheck
|
2019-12-04 02:52:10 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
2021-06-06 15:12:00 +01:00
|
|
|
runHook preInstall
|
2019-12-04 02:52:10 +00:00
|
|
|
mkdir -p $out/bin
|
2021-06-06 15:12:00 +01: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 09:39:07 +01:00
|
|
|
platforms = platforms.unix;
|
2019-12-04 02:52:10 +00:00
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ sgo ];
|
|
|
|
};
|
|
|
|
}
|