Setting sources root upon clone / first use of a project


For some of my projects, I would like to be able get PyCharm to automatically add certain subfolders as 'Sources Root'. This is only required once, basically right after someone clones the project through Git and PyCharm first opens the project.

What is the best way to have PyCharm pick up on this without causing undesirable side effects?

I noticed that PyCharm stores the preference in .idea/{project}.iml, but modifying this file externally doesn't seem like a good idea and just including the whole file in the git repository causes other settings stored there to get caught up in the repository as well.

Is there some other way to mark folders as sources root that would cause PyCharm to pick up on this?

The reason for wanting this is to allow separation of source into various sub-folders, instead of requiring everything to sit at root level, while still allowing PyCharm to do all of its wonderful checking without requiring manual setup from the user.

My current solution is to instruct users of PyCharm to mark the folders manually in the - not ideal.


Please sign in to leave a comment.