[CentralOH] How to Avoid Hard Coded Python Version?
jep200404 at columbus.rr.com
jep200404 at columbus.rr.com
Thu Nov 5 21:37:12 EST 2015
How would you avoid hard coding a Python version number?
I've been porting a Django web server from Centos 6 to Centos 7.
Apache was not happy on Centos 7.
I figured out the problem was not an Apache configuration file.
It was a hard coded python version number in a python file:
vepath = '{home}/env/lib/python2.6/site-packages'.format(home=apphome)
So I changed it to the following, and Apache is happy on Centos 7.
vepath = '{home}/env/lib/python2.7/site-packages'.format(home=apphome)
I would like to avoid that hard coded python version for the
next time. I can imagine several ways of dynamically figuring
out the python version. One would be to use a glob like
'{home}/env/lib/python*/site-packages'.format(home=apphome)
Another would be something like:
'{home}/env/lib/python{version}/site-packages'.format(
home=apphome, version=sys.version[:3])
The 3 in sys.version[:3] is ugly, so the glob feels slightly better.
What would you use?
What improvements do you have?
More information about the CentralOH
mailing list