How to handle a mixed Python + C / C++ project?

Answered

Hi there!

 

It's quite common for Python projects to have some parts written in C/++. I couldn't find a C Plugin in PyCharm. Could someone please tell me how I should handle this?

Thanks!

14 comments

Hello, Felix! There is no C plugin for Pycharm but you can use CLion: https://www.jetbrains.com/clion/ with python plugin which supports all features of Pycharm Community.

0

I have this interest too. It would be very convenient if I could open the same project in Clion and Pycharm; is there any way to do this?  I am working on a Flask program with some C++ code using Boost.Python.

If I start a CLion project, Pycharm can't open it due to errors, and similarly if I start a Pycharm project then CLion cannot open it.

0

The problem is that PyCharm and CLion use the same project format , but have different module types, settings, etc. For example, PyCharm knows nothing about "CPP_MODULE" module type - it has no providers to handle it. So, it's recommended to avoid sharing the same project between PyCharm and CLion.
If you like to proceed with working on your project in both IDEs, I can suggest creating a separate project to be used in PyCharm: create a new empty PyCharm project anywhere and then add a folder where your python, etc. files are stored as an additional content root to it using Settings/Project/Directories, Add content root.

1

Hi Anna,

thanks for your answers!

> The problem is that PyCharm and CLion use the same project format, but have different module types, settings, etc. For example, PyCharm knows nothing about "CPP_MODULE" module type - it has no providers to handle it. So, it's recommended to avoid sharing the same project between PyCharm and CLion.

Couldn't this problem simply be solved if each IDE was using its own settings dir (.idea, .lion, .charm, etc.)? I already have the same problem with PyCharm and WebStorm in some projects. I think JetBrains should be more clear on this and either release an IDE which handles all languages nicely via plugins and/or release a dedicated IDE for each language in way that all of them can be used next to each other on the same projects.

I started with PHPStorm, then I needed support for other languages and switched to IntelliJ Idea Ultimate since I was told that's the IDE to go if you want to combine multiple languages. Besides having all the Java stuff (which I don't need), it worked kinda well (really loved it). But I always had the feeling that the plugins were a limited subset of what their dedicated IDE counterpart would offer. Actually there is a lot of confusion about this across the web:

https://stackoverflow.com/questions/13827214/can-intellij-idea-encapsulate-all-of-the-functionality-of-webstorm-and-phpstorm

https://www.reddit.com/r/Python/comments/3eoi3f/is_pycharm_different_from_intellij_idea_with_the/

https://stackoverflow.com/questions/3339399/comparison-of-intellij-python-plugin-or-pycharm

https://news.ycombinator.com/item?id=7868669

the list goes on...

I ended up switching from IDEA to PyCharm + WebStorm. Now I find out that in order to handle Python projects that contain some C/++ I have to use another IDE (Clion) which does not work in combination with PyCharm...So now I have to ditch PyCharm in favor of Clion and I'm back using the (limited?) Python plugin and losing the Python project creation features etc.. Will this ever have an end?

> If you like to proceed with working on your project in both IDEs, I can suggest creating a separate project to be used in PyCharm: create a new empty PyCharm project anywhere and then add a folder where your python, etc. files are stored as an additional content root to it using Settings/Project/Directories, Add content root.

This sounds odd to me.

How about releasing one single IDE that can be extended via language plugins and let the users pay for each main language plugin they need? That way all the confusion would be gone and the user wouldn't have to manage the same IDE 5 times. If this won't happen, then please provide a nice solution to make each IDE work next to each other without trouble. :-)

 

4

I would have to second the sentiment of one IDE to do multiple languages.

I would also recommend producing sample files like "Example: Python GUI with C++ back end," so that users can just do the work to build their programs and packages and not get caught up in the quirks on an OS, Compiler, and the tools.  That would do wonders for JetBrains business. It would empower designers to work unencumbered by the need to play with each of these tools or to have build up "seen it before" ~knowledge of the quirks. Imagine how much more productive we would be - and more important JetBrains would be to the future. :)

 

1

With the recent update to CLion (2018.3.3) even rudimentary Python plugin is not available so there is really no way. The other way -- Use C++ plugin in IntelliJ Ultimate -- doesn't work either. 

So there is really no way...

Is VS Code now the only game in town for combined C++/Python development?

 

 

0

Hi @Reg+jetbrains,

As Anna has already written, CLion supports Python via the PyCharm Community Edition for CLion bundled plugin. The feature set corresponds to the PyCharm IDE Community Edition and includes all the basic and essential Python editing features, as well as running, debugging and testing. Please find more information in the web-help (https://www.jetbrains.com/help/clion/python.html) and in our blog (https://blog.jetbrains.com/clion/2016/01/python-support-in-clion/).

Checked - the plugin is available in CLion 2018.3.3:

0

@Anna Falevskaya: It would be fantastic if we could get the functionality of CLion and PyCharm Professional in a single product.

0
Hi Wagner, could you please specify which Python features you miss in CLion? Also feel free to comment or upvote a feature request about making CLion available as IntelliJ plugin: https://youtrack.jetbrains.com/issue/CPP-4141.
0

@Jiri Fait: upvoted.

 

The PyCharm Professional features I miss the most in CLion are support for remote interpreters (via SSH, Vagrant, or Docker) and remote debugging.

0
Wagner, thanks a lot for the clarification! Please also upvote a feature request about remote debugging (https://youtrack.jetbrains.com/issue/CPP-5681) and about combining CLion and PyCharm Professional (https://youtrack.jetbrains.com/issue/CPP-13470).
0

So... the thing is, I have a license of Clion and Pycharm but I can't use both in the same project!? This is just nonsense...

I would like to open both IDEs in the same project without any problem.. but it seems this is a big deal for Jetbrains....

0

And the other things is, I am using CLion with WSL. How do I configure an python interpreter inside of CLion to use it? Because there is no such option, just in pycharm professional

0

Please sign in to leave a comment.