Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically find the installed version of pywin32

Some Python packages provide a way for a program to get the installed version. E.g.

>>> import numpy
>>> numpy.version.version
'1.5.0'

But I can't find a way to do so for pywin32. What good way might there be to find out?

like image 352
Craig McQueen Avatar asked Nov 04 '10 00:11

Craig McQueen


2 Answers

I found a blog post "Include version information in your Python packages" by Jean-Paul Calderone which showed you can get the version of pywin32 this way:

>>> import win32api
>>> fixed_file_info = win32api.GetFileVersionInfo(win32api.__file__, '\\')
>>> fixed_file_info['FileVersionLS'] >> 16
212
like image 61
Craig McQueen Avatar answered Oct 17 '22 03:10

Craig McQueen


Adapted from Mark's official response at: http://mail.python.org/pipermail/python-win32/2010-April/010404.html

import os
import distutils.sysconfig

pth = distutils.sysconfig.get_python_lib(plat_specific=1)
ver = open(os.path.join(pth, "pywin32.version.txt")).read().strip()

as Craig's answer no longer worked for me on the amd64 build.

like image 20
RuiDC Avatar answered Oct 17 '22 02:10

RuiDC