I have a small program in python that consists in one .py
file plus a directory of data files used by the program.
I would like to know the proper way to create an installation procedure for a user with admin rights on Linux so that he can install the program on his system and use it from the command line, with options and parameters. EDIT: The part I am having trouble with is to have the program, once installed, retrieve the data files, contained in a 'data' sub-folder.
Would a setup script that installs the executable program file in /usr/local/bin
and the data folder in /usr/share/my_program/data
be an acceptable solution? Something like:
#!/bin/bash
# Launch with sudo
chmod +x program.py
cp program.py /usr/local/bin
cp -r data /usr/share/my_program
echo Installation complete
Now, in order to do that, I have to assume, in the program, that the data files are going to be in /usr/share/my_program/data
. But I would also leave the user the choice of using the program without installing it. Then I would have to assume that the data are in './data', relative to the executable program file. How should I solve this problem? I can think of a few ways, but my feeling is that I am creating a mess where there should be a clear and correct answer.
Currently, I am considering using a try except clause:
try:
find data from /usr/share/my_program && set path accordingly
except:
set path to the data as './data'
Again, I feel it is a bit convoluted. How would you proceed for the installation?