Pythonwin uses something very similar...
import distutils.sysconfig
site_packages = distutils.sysconfig.get_python_lib(plat_specific=1)
try:
build_no = open(os.path.join(site_packages,
"pywin32.version.txt")).read().strip()
ver = "pywin32 build %s" % build_no
except EnvironmentError:
ver = None
if ver is None:
# See if we are Part of Active Python
ver = _GetRegistryValue("SOFTWARE\\ActiveState\\ActivePython",
"CurrentVersion")
if ver is not None:
ver = "ActivePython build %s" % (ver,)
if ver is None:
ver = ""
IIUC, ActivePython doesn't create the .txt file and there is no
reasonable way of correlating an AP build with a pywin32 build.
Cheers,
Mark
On 16/04/2010 6:44 AM, Marc-Andre Belzile wrote:
Hi,
what is the recommended way of getting the pywin version number from
python ?
I'm currently using this snipet:
import os
import distutils
import distutils.sysconfig
site_packages = distutils.sysconfig.get_python_lib(plat_specific=1)
build_no = open(os.path.join(site_packages,
"pywin32.version.txt")).read().strip()
print ("PyWin32 version: %s") % ( build_no)
thanks
-mab
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32