Accessing prefix within setup.py (distutils)

G

Graham Ashton

I'm writing a setup.py script for installing my application and have a
quick distutils question. My application has a .py file, a
..conf file and a .glade file. I would like them to get installed as
follows:

/usr/local/bin/myprogram.py
/usr/local/etc/myprogram.conf
/usr/local/share/myprogram/glade/myprogram.glade

This is quite achievable if I specify a prefix of /usr/local, with the
following:

setup(...,
scripts=["myprogram.py"],
data_files=[("share/myprogram/glade", ["myprogram.glade"]),
("etc", ["myprogram.conf"])]
)

My question is how to avoid installing myprogram.conf into /usr/etc
(instead of /etc) if the installer specifies a prefix of /usr? Doesn't
distutils know the difference between a data file and a config file?

If I could detect what the --prefix parameter was set to I could deal with
it myself within setup.py, but I don't seem to be able to get hold of it.

Thanks in advance.

-- Graham
 
K

Kirby Angell

data_files = [ \

('/etc/init.d', [ 'scripts/myscript' ] ),
('/usr/local/bin', [ 'code/prog1.py' ] ),
('/usr/local/bin', [ 'code/prog2.py' ] ),
('/usr/local/etc', [ 'etc/prog.conf' ] )

]

works for me to put stuff all over the place. I will confess to not
having to worry about the --prefix parameter because our software is
only used in-house.
My question is how to avoid installing myprogram.conf into /usr/etc
(instead of /etc) if the installer specifies a prefix of /usr? Doesn't
distutils know the difference between a data file and a config file?

--
Thank you,

Kirby Angell
Get notified anytime your website goes down!
http://www.alertra.com
key: 9004F4C0
fingerprint: DD7E E88D 7F50 2A1E 229D 836A DB5B A751 9004 F4C0
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top