Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyCharm include and modify External library in project

I have an issue where I am developing a Django project which includes other libraries we are also developing.

My current structure is as follows:

  • Main Project
    • App1
    • App2

  • Libraries
    • Library 1
    • Library 2

All libraries have their own setup scripts and are in separate git repositories, and we are adding them in PyCharm in the PYTHONPATH, and referencing them simply by their name. Which works good, but they are not in my current project, which means no re-factoring ( renaming, moving etc... ) and I have to use External search to find my class from the libraries.

How do I set some libraries as project related to make them view-able and refactorable like we do on the currently set project.

like image 223
Bojan Jovanovic Avatar asked Feb 23 '14 16:02

Bojan Jovanovic


2 Answers

Well, you can add other directories as content roots:

enter image description here

Then simply mark the directory as a source root:

enter image description here

This should allow you to refactor, rename and do all the things you've wanted to do.

like image 166
Games Brainiac Avatar answered Sep 28 '22 23:09

Games Brainiac


Another option would be to place libraries into separate project (or go even further and place each library in its own project) and then open this project/these projects side-by-side with the main project. This way you have clear separation between the main project and libraries used. This comes handy when you work on another project using some of the same libraries as then you only need to open already existing project containing libraries and you are done.

like image 29
Piotr Dobrogost Avatar answered Sep 28 '22 23:09

Piotr Dobrogost