Hi all, I want to append the version number to links of JavaScript and CSS, so each release would force browsers to update these files. Right now I just wrote the version number in 2 places : setup.py and views.py So there's a duplication in the code. I'm wondering if there are better solutions for this. Thanks!
In that case it would be better if you put your version in another file, say in your __init__.py with: __version__ = 'x.y' and then in setup.py and views.py: from yourmodule import __version__ in setup.py: setup( [...] version=__version__, [...] ) On Wed, Aug 24, 2011 at 7:25 PM, Peter Cai <newptcai@gmail.com> wrote: > Hi all, > > I want to append the version number to links of JavaScript and CSS, > so each release would force browsers to update these files. > > Right now I just wrote the version number in 2 places : setup.py and > views.py So there's a duplication in the code. > > I'm wondering if there are better solutions for this. > > Thanks! > -- Rodrigo Aliste P.
Thx, just tried, it works. On Wed, Aug 24, 2011 at 6:35 PM, Rodrigo Aliste P. <raliste@gmail.com>wrote: > In that case it would be better if you put your version in another file, > say in your __init__.py with: > > __version__ = 'x.y' > > and then in setup.py and views.py: > > from yourmodule import __version__ > > in setup.py: > > setup( > [...] > version=__version__, > [...] > ) > > > > On Wed, Aug 24, 2011 at 7:25 PM, Peter Cai <newptcai@gmail.com> wrote: > >> Hi all, >> >> I want to append the version number to links of JavaScript and CSS, >> so each release would force browsers to update these files. >> >> Right now I just wrote the version number in 2 places : setup.py and >> views.py So there's a duplication in the code. >> >> I'm wondering if there are better solutions for this. >> >> Thanks! >> > > > > -- > Rodrigo Aliste P. > >
On 25/08/11 00:25, Peter Cai wrote: > Right now I just wrote the version number in 2 places : setup.py and > views.py So there's a duplication in the code. > > I'm wondering if there are better solutions for this. The only way I know is to use distribute/setuptools and therefore it probably works only if your package is installed as an egg:: from pkg_resources import get_distribution version = get_distribution('package-name').version Cheers, -- Daniele