Compare commits

...

2 Commits

Author SHA1 Message Date
1a3c831a06 flake: Introduce PyThermostat scripts to devShell
Make Python scripts in PyThermostat available in the development shell
(thermostat_plot, thermostat_autotune, and thermostat_test).
2024-11-25 11:12:02 +08:00
d64c83953e flake: Add pythermostat to PYTHONPATH in devshell
For easier testing of PyThermostat client code in the development shell,
so that the following is possible right in the repo root:

```
$ python
Python 3.11.9 (main, Apr  2 2024, 08:25:04) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pythermostat.client import Client
>>> c = Client()
>>>
```
2024-11-25 11:11:17 +08:00
4 changed files with 17 additions and 0 deletions

View File

@ -69,6 +69,19 @@
matplotlib matplotlib
]; ];
}; };
pythermostat-dev-wrappers = pkgs.runCommandNoCC "pythermostat-dev-wrappers" { } ''
mkdir -p $out/bin
for program in ${self}/pythermostat/*.py; do
if [ -x $program ]; then
progname=`basename -s .py $program`
outname=$out/bin/thermostat_$progname
echo "#!${pkgs.bash}/bin/bash" >> $outname
echo "exec python -m $progname \"\$@\"" >> $outname
chmod 755 $outname
fi
done
'';
in in
{ {
packages.x86_64-linux = { packages.x86_64-linux = {
@ -90,11 +103,15 @@
openocd openocd
dfu-util dfu-util
rlwrap rlwrap
pythermostat-dev-wrappers
] ]
++ (with python3Packages; [ ++ (with python3Packages; [
numpy numpy
matplotlib matplotlib
]); ]);
shellHook = ''
export PYTHONPATH=`git rev-parse --show-toplevel`/pythermostat:$PYTHONPATH
'';
}; };
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt-rfc-style; formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt-rfc-style;

0
pythermostat/pythermostat/autotune.py Normal file → Executable file
View File

0
pythermostat/pythermostat/plot.py Normal file → Executable file
View File

0
pythermostat/pythermostat/test.py Normal file → Executable file
View File