[tahoe-dev] help! how do I manage dependencies on JavaScript code?
Zooko O'Whielacronx
zooko at zooko.com
Fri Sep 3 22:03:13 UTC 2010
When you build Tahoe-LAFS, it attempts to read darcs revision control
history and create a version number based on that, and write that
version number into src/allmydata/_version.py. If you don't have
darcs, or you don't have a ./_darcs subdirectory containing your
revision control history, then it does nothing. Tarballs that get
built, such as:
http://tahoe-lafs.org/source/tahoe-lafs/releases/allmydata-tahoe-1.8.0c3.tar.bz2
come with a _version.py file already present, so it is okay that this
step does nothing.
One thing that I learned from this is that warning messages are very
costly. Warning messages are not cheap!
Many people saw warning messages emitted by this code saying something
like "warning: Couldn't find darcs." and thought that darcs was a
dependency of Tahoe-LAFS.
So I changed it to not say the word "warning" or "error". Currently
when you run it and there is no darcs executable it says:
$ python setup.py darcsver
running darcsver
setup.py darcsver: Failure from attempt to find version tags with
'darcs changes', and src/allmydata/_version.py already exists, so
leaving it alone.
If you run it and there is a darcs executable but no ./_darcs
repository, it says:
$ python setup.py darcsver
running darcsver
setup.py darcsver: darcs wrote to stderr: '
darcs failed: Not a repository: . (./_darcs/inventory:
openBinaryFile: does not exist (No such file or directory))
'
setup.py darcsver: Failure from attempt to find version tags with
'darcs changes', and src/allmydata/_version.py already exists, so
leaving it alone.
Oh, I didn't remember that it said that. That still looks bad. Part of
the problem here is that Python distutils is set to verbose by
default. If you pass the --quiet option or edit your distutils config
file:
http://docs.python.org/install/#location-and-names-of-config-files
and add:
[global]
verbose=0
Then both of these commands will pass silently:
$ python setup.py --verbose darcsver
running darcsver
setup.py darcsver: Failure from attempt to find version tags with
'darcs changes', and src/allmydata/_version.py already exists, so
leaving it alone.
$ python setup.py darcsver
$
(There was no output from the second one, because my
~/.pydistutils.cfg file now has verbose=0 in its [global] section.)
As an added benefit all of the other commands in distutils (the vast
majority of which are not maintained by me) will also get quieter.
But of course people won't have their distutils configured to be quiet
by default, so I should still do something about this...
Okay, I've updated that code so that even if you have the default
verbosity setting, then if it can't use darcs to generate a new
version number, it will just say:
$ python setup.py -v darcsver --count-all-patches
running darcsver
setup.py darcsver: using extant version file src/allmydata/_version.py
If you do have a working darcs executable and you are in a Tahoe-LAFS
darcs repository, it will say this:
$ python setup.py -v darcsver --count-all-patches
running darcsver
setup.py darcsver: wrote '1.8.0c3-r4713' into src/allmydata/_version.py
In quiet mode it doesn't emit anything in either case.
Regards,
Zooko
More information about the tahoe-dev
mailing list