Compare commits

...

2 Commits

Author SHA1 Message Date
16c78c5784 flake: Introduce PyThermostat scripts to devShell
Make executable Python scripts in the PyThermostat root available in the
development shell (e.g. thermostat_plot, thermostat_autotune,
thermostat_test).
2024-11-25 10:27:04 +08:00
9d218b3fa5 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 10:21:21 +08:00
4 changed files with 21 additions and 5 deletions

View File

@ -63,12 +63,24 @@
version = "0.0.0";
src = "${self}/pythermostat";
propagatedBuildInputs =
with pkgs.python3Packages; [
propagatedBuildInputs = with pkgs.python3Packages; [
numpy
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
{
packages.x86_64-linux = {
@ -90,11 +102,15 @@
openocd
dfu-util
rlwrap
pythermostat-dev-wrappers
]
++ (with python3Packages; [
numpy
matplotlib
]);
shellHook = ''
export PYTHONPATH=`git rev-parse --show-toplevel`/pythermostat:$PYTHONPATH
'';
};
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt-rfc-style;

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

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

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