Closed rickstaa closed 4 years ago
Hey, It can be done, but what are the advantages of this solution compared to cloning the repository from github?
Instead of git clone https://github.com/onlaj/Piano-LED-Visualizer
user will have to type pip install piano-led-visualizer
, what else will change?
@onlaj You are right not much will change. The main benefit of adding it to the PyPI repository will be that users do not need to clone the repository but can simply install the package using the pip install piano-led-visualizer
command. The main benefit of changing the project structure into a model/script based structure would be that we can create a command-line script out of the visualizer.py
script. This would allow the user to evoke the visualizer using piano-led-visualizer
instead of sudo -E python vizualizer.py
. I am however unsure if that would work when the script needs the sudo -E
. The other benefit would be that users can install the package and requirements using one simple pip install .
command instead. This, however, could already be done by only adding the following setup.py file. The main reason I proposed the project structure change is that I think separating the (third party) modules from the main run code would make it easier for people to contribute to the repository. I, however, can understand if there are features you would like to have implemented first. I am happy to help.
@rickstaa
just create a service :
and run it like a service. so you can always
sudo service pianoled start/stop also autostart after boot.
@vzoltan You right that would be a more of an improvement compared to a command-line script. Creating a service would make a pipy package redundant. I will use that on my own raspberry pi for now. Maybe we can add something about that in the documentation.
@vzoltan Or just a note as service creation is already explained in the rpi-midi-complete documentation
with what ive linked it runs as service. all i know, it works for me.
@vzoltan It runs perfectly thanks for that! I was thinking of adding something like this to the README.md:
Download or clone this repository into your RPI.
git clone https://github.com/onlaj/Piano-LED-Visualizer
Using PIP install all libraries listed in requirements.txt file Run visualizer.py with command
sudo -E python visualizer.py
You can auto run Visualizer on RPi boot, just follow this tutorial: How To Autorun A Python Script On Raspberry Pi Boot. Additionally, you can also create a service that is started at boot. The steps on how to do this can be found below.
A service can be created for the pianoled script by creating a service startup file sudo nano /lib/systemd/system/pianoled.service
:
[Unit]
Description=PianoLED
After=multi-user.target
Conflicts=getty@tty1.service
[Service]
Type=simple
ExecStart=sudo /bin/sh -c 'HOME=/home/pi /usr/bin/python /home/pi/Piano-LED-Visualizer/visualizer.py'
StandardInput=tty-force
[Install]
WantedBy=multi-user.target
Following this service can be added to boot at startup using the following commands:
sudo systemctl daemon-reload
sudo systemctl enable pianoled.service
sudo systemctl start pianoled.service
@vzoltan I tested your solution out today, and it fully satisfies my what I had in mind. Thanks again!
@onlaj First of all, thanks a lot for creating this repository it works very well! I was creating something similar when I found your code. @onlaj Maybe it is an idea to create a pipy package out of this? I am happy to help with this. In order to do this, I think it is better to change the folder structure to one that is more compatible with the pipy framework (see this post)[https://stackoverflow.com/questions/193161/what-is-the-best-project-structure-for-a-python-application]. My suggestion would be to use something like:
.xml
files.vizualize.py
script)..stl
file.visualize.py
run code.In this, the
visualize.py
script would be split into a module and a script that users can run. Let me know your thoughts.