2021-08-05 21:33:18 +00:00
{ lib
, buildPythonApplication
, fetchFromGitHub
, click
, semantic-version
, requests
, colorama
, pyserial
, wheel
2022-01-22 01:22:15 +00:00
, scons
2021-08-05 21:33:18 +00:00
, setuptools
, tinyprog
2023-10-09 19:29:22 +00:00
, flit-core
2021-08-05 21:33:18 +00:00
, pytestCheckHook
} :
buildPythonApplication rec {
pname = " a p i o " ;
2024-07-27 06:49:29 +00:00
version = " 0 . 9 . 5 " ;
pyproject = true ;
2021-08-05 21:33:18 +00:00
src = fetchFromGitHub {
owner = " F P G A w a r s " ;
repo = " a p i o " ;
rev = " v ${ version } " ;
2024-07-27 06:49:29 +00:00
hash = " s h a 2 5 6 - V U 4 t O s z G k w 2 0 D W W 2 S e r F s n j F i S k r S w q B c w o s G n H J f U 8 = " ;
2021-08-05 21:33:18 +00:00
} ;
postPatch = ''
2022-04-27 09:35:20 +00:00
substituteInPlace pyproject . toml \
2024-07-27 06:49:29 +00:00
- - replace-fail ' scons == 4 .2 . 0 ' ' scons' \
- - replace-fail ' == ' ' >= '
2022-01-22 01:22:15 +00:00
2024-07-27 06:49:29 +00:00
substituteInPlace apio/managers/scons.py - - replace-fail \
2021-08-05 21:33:18 +00:00
' return " t i n y p r o g - - l i b u s b - - p r o g r a m " ' \
' return " ${ tinyprog } / b i n / t i n y p r o g - - l i b u s b - - p r o g r a m " '
2024-07-27 06:49:29 +00:00
substituteInPlace apio/util.py - - replace-fail \
' _command = apio_bin_dir / " t i n y p r o g " ' \
2021-08-05 21:33:18 +00:00
' _command = " ${ tinyprog } / b i n / t i n y p r o g " '
# semantic-version seems to not support version numbers like the one of tinyprog in Nixpkgs (1.0.24.dev114+gxxxxxxx).
# See https://github.com/rbarrois/python-semanticversion/issues/47.
# This leads to an error like "Error: Invalid version string: '1.0.24.dev114+g97f6353'"
# when executing "apio upload" for a TinyFPGA.
# Replace the dot with a dash to work around this problem.
2024-07-27 06:49:29 +00:00
substituteInPlace apio/managers/scons.py - - replace-fail \
2021-08-05 21:33:18 +00:00
' version = semantic_version . Version ( pkg_version ) ' \
' version = semantic_version . Version ( pkg_version . replace ( " . d e v " , " - d e v " ) ) '
'' ;
2023-10-09 19:29:22 +00:00
nativeBuildInputs = [
flit-core
] ;
2021-08-05 21:33:18 +00:00
propagatedBuildInputs = [
click
semantic-version
requests
colorama
pyserial
wheel
2022-01-22 01:22:15 +00:00
scons
2021-08-05 21:33:18 +00:00
setuptools # needs pkg_resources at runtime (technically not needed when tinyprog is also in this list because of the propagatedBuildInputs of tinyprog)
tinyprog # needed for upload to TinyFPGA
] ;
2023-02-02 18:25:31 +00:00
nativeCheckInputs = [
2021-08-05 21:33:18 +00:00
pytestCheckHook
] ;
2024-07-27 06:49:29 +00:00
disabledTestPaths = [
# This test fails and is also not executed in upstream's CI
" t e s t 2 "
] ;
2021-08-05 21:33:18 +00:00
pytestFlagsArray = [ " - - o f f l i n e " ] ;
2024-07-27 06:49:29 +00:00
strictDeps = true ;
2021-08-05 21:33:18 +00:00
meta = with lib ; {
description = " O p e n s o u r c e e c o s y s t e m f o r o p e n F P G A b o a r d s " ;
2024-04-21 15:54:59 +00:00
mainProgram = " a p i o " ;
2021-08-05 21:33:18 +00:00
homepage = " h t t p s : / / g i t h u b . c o m / F P G A w a r s / a p i o " ;
license = licenses . gpl2Only ;
maintainers = with maintainers ; [ Luflosi ] ;
} ;
}