469,364 Members | 2,471 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,364 developers. It's quick & easy.

gen_py target directory for makepy

I had an unusual problem tonight running makepy to install some
Microsoft COM interfaces in a Python 2.5 Windows XP installation
created using the ActiveState installer.

In earlier versions of Python, the files were generated to:


But in my 2.5 installation they were generated to my temp
directory, in my case this was:


I hadn't paid attention to the messages and when I cleared my
temp directory, which I occasionally do, the COM interfaces
stopped working.

Tracing through the makepy code, I found the following
(reformatted for email) in


if not __gen_path__:
import win32com.gen_py
__gen_path__ = sys.modules["win32com.gen_py"].__path__[0]
except ImportError:
# If a win32com\gen_py directory already exists, then we use it
# (gencache doesn't insist it have an __init__, but our
# __import__ above does!
__gen_path__ = \
os.path.abspath(os.path.join(__path__[0], "gen_py"))
if not os.path.isdir(__gen_path__):
# We used to dynamically create a directory under win32com -
# but this sucks. If the dir doesn't already exist, we we
# create a version specific directory under the user temp
# directory.
__gen_path__ = os.path.join(
win32api.GetTempPath(), "gen_py",
"%d.%d" % (sys.version_info[0],

I was able to make everything work right by creating the gen_py
directory in the expected place and re-running makepy. But I'm
curious to know:

1. Why does it suck to create gen_py dynamically?

2. Why didn't I have a gen_py directory already? Did I somehow
destory it or is it not created by default?

3. Why is the temp directory the alternate choice for where to
put these?


Apr 9 '08 #1
0 1343

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Alv Mart | last post: by
1 post views Thread by Cristian Hasbun from Chile | last post: by
1 post views Thread by Olaf Meding | last post: by
2 posts views Thread by Svenn-Ivar Svendsen | last post: by
2 posts views Thread by nvhengr | last post: by
reply views Thread by artem.marchenko | last post: by
1 post views Thread by Chris Curvey | last post: by
4 posts views Thread by suzhi18 | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.