When does a binary extension gets the file extension '.pyd' and when is it '.so'
Fredrik Lundh
fredrik at pythonware.com
Fri Apr 4 12:34:59 EDT 2008
llothar wrote:
> On windows everything is '.pyd' but there seems to be two ways to get
> this on unix?
If you attempt to import the module "spam" on Windows, Python looks for
"spam.dll" and "spam.pyd" (in addition to "spam.py/spam.pyw/spam.pyc" etc)
On most Unix platforms, Python looks for "spam.so" and "spammodule.so".
You can check what suffixes a given Python version uses via the "imp"
module:
>>> import imp
>>> imp.get_suffixes()
To see *where* Python is looking as well, use the "-vv" flag:
$ python -vv -c "import spam"
...
# trying spam.so
# trying spammodule.so
# trying spam.py
# trying spam.pyc
... etc
(-vv prints loads of stuff, so you may want to use "grep" to filter out
the stuff you're interested in:
$ python -vv -c "import spam" 2>&1 | grep spam
or, under Windows:
> python -vv -c "import spam" 2> out.txt
> findstr spam out.txt
)
> Why and what is the rule?
If you want Python to be able to import your binary extension, make sure
to use a name it looks for.
</F>
More information about the Python-list
mailing list