Autogenerated PyCharm files and virtual environments
I'm working on a plugin for setuptools that autogenerates .idea files for PyCharm projects. My code is based off of a plugin that is provided by PyBuilder (https://github.com/pybuilder/pybuilder/blob/master/src/main/python/pybuilder/plugins/python/pycharm_plugin.py).
The workflow that I'm trying to achieve is this:
$ git clone project
$ cd project
$ python setup.py pycharm
$ charm .
And then be in a project that is ready to be worked on. While I can get most of this working (correctly picking up my source, test, and excluded directories), I'm having trouble getting PyCharm to import my virtual environment. If I place this line in my .idea/project.iml file:
<orderEntry type="jdk" jdkName="Python 2.7.13 virtualenv at /Users/ewhauser/working/project/.tox/py27" jdkType="Python SDK" />
PyCharm won't recognize it as a venv unless it's already be imported as one before via the GUI. Is there any way to do this programmatically? Alternative way of achieving that workflow?
Thanks.
Please sign in to leave a comment.
jdkName is a key in <PyCharm settings>/options/jdk.table.xml, see https://www.jetbrains.com/help/pycharm/2016.3/project-and-ide-settings.html for the exact location.
You have to either generate an entry in jdk.table.xml as well, or put a virtualenv directory directly inside your project. PyCharm automatically detects a virtualenv inside a project upon opening a directory with the project so you don't have to edit any settings.
Hey Eric, did you find a solution for this? I got this working for a few time but I think last PyCharm update broke it (PyCharm 2019.3.4 (Professional Edition) #PY-193.6911.25).
Maybe I was following an approach not completely correct I know that way isn't available any more.
(sorry for bringing back such an old post)