Project with both Arduino C/C++ and python scripts. which is best: Pycharm vs CLion?
I have a project that combines both C/C++ (in an Arduino) and Python scripts.
This project is going to start off simple and, if successful, will likely get much more complicated:
- multiple microcontrollers STM32 and a couple of others on the C/C++ side. Maybe Raspberry Pi?
- multi-platform on the Python side i.e. initially Ubuntu, then macOS and Windows
Which tool do you recommend: PyCharm or CLion?
If you choose Clion, Cmake based or Makefile based?
请先登录再写评论。
Hi, similar problem here – did you ever come up with a good solution?
https://intellij-support.jetbrains.com/hc/en-us/community/posts/28458972664978-Use-both-CLion-and-PyCharm
I did, at least for my situation. I created a python module (called pyalamake) that can be used to generate a Makefile. Because it's python it's cross-platform and so runs on Ubuntu and macOS. Working on getting it working on MSYS2/Windows still, but that's making progress too.
Because it is Makefile, it can run the avr-g++ for Arduino, and run the g++ for gtest using mocked Arduino code. And I've also got it sorta, kinda working for SWIG to with ruby and python (node doesn't work, and ruby doesn't work in macos, still trying it out on MSYS2). If you look at the tests I have in the pyalamake project it runs C, C++, Arduino, Gtest, SWIG, and you can even gen manual makefile lines if you want. (see gen.py in the projects for examples of how to define each of these)
Note, I would have preferred to use Ninja but Clion can only use Makefile or cmake.
Anyway, all of this runs okay under Clion for a bunch of Arduino and C/C++ projects and it seems to be okay under PyCharm as well since I use that for developing the module.
See https://arrizza.com/pyalamake.html
It is perfect? No idea. Is it bug-free, as it as I can, but no guarantees. Is there a better tool out there? Couldn't find out that was currently maintained. All I can say is that it seems to be okay for about the currently working 7 or so Arduino projects and 10 or so C/C++ projects I have on Ubuntu and macOS.
Thanks so much for getting back!
That's very cool – and solves a deeper set of problems than I'm facing at the moment!
I spent the day figuring out a kludge that seems to accomplish what I need. A PyCharm project encompasses both C/C++ and Python code:
(main) root@C.24489632:/workspace/mixed_project$ tree
.
├── C
│ ├── C4.c
│ ├── C4.cpp
│ ├── C4.hpp
│ ├── CMakeLists.txt
│ ├── bindings
│ │ ├── C4_bindings.cpp
│ │ └── xoshiro256_bindings.cpp
│ ├── cmake-build-debugremote
│ ├── xoshiro256.c
│ └── xoshiro256.h
├── CMakeLists.txt
├── lib
│ ├── C4_engine.pyi
│ ├── C4_engine.so
│ ├── libC4.so
│ ├── libxoshiro256_c.so
│ ├── xoshiro256.pyi
│ └── xoshiro256.so
├── python
│ ├── C4
│ │ ├── C4.ipynb
│ │ ├── C4.md
│ │ ├── C4.py
│ │ └── __init__.py
│ ├── UCT.py
│ ├── __init__.py
│ ├── examples
│ │ └── benchmark.py
│ ├── paths.py
│ ├── tests
│ └── util
│ ├── __init__.py
│ └── util.py
└── requirements.txt
A CLion project points at only the C directory (a subset of the PyCharm project). I can edit the C/C++ files in either IDE (though CLion has much better tools). Git is managed through PyCharm (which sees any changes to the C files).
CLion can handle building through remote toolchains over SSH. CMakeLists.txt copies the .so libraries to the /lib directory (external to the CLion project itself). PyCharm can work with a remote interpreter via SSH, accessing the libraries. I do have to manually pull the .pyi files down from the remote to my local machine so that PyCharm can do its inspections, however. We'll see how it works out in the long run – and how manageable it is to switch back and forth between the IDEs for different purposes!