Re: __author__

From: Peter L Hansen (peter_at_engcorp.com)
Date: 10/01/04


Date: Fri, 01 Oct 2004 15:35:04 -0400

Mike C. Fletcher wrote:
> Peter L Hansen wrote:
>> (I've tended to use VERSION, I believe, but I'm moving towards
>> using a build.xml file containing a variety of meta-information
>> for the entire package, rather than an embedded constant.)
>
> Ah yes, much easier to work with ;) :
>
> import package
> if [int(i) for i in package.__version__.split('.')[:2]] > [2,3]:
> blah()
>
> versus:
>
> import package
> tag = findVersionTag(parseXMLFile(findXMLFile( package )))
> if (findMajorVersion(tag),findMinorVersion(tag)) > (2,3):
> blah()
>
> Just teasing, you know I believe that XML is the solution to all
> problems in the universe which can't be addressed *directly* with Java
> ;) . As long as you're exposing APIs that mean client libraries never
> have to do the actual finding and parsing of the XML file, having your
> "get version" API integrated into your package-management code can be
> very useful for keeping them in sync.
>
> Still, __version__ is a pretty simple API...

Actually, the XML is invisible to anything outside the application,
while simplifying a variety of things relating to the rest of my
infrastructure, including automatic documentation generation,
testing framework, packaging, and revision control.

At the top of the app/package, I have a "from buildutils import build"
call, and then I can do "build.version", or "build.exename", or
whatever... if I care to support folks like you who might want to
do "xxx.__version__" I guess I should do a "__version__ = build.version"
at the top of the module... hadn't thought of that.

Basically, the stuff is read at run-time, so _you_ wouldn't
be able to tell the difference, but I have the information
maintained externally instead of being coupled to the Python
code and inaccessible to, say, InnoSetup or py2exe or my own
utilities which might not or have the means to import the
module.

And as you surmised, this is largely about keeping things in
sync and avoiding duplication. In the most recent thing that
uses this, I need pieces of the build.xml content in all the
places mentioned above, meaning I've finally achieved my goal
of removing about five different instances of duplication and
my release process can be completely automated, provided I've
remembered to update the version number at all...

-Peter



Relevant Pages

  • Re: TclXSLT question: best approach?
    ... Tcl script using XSLT and then eval'ing it is something I've been doing ... dom::serialize command because the dom package is separate to the xslt ... know that its intended serialisation is as text rather than as XML. ...
    (comp.lang.tcl)
  • Confusion over directory search order for "use"
    ... I'm going to use a package for this and I've chosen to code the ... config in XML and use XML::Simple to read it in. ... directory in which Global.pm and "tryit" live. ... [henry@neptune henry]$ grep NFB tryit ...
    (comp.lang.perl.misc)
  • Re: .NET (C#) and Word Application
    ... when embedding the document in your app. ... Your best bet is to create the document XML yourself, and package it ... the System.Xml namespace to generate the actual XML (Office 2007 documents ...
    (microsoft.public.dotnet.languages.csharp)
  • XML support in Java 5?
    ... The javax.xml and javax.xml.stream packages have some classes that look very useful for writing and reading XML. ... The few things that are documented as being in Java 5, I don't see how they are useful for actually writing XML. ...
    (comp.lang.java.programmer)
  • Re: Formatting an Excel sheet from a DTS package
    ... One solution may be to use Excel's XML format. ... ActiveX scripting task in the package to perform an XSLT transform to ... make it into an Excel XML file. ...
    (microsoft.public.sqlserver.dts)