[Scons-users] Recommendation on PyCharm config when working with SCons
Mats Wichmann
mats at wichmann.us
Mon Apr 8 11:06:29 EDT 2019
On 4/8/19 3:23 AM, Arndt Pauschardt wrote:
> Hi, *
> editing, refactoring, extending, ... SConscripts is best done in a
> Python IDE ... I would assume that most of you would agree if working on
> reasonably-sized build systems.
> When doing Python-work, I use PyCharm, but I haven't really managed to
> set it up properly to work with SCons.
>
> I have lots of "unresolved references" when doing things like "from
> site_config import bla" or when "SConscript('blab', exports=['blub'].
> As a result, name completion or any other helpful feature of an IDE does
> not really work.
>
> I have been playing around with PyCharm project settings, telling it to
> handle SConscripts as Python source is obviously easy, but then it
> becomes fuzzy - playing around with the "project structure" in PyCharm
> does not really make a difference.
> The selected python interpreter is aware of SCons, it even allows to
> upgrade it, so on this side it looks ok.
>
> Does anyone of you have recommendations and/or hints how to teach
> PyCharm to integrate better with SCons? Any other IDE which does this
> out of the box?
>
> Thx
> Arndt
I've thought some about this, and it's received some discussion on the
list and elsewhere, and it's not actually simple.
There's a PyCharm feature request on this that you can vote on:
https://youtrack.jetbrains.com/issue/PY-10591
be warned, however, I've heard informally that these get no attention
until the number of votes in favor becomes very large (like,
in-the-thousands large). 13 votes is unlikely to move the needle.
SCons isn't really a normal Python module - you don't import it in your
scripts, which is how things usually work - where the IDE can scan the
imported modules and figure out things about them (and will take
advantage of things like hinting, if the project provides it - scons
does not), and become relatively wise about the usage of that module.
Your SConscripts are scons's "configuration script", which are not
executed directly by the Python interpreter, but rather handled by SCons
in... ummm... interesting ways. If you are using the editor in PyCharm,
or Atom, or Visual Studio Code, or SublimeText, or other popular Python
editing systems that are more or less IDE, how is it going to figure out
the SCons API that your SConscript uses? As you've seen, the call
SConscript("blab") is just an undefined reference.
You can probably import SCons into your sconscript as a temporary
measure and see if it helps what you're after:
from SCons.Script import *
PyCharm and Visual Studio Code - the two I've looked at - have languages
for describing what you want to recognize. VS Code uses TextMate, which
PyCharm used to, but they have transitioned away for grammar extensions
(PyCharm extension themselves are written in Java, sadly) - I don't
remember what the new technology is called. But in glancing at plugin
development docs, it's hard to see where this goes, because, again,
things don't work in the same order as for a "normal" Python program.
More information about the Scons-users
mailing list