简体   繁体   中英

Registering VCS root in PyCharm from within virtual environment?

I have checked out my modules in my django project with the -e, --editable path/url option in pip, and the .git roots have been installed in my .env/src/{EGG} folder.

But unfortunately PyCharm doesn't detect them as a separate VCS root, and my code changes cannot be committed to the repository checked out inside my modules.

How do I register the VCS roots, preferably automatically because there are a lot of components our project depends on.

I have found out that if I open up one by one in pycharm by selecting show hidden files and folders, I can manually add them. But I would prefer it to be done automatically.

Ok since no one has answered my question, I wrote this simple script that I added in my path folder in utils.

So when I execute this in my project root folder, the VCS roots get added in pycharm upon restart.

https://github.com/virogenesis/pycharm_vcsrootgenerator

If these modules are supposed to be part of your project (PyCharm then detects VCS roots automatically) then you should check them out into your project directory and not into .env/src .
You can do it in the following ways:

  • Use --src <dir> option of pip install command, when <dir> according to pip's documentation is

Directory to check out editable projects into. The default in a virtualenv is <venv path>/src . The default for global installs is <current dir>/src .

  • Check them out with git and then install into virtualenv with pip install --editable /path/to/modules (it might be best to invoke pip from within the directory with setup.py file as often setup.py files are not prepared to be run from different directory)

If you have some external (third party) Python packages used in the project which you would like to have easy way to modify and provide patches upstream, it might be good idea to check them out in the same way to some specific ( external , deps , thirdparty are likely names) directory of your project in the same way. Remember to ignore this specific directory in the configuration of yours project's VCS.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM