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 " ;
2022-04-27 09:35:20 +00:00
version = " 0 . 8 . 1 " ;
2023-10-09 19:29:22 +00:00
format = " p y p r o j e c t " ;
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 } " ;
2022-04-27 09:35:20 +00:00
sha256 = " s h a 2 5 6 - 0 4 q A G T z u s M T 3 G s a R x D o X N J K 1 M s l z x u + u g Q c l B J x 8 x z E = " ;
2021-08-05 21:33:18 +00:00
} ;
postPatch = ''
2022-04-27 09:35:20 +00:00
substituteInPlace pyproject . toml \
- - replace ' scons == 4 .2 . 0 ' ' scons' \
- - replace ' == ' ' >= '
2022-01-22 01:22:15 +00:00
2021-08-05 21:33:18 +00:00
substituteInPlace apio/managers/scons.py - - replace \
' 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 " '
substituteInPlace apio/util.py - - replace \
' _command = join ( get_bin_dir ( ) , " t i n y p r o g " ) ' \
' _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.
substituteInPlace apio/managers/scons.py - - replace \
' 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
] ;
pytestFlagsArray = [ " - - o f f l i n e " ] ;
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 " ;
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 ] ;
} ;
}