Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No SCons symbols in SConstruct to enable IDE's etc to better handle SConstructs/SConscript. #4661

Closed
marcinn opened this issue Dec 13, 2024 · 8 comments

Comments

@marcinn
Copy link

marcinn commented Dec 13, 2024

Nothing from scons is imported in SConstruct file. This makes SConstruct an invalid python script. This is not a python script. Linters does not work. Also nobody knows which object / class comes from.

Also there is sys.path mangling and globals magic, which makes this package incompatible with all python tools (not mentioning good practices in python programming).

@mwichmann
Copy link
Collaborator

And the point is?

SCons is a Python program, whose operation is dictated by the instructions, using Python as the programming language in an SConstruct file. That's not the same as an SConstruct itself being a complete Python program.

Yes, there's a lot of fiddling, some of us think that in the context of how Python code is written in 2024 it's overly "clever" and makes some things harder to understand (certainly if you're working on SCons code itself). I will jokingly say that "your list is incomplete" - there's a lot of magic that happens with factory functions of the same name as the class you think you're directly instantiating, and places where methods are renamed in flight, and other stuff that makes things hard to trace - in the SCons code. Those don't actually make it harder to write a build system in SCons, though (in my opinion), they're things that happen behind the scenes.

Would love to have some help getting IDEs to understand the "SCons API" so that bringing up your SConstruct isn't just a screenfull of squiggly lines. There are some contributors chipping away at that but there's clearly much more that could happen.

@marcinn
Copy link
Author

marcinn commented Dec 13, 2024

And the point is?

The point is to do it right. Refactoring can be difficult, but it's worth it if Scons is going to be a future-proof tool.

That's not the same as an SConstruct itself being a complete Python program.

I just see. Unfortunately you can't have your cake and eat it. All tooling won't work due to outdated hacks under the hood.

"your list is incomplete" - there's a lot of magic that happens with factory functions

I saw some. That's why I said what I said.

@mwichmann
Copy link
Collaborator

If you're determined to have some checker tools work on your project, you can attempt something like this in your SConstruct:

from typing import TYPE_CHECKING
...
if TYPE_CHECKING:
    from SCons.Script import *

That's obviously specific to the type checking context, and not something I've personally tested, but might be of some use.

@bdbaddog bdbaddog changed the title Nothing is imported in SConsctuct No SCons symbols in SConstruct to enable IDE's etc to better handle SConstructs/SConscript. Dec 13, 2024
@bdbaddog
Copy link
Contributor

Here's a related enhancement request:
#3210

@marcinn
Copy link
Author

marcinn commented Dec 13, 2024

I saw this. The whole thing is about making SConstruct a real python script, as stated in the docs. All tools will work with it, not only rare IDEs.

Explicite imports should remove globals magic, and importlib should solve importing other SConstruct files as modules (see import_from_path https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly). Both changes will make Scons user- and stack friendly.

@bdbaddog
Copy link
Contributor

There's nothing preventing you from using explicit imports in your SConscripts.
That said there's a large number of existing builds using SCons without them, so requiring them would break ALL existing builds.

SConscript() does far more than just import.
We're not going to make any such change.

Enabling better interaction with IDE's however has been a goal for a long time.
Closing this bug, since the achievable part of it is contained in the other linked github issue.

Also note, you've ignored the bug template, which requests that you bring any such queries to the users mailing list, discord server, or even a github discussion, before creating an issue.

@bdbaddog bdbaddog closed this as not planned Won't fix, can't repro, duplicate, stale Dec 13, 2024
@marcinn
Copy link
Author

marcinn commented Dec 13, 2024

Enabling better interaction with IDE's however has been a goal for a long time.

This is not about IDE plugins. You are preventing from using all tools, incl. linters.

There's nothing preventing you from using explicit imports in your SConscripts.

Have you tried this? I tried. It does not work because of false negatives. This is not a solution. Even if I add imports, Scons is still changing sys.paths and not using importlib capabilities. This will never work, because there are ugly, old hacks under the hood, which causes a lot of troubles.

That said there's a large number of existing builds using SCons without them, so requiring them would break ALL existing builds.

I am aware of that. They must just die (read: be upgraded) in few years. That's why I said about the future. There is no other way. And we are talking just about imports, not changing the syntax.

Also note, you've ignored the bug template

I'm sorry, but the scale of the problem is beyond the scope of the bug report template.

@SCons SCons locked as resolved and limited conversation to collaborators Dec 13, 2024
@bdbaddog
Copy link
Contributor

That's why we ask you to bring such to a discussion medium and NOT just file an issue first.

I've closed with bug with won't fix.
Sorry we won't be able to make the extensive changes to SCons you feel would be beneficial to your usage.
Locking this issue, if you feel the need to discuss further, please open a discussion.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants