One content source above another in the directory tree

My project is stored in a certain directory which I'll call .../programs/mine, and its source files are in .../programs/mine/src. It uses some common modules that are stored in .../programs. This poses two problems. First: importing the modules so that the program can call them. Second: telling PyCharm that .../programs is a content root so that it won't flag every import statement as an error.

I know how to solve the first problem, but the second one baffles me. When I try to declare .../programs as a content root, PyCharm displays the message:

Content root being added ".../programs" dominates existing content root "...programs/mine/src". Content roots should not intersect.

I'm puzzled by two things. First, what is the reason for this limitation? If Python searched the directory tree below a directory in the Pythonpath it would make some sense (although it would not be necessary, and I could argue that it prevented the programmer from doing some useful things). Python doesn't work that way, though, and I can think of no reason why PyCharm should.

Second, how can I make PyCharm work with my application? Moving the modules out of .../programs is not an option; they were here before I was, and a dozen or more programs depend on them. But I'm not pleased by the idea of just putting up with a bunch of false error messages because my IDE is too inflexible to accommodate to the environment it runs in.

1 comment

I looked at this a bit closer and found that if I point the content root to .../programs instead of .../programs/mine/src, it finds all of the scripts -- mine and the common ones -- just fine. This is far from a good solution, though. It means that the project view shows the totality of my team's work, of which my project -- the only part I want to see -- is just a tiny piece. Navigating the project view is cumbersome, and it takes an irritatingly long time to collapse, expand, etc.

I want to tell PyCharm this: my project's content root is .../programs/mine/src, but it loads modules from .../programs too. Or, alternatively: my project's content root is .../programs, but .../programs/mine/src is the only part I want the project view to show. Is there a way to do either of those things?

0

Please sign in to leave a comment.