0

I am using PyBind11 to create a C++ Extension for Python. I am using visual studio and I am able to successfully create the pyd file.

I used the Visual Studio project properties and build using MSBuild to create the pyd file. Now I want to distribute this as a Python package. Like user can do Pip install CppExtension.

All the solution says to use setup.py to install the pyd file to any python environment. But the setup.py will compile the cpp files and create a pyd file and then install it.

But I already have a compiled pyd. Is there any way to directly install the pyd file into the user environment without compiling the CPP files.

I am looking for a Windows Solution.

Workaround: By adding the folder path to PYTHONPATH Environment variable I am able to import and use in other Python project. But I think this is more for a development environment.

samnaction
  • 1,194
  • 1
  • 17
  • 45
  • You could put your pyd file to a location that is on the `PYTHONPATH` ? This is easy to automate, for instance if you make an installer. – Christian Jul 05 '21 at 11:35
  • The PYTHONPATH is not present in the environment variable to begin with, I need to explicitly create them. Is that a valid approach? – samnaction Jul 05 '21 at 14:31
  • I'm not sure I understand, you don't have a python installed? – Christian Jul 05 '21 at 15:36
  • I have it installed, the PYTHONPATH variable in windows is not created by default. I need to add it manually. – samnaction Jul 06 '21 at 02:24
  • You don't necessarily have to create `PYTHONPATH`, you could put the `pyd` file to a default location (which you can get [running some python](https://stackoverflow.com/a/46071447/3283333)) but depending on how you get Python (conda, virtualenv, ...) the default does not work – Christian Jul 06 '21 at 05:18

0 Answers0