librelist archives

« back to archive

Is there any way to get the version number I put in setup.py?

Is there any way to get the version number I put in setup.py?

From:
Peter Cai
Date:
2011-08-24 @ 22:25
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!

Re: [flask] Is there any way to get the version number I put in setup.py?

From:
Rodrigo Aliste P.
Date:
2011-08-24 @ 22:35
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.

Re: [flask] Is there any way to get the version number I put in setup.py?

From:
Peter Cai
Date:
2011-08-24 @ 23:39
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.
>
>

Re: [flask] Is there any way to get the version number I put in setup.py?

From:
Daniele Nicolodi
Date:
2011-08-24 @ 22:33
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