-
Notifications
You must be signed in to change notification settings - Fork 676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build binary distribution with c/c++ extensions #4848
Comments
I don't really have much real world experience developing native modules, so I might be giving you bad advice here, or just be misunderstanding the way you have things organized, but I'll give you some ideas... You could have PythonExtensionTest.c in the location that you want if you were not using VS ie your "usually" case. Either put the .vcxproj in the same directory of the .c file, or somewhere else that includes the .c file. Meaning, you don't have to stick to what VS gives you by default as far as solution/project folder organization. It is fine to have your .pyproj, .vcxproj both in the same folder, or to have projects include source files from a separate folder from where the project files are located. For .pyproj, there's a HomeFolder property that can be used to specify the root of all sources. It defaults to '.' but the "From Existing Python" new project wizard sets it to something else if you decide to create the .pyproj in a location different from the sources. C++ projects can also easily include sources from alternate folder. That, with changes to the C++ linker settings to control the output location would hopefully let you keep the .c file where you want it and have the binary created in the right place. As far as "build binary distribution" that is something that we always do from command line / build server, not the IDE. |
Thanks for the answer!
Yes, this is actually what we want to do. We have a build server environment, where we specify the project and target. Then Putting both the pyproj and vcxproj into the same folder might help, I need to check! |
I played around with this for a while now. I'm now able to build the projects by using multipe vcxproj files and some pre and postbuild rules to invoke python for packaging. Inside the python documentation, I also found the hint to look at the VS project for cpython: https://github.com/python/cpython/tree/3.7/PCbuild |
as in example from Microsoft Im trying to build c++ extension for python as python module |
@Smascer unfortunately, I do not have access to these files anymore and quite some time has passed since I played around with that... afair, I simply used the vxproj files from cpython as a reference. |
@reox thank you for a quick answer. I will take a look on cpython. |
I read #3599 on using an AfterBuild target to invoke
setup.py
but this does not solve my question about building binary distributions including some c/c++ extension.As I read in the documentation, you should setup a new project containing the C++ code.
Usually, I would write in the
setup.py
something likebut as
PythonExtensionTest
is now another project, this does not work.I tried to add
PythonExtensionTest
intopackages
but then python tells me, that this package does not exsist.script.py
btw contains a simple test:and I can run this program directly from VS2017, as
PythonExtensionTest.pyd
is build correctly, but is in the wrong path, as I would like to have it as a module underPythonTest
.Is there any way to build binary distributions which include c/c++ extensions directly from visual studio?
Or is the preferred way to use VS just for development and have
setup.py
along with the package? But how can I then usesetup.py
correctly, If I have the modules in separate folders?For example, specifiying the extensions like:
works, but I loose all the control over the build process now, which I gained using a VS Project.
thanks in advance!
The text was updated successfully, but these errors were encountered: