Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 269196 - gentoolkit-0.3.0_rc5 - /etc/gentoolkit-version was not a great idea
Summary: gentoolkit-0.3.0_rc5 - /etc/gentoolkit-version was not a great idea
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Tools (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Portage Tools Team
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks: 237964 270217
  Show dependency tree
 
Reported: 2009-05-10 01:48 UTC by Douglas Anderson
Modified: 2009-06-19 17:13 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
gentoolkit-VERSION.patch (gentoolkit-VERSION.patch,1.58 KB, patch)
2009-05-19 00:39 UTC, michael@smith-li.com
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Douglas Anderson 2009-05-10 01:48:01 UTC
The idea to put gentoolkit's version in the /etc folder came from /etc/gentoo-release, but I release now it's not the best location because:
1) it's not meant to be user-editable
2) the user will have to run dispatch-conf or etc-update after each update of gentoolkit, which is really unnecessary

loki_val suggested putting it in /usr/share. If we did that, it'd be an easy switch, just change the location the ebuild writes to and change the filename that each script is reading from. 

A different idea is to use the Makefile to write the version to the files right before being tarred up, similar to what FuzzyRay already uses to set the version in setup.py. 

Something like:

	# Set python scripts' version
	sed -i "s/^__version__ = .*/__version__ = '$(VERSION)'/" setup.py bin/* pym/gentoolkit/equery/__init__.py
	# Set bash scripts' version
	sed -i "s/^PROGRAM_VERSION=.*/PROGRAM_VERSION="$(VERSION)"/" bin/euse

To use that, we'd have to change VER to __version__ in setup.py (and there might have been a change in one other file).

I personally think the Makefile version is the cleaner of the two, but it needs more modifications and it's needs testing from someone who can commit to svn so all their changes aren't reverted. :) 

Thoughts?
Comment 1 Douglas Anderson 2009-05-10 01:50:32 UTC
And you'd need to update what was reverted:

	svn revert setup.py bin/* pym/gentoolkit/equery/__init__.py
Comment 2 michael@smith-li.com 2009-05-10 14:16:12 UTC
You'd also need to change VER = foo to __version__ = foo in setup.py.

I'm actually kinda frustrated with the response I'm getting from python on this: I think having to jump through hoops or manually set version strings in multiple places is a violation of python philosophy, but distutils doesn't handle this for us, yet (and I've found threads requesting this feature from as far back as 2000: http://markmail.org/message/2scglmh7ckuee6fz )

Let's do this:
Create a file named VERSION and a symlink VERSION.py containing only a quoted string with the version number in it.
# echo '1.2.3.4' > VERSION && ln -s VERSION VERSION.py

Then, in setup.py, near the top (__init__.py can use this method too if it's convenient.):
# HACK to get version in a way that works in both bash and python
from VERSION import __doc__ as __version__

Then install VERSION with the other files like README, AUTHORS, etc, and use that file for pulling version info.

Doing this in make isn't quite as trivial. Although we could just do make VERSION=$(<VERSION) in the ebuild, or we could leave the VERSION out of the Makefile entirely.
Comment 3 michael@smith-li.com 2009-05-10 14:35:35 UTC
Even better. Don't make the VERSION.py symlink, and instead do:

execfile('VERSION')
__version__ = __doc__

Also, for reading the VERSION in bash you'll need to strip out the quotes, either with parameter expansion:
echo "${VERSION//'}"

or by dropping them at read time:
IFS="'" read _ VERSION _ < VERSION
Comment 4 Douglas Anderson 2009-05-10 16:42:25 UTC
If that VERSION file would get installed to /usr/share/gentoolkit/VERSION then that would be a fine solution.

Also we could just not quote the version in VERSION and get it with 
VERSION=$(cat /path/to/VERSION)
in bash and
__version__ = open('/path/to/VERSION').read().strip()
in python.
I'm using something similar to that now.
Comment 5 michael@smith-li.com 2009-05-19 00:39:08 UTC
Created attachment 191733 [details, diff]
gentoolkit-VERSION.patch

This patch sets up the repository to expect a VERSION file. Releases should have a specific version in this file. It doesn't really matter what is in the file in trunk, but for clarity's sake I think it should contain 9999, unquoted.
Comment 6 Paul Varner (RETIRED) gentoo-dev 2009-05-21 01:58:45 UTC
$ svn commit -m "Change /etc/gentoolkit-version to /usr/share/gentoolkit/VERSION"
Sending        gentoolkit/ChangeLog
Sending        gentoolkit/bin/eclean
Sending        gentoolkit/bin/epkginfo
Sending        gentoolkit/bin/euse
Sending        gentoolkit/bin/glsa-check
Sending        gentoolkit/pym/gentoolkit/equery/__init__.py
Transmitting file data ......
Committed revision 651.
Comment 7 Paul Varner (RETIRED) gentoo-dev 2009-06-19 17:13:48 UTC
Released in gentoolkit-0.3.0_rc7