Skip to content

Commit 7313377

Browse files
authored
Merge pull request SCons#4576 from mwichmann/maint/variables-export
Restore usage of "from SCons.Variables import *`
2 parents e4854a1 + 94874ae commit 7313377

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed

CHANGES.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
2929
- Add a timeout to test/ninja/default_targets.py - it's gotten stuck on
3030
the GitHub Windows action and taken the run to the full six hour timeout.
3131
Usually runs in a few second, so set the timeout to 3min (120).
32+
- SCons 4.8.0 added an `__all__` specifier at the top of the Variables
33+
module (`Variables/__init__.py`) to control what is made available in
34+
a star import. However, there was existing usage of doing
35+
`from SCons.Variables import *` which expected the variable *types*
36+
to be avaiable. While we never advertised this usage, there's no
37+
real reason it shouldn't keep working - add to `__all__`.
3238
- Switch SCons build to use setuptools' supported version fetcher from
3339
the old homegrown one.
3440

RELEASE.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ CHANGED/ENHANCED EXISTING FUNCTIONALITY
3939
FIXES
4040
-----
4141

42-
- List fixes of outright bugs
42+
- SCons 4.8.0 added an `__all__` specifier at the top of the Variables
43+
module (`Variables/__init__.py`) to control what is made available in
44+
a star import. However, there was existing usage of doing
45+
`from SCons.Variables import *` which expected the variable *types*
46+
to be avaiable. `BoolVariable`, `EnumVariable`, `ListVariable`,
47+
`PackageVariable` and `PathVariable` are added to `__all__`,
48+
so this form of import should now work again.
4349

4450
IMPROVEMENTS
4551
------------

SCons/Variables/VariablesTests.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import SCons.Subst
3030
import SCons.Warnings
3131
from SCons.Util import cmp
32+
from SCons.Variables import *
3233

3334

3435
class Environment:
@@ -723,6 +724,27 @@ def test_AddOptionWithAliasUpdatesUnknown(self) -> None:
723724
assert len(r) == 0, r
724725
assert env['ADDEDLATER'] == 'added', env['ADDEDLATER']
725726

727+
def test_VariableTypesImportVisibility(self) -> None:
728+
"""Test that 'from SCons.Variables import *' will import all types of SCons defined Variables
729+
"""
730+
731+
try:
732+
x = BoolVariable('test', 'test option help', False)
733+
y = EnumVariable('test', 'test option help', 0,
734+
['one', 'two', 'three'],
735+
{})
736+
z = ListVariable('test', 'test option help', 'all',
737+
['one', 'two', 'three'])
738+
o = PackageVariable('test', 'test build variable help', '/default/path')
739+
p = PathVariable('test',
740+
'test build variable help',
741+
'/default/path')
742+
except Exception as e:
743+
self.fail(f"Could not import all known Variable types: {e}")
744+
745+
746+
747+
726748

727749
if __name__ == "__main__":
728750
unittest.main()

SCons/Variables/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@
4343
__all__ = [
4444
"Variable",
4545
"Variables",
46+
"BoolVariable",
47+
"EnumVariable",
48+
"ListVariable",
49+
"PackageVariable",
50+
"PathVariable",
4651
]
4752

4853
class Variable:

0 commit comments

Comments
 (0)