Alter PyCharm's PYTHONPATH per project based on a script

Hello folks,

I am wondering if it's possible to alter the paths that PyCharm uses to build its code completion database per project based on a custom script. Let's say that my project depends on a large number of python packages that are not installed in the usual places. The way my project can find all these modules is to parse a special manifest xml file that list all dependencies, then this list gets read and sys.path variable is altered to include paths to all dependent packages. The question is then if it's possible to somehow tell PyCharm about this new sys.path. Would I need to setup an extrenal tool (e.g. a script), or does it have to be a proper plugin, or maybe there's some other way.

Thanks!

3 comments
Comment actions Permalink

Hello akub,

You can use the "Add Content Root" action to add the folders with the external

packages to your project.

I am wondering if it's possible to alter the paths that PyCharm uses

to build its code completion database per project based on a custom

script. Let's say that my project depends on a large number of python

packages that are not installed in the usual places. The way my

project can find all these modules is to parse a special manifest xml

file that list all dependencies, then this list gets read and sys.path

variable is altered to include paths to all dependent packages. The

question is then if it's possible to somehow tell PyCharm about this

new sys.path. Would I need to setup an extrenal tool (e.g. a script),

or does it have to be a proper plugin, or maybe there's some other

way.

--

Dmitry Jemerov

Development Lead

JetBrains, Inc.

http://www.jetbrains.com/

"Develop with Pleasure!"

0
Comment actions Permalink

Dmitry,

The problem with adding these things manually is that my immediate dependencies have their own set of dependencies which can have a bunch ot their own, etc. And while it's easy for me to add/change dependencies for my package using manifest, each time I do that I would need to hunt down all the paths again and add them manually. That is why an automated solution is preferred, even if I have trigger it manually each time my packages manifest changes. Is that something that can be done currently not from gui but from a script?

Thanks!

0
Comment actions Permalink

Hello akub,

You can write a plugin that will configure the dependencies automatically

for you. Note that the plugins for PyCharm need to be written in Java.

The problem with adding these things manually is that my immediate

dependencies have their own set of dependencies which can have a bunch

ot their own, etc. And while it's easy for me to add/change

dependencies for my package using manifest, each time I do that I

would need to hunt down all the paths again and add them manually.

That is why an automated solution is preferred, even if I have trigger

it manually each time my packages manifest changes. Is that something

that can be done currently not from gui but from a script?

--

Dmitry Jemerov

Development Lead

JetBrains, Inc.

http://www.jetbrains.com/

"Develop with Pleasure!"

0

Please sign in to leave a comment.