1

I am trying to generate Python bindings for a C++ shared library with SWIG and distribute the project with conda. The build process seems to work as I can execute

import mymodule as m
ret = m.myfunctioninmymodule()

in my build directory. Now I want to install files that are created (namely, mymodule.py and _mymodule.pyd) in my conda environment on Windows so that I can access them from everywhere. But where do I have to place the files?

What I have tried so far is to put both files in a package together with a __init__.py (which is empty, however) and write a setup.py as suggested here. The package has the form

- mypackage
 |- __init__.py
 |- mymodule.py
 |- _mymodule.pyd

and is installed under C:\mypathtoconda\conda\envs\myenvironmentname\Lib\site-packages\mypackage-1.0-py3.6-win-amd64.egg. However, the python import (see above) fails with

ImportError: cannot import name '_mymodule'

It should be noted that under Linux this approach with the package works perfectly fine.

Edit: The __init__.py is empty because this is sufficient to build a package. I am not sure, however, what belongs in there. Do I have to give a path to certain components?

carlosvalderrama
  • 465
  • 1
  • 6
  • 22
  • Apparently, the package was installed as zip archive under Windows (in extracted form under Linux, though). Using pip install . instead of calling setup.py directly lead to success (thanks to [this answer](https://stackoverflow.com/a/33791008/9450461)). – carlosvalderrama Nov 11 '19 at 20:21

0 Answers0