Skip to content

Commit f449a33

Browse files
committed
Further reword {Append,Prepend}ENVPath entries [skip appveyor]
Signed-off-by: Mats Wichmann <[email protected]>
1 parent 5af9be1 commit f449a33

File tree

3 files changed

+123
-83
lines changed

3 files changed

+123
-83
lines changed

SCons/Environment.xml

Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -778,33 +778,38 @@ See also &f-link-env-AppendUnique;,
778778
</arguments>
779779
<summary>
780780
<para>
781-
Append one or more path prefixes to an entry in a dictionary-valued
782-
&consvar; in <parameter>env</parameter>.
783-
Optional <parameter>envname</parameter> specifies the
784-
the &consvar; to update;
781+
Append directory paths from
782+
<parameter>newpath</parameter> to
783+
a search-path entry <parameter>name</parameter>
784+
in &consvar; <parameter>envname</parameter>
785+
in the current enviromment (<parameter>env</parameter>).
786+
If <parameter>envname</parameter> is not given,
785787
the default is <literal>"ENV"</literal>
786788
(see &cv-link-ENV;).
787-
The required <parameter>name</parameter> parameter
788-
is the dictionary entry to update.
789-
The prefix(es) to add,
790-
given by <parameter>newpath</parameter>,
789+
<parameter>envname</parameter> is expected
790+
to refer to a dictionary-like object;
791+
if it does not exist in <parameter>env</parameter>
792+
it will be created as an initially empty dict.
793+
<parameter>newpath</parameter>
791794
may be specified as a string,
792795
a directory node, or a list of strings.
793-
If a string, it may contain multiple prefixes separated
796+
If a string, it may contain multiple paths separated
794797
by the system path separator
795798
(<systemitem>os.pathsep</systemitem>),
796799
or, if specified, by the value of <parameter>sep</parameter>.
797800
Top-relative path strings (starting with <literal>#</literal>) are recognized.
801+
The type of the existing value
802+
of <parameter>name</parameter> is preserved.
798803
</para>
804+
799805
<para>
800-
Path prefixes will only appear once.
801-
Duplicate prefixes in <parameter>newpath</parameter> are removed,
806+
Paths will only appear once.
807+
Duplicate paths in <parameter>newpath</parameter> are removed,
802808
preserving the last occurrence to maintain path order.
803-
If <parameter>delete_existing</parameter> is true,
804-
existing duplicates are removed before appending;
805-
otherwise, new duplicates are skipped
806-
(the default is false).
807-
Prefixes are normalized for comparisons to avoid problems of
809+
If <parameter>delete_existing</parameter> is true (the default),
810+
existing duplicates are removed before appending,
811+
otherwise, new duplicates are skipped.
812+
Paths are normalized during comparisons to avoid problems of
808813
"same path, spelled differently",
809814
but retain their original form in the result.
810815
</para>
@@ -2872,33 +2877,38 @@ and &f-link-env-PrependUnique;.
28722877
</arguments>
28732878
<summary>
28742879
<para>
2875-
Prepend one or more path prefixes to an entry in a dictionary-valued
2876-
&consvar; in <parameter>env</parameter>.
2877-
Optional <parameter>envname</parameter> specifies the
2878-
the &consvar; to update;
2880+
Prepend directory paths from
2881+
<parameter>newpath</parameter> to
2882+
a search-path entry <parameter>name</parameter>
2883+
in &consvar; <parameter>envname</parameter>
2884+
in the current enviromment (<parameter>env</parameter>).
2885+
If <parameter>envname</parameter> is not given,
28792886
the default is <literal>"ENV"</literal>
28802887
(see &cv-link-ENV;).
2881-
The required <parameter>name</parameter> parameter
2882-
is the dictionary entry to update.
2883-
The prefix(es) to insert,
2884-
given by <parameter>newpath</parameter>,
2888+
<parameter>envname</parameter> is expected
2889+
to refer to a dictionary-like object;
2890+
if it does not exist in <parameter>env</parameter>
2891+
it will be created as an initially empty dict.
2892+
<parameter>newpath</parameter>
28852893
may be specified as a string,
28862894
a directory node, or a list of strings.
2887-
If a string, it may contain multiple prefixes separated
2895+
If a string, it may contain multiple paths separated
28882896
by the system path separator
28892897
(<systemitem>os.pathsep</systemitem>),
28902898
or, if specified, by the value of <parameter>sep</parameter>.
28912899
Top-relative path strings (starting with <literal>#</literal>) are recognized.
2900+
The type of the existing value
2901+
of <parameter>name</parameter> is preserved.
28922902
</para>
2903+
28932904
<para>
2894-
Path prefixes will only appear once.
2895-
Duplicate prefixes in <parameter>newpath</parameter> are removed,
2896-
preserving the last occurrence to maintain path order.
2897-
If <parameter>delete_existing</parameter> is true,
2898-
existing duplicates are removed before prepending;
2899-
otherwise, new duplicates are skipped
2900-
(the default is false).
2901-
Prefixes are normalized for comparisons to avoid problems of
2905+
Paths will only appear once.
2906+
Duplicate paths in <parameter>newpath</parameter> are removed,
2907+
preserving the first occurrence to maintain path order.
2908+
If <parameter>delete_existing</parameter> is true (the default),
2909+
existing duplicates are removed before prepending,
2910+
otherwise, new duplicates are skipped.
2911+
Paths are normalized during comparisons to avoid problems of
29022912
"same path, spelled differently",
29032913
but retain their original form in the result.
29042914
</para>

SCons/Util/envs.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ def PrependPath(
3030
3131
Will only add any particular path once (leaving the first one it
3232
encounters and ignoring the rest, to preserve path order), and will
33-
:mod:`os.path.normpath` and :mod:`os.path.normcase` all paths to help
34-
assure this. This can also handle the case where *oldpath*
35-
is a list instead of a string, in which case a list will be returned
36-
instead of a string. For example:
33+
:mod:`os.path.normpath` and :mod:`os.path.normcase` all paths
34+
for comparisons to help assure this. *oldpath* may be a list
35+
instead of a string, in which case a list is returned.
36+
37+
Example:
3738
3839
>>> p = PrependPath("/foo/bar:/foo", "/biz/boom:/foo")
3940
>>> print(p)
@@ -120,10 +121,11 @@ def AppendPath(
120121
121122
Will only add any particular path once (leaving the last one it
122123
encounters and ignoring the rest, to preserve path order), and will
123-
:mod:`os.path.normpath` and :mod:`os.path.normcase` all paths to help
124-
assure this. This can also handle the case where *oldpath*
125-
is a list instead of a string, in which case a list will be returned
126-
instead of a string. For example:
124+
:mod:`os.path.normpath` and :mod:`os.path.normcase` all paths
125+
for comparisons to help assure this. *oldpath* may be a list
126+
instead of a string, in which case a list is returned.
127+
128+
Example:
127129
128130
>>> p = AppendPath("/foo/bar:/foo", "/biz/boom:/foo")
129131
>>> print(p)

doc/generated/functions.gen

Lines changed: 70 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -707,26 +707,40 @@ See also &f-link-env-AppendUnique;,
707707
<varlistentry id="f-AppendENVPath">
708708
<term><replaceable>env</replaceable>.<methodname>AppendENVPath</methodname>(<parameter>name, newpath, [envname, sep, delete_existing=False]</parameter>)</term>
709709
<listitem><para>
710-
Append path elements specified by <parameter>newpath</parameter>
711-
to the given search path string or list <parameter>name</parameter>
712-
in mapping <parameter>envname</parameter> in the &consenv;.
713-
Supplying <parameter>envname</parameter> is optional:
714-
the default is the execution environment &cv-link-ENV;.
715-
Optional <parameter>sep</parameter> is used as the search path separator,
716-
the default is the platform's separator (<systemitem>os.pathsep</systemitem>).
717-
A path element will only appear once.
718-
Any duplicates in <parameter>newpath</parameter> are dropped,
719-
keeping the last appearing (to preserve path order).
720-
If <parameter>delete_existing</parameter>
721-
is <constant>False</constant> (the default)
722-
any addition duplicating an existing path element is ignored;
723-
if <parameter>delete_existing</parameter>
724-
is <constant>True</constant> the existing value will
725-
be dropped and the path element will be added at the end.
726-
To help maintain uniqueness all paths are normalized (using
727-
<systemitem>os.path.normpath</systemitem>
728-
and
729-
<systemitem>os.path.normcase</systemitem>).
710+
Append directory paths from
711+
<parameter>newpath</parameter> to
712+
a search-path entry <parameter>name</parameter>
713+
in &consvar; <parameter>envname</parameter>
714+
in the current enviromment (<parameter>env</parameter>).
715+
If <parameter>envname</parameter> is not given,
716+
the default is <literal>"ENV"</literal>
717+
(see &cv-link-ENV;).
718+
<parameter>envname</parameter> is expected
719+
to refer to a dictionary-like object;
720+
if it does not exist in <parameter>env</parameter>
721+
it will be created as an initially empty dict.
722+
<parameter>newpath</parameter>
723+
may be specified as a string,
724+
a directory node, or a list of strings.
725+
If a string, it may contain multiple paths separated
726+
by the system path separator
727+
(<systemitem>os.pathsep</systemitem>),
728+
or, if specified, by the value of <parameter>sep</parameter>.
729+
Top-relative path strings (starting with <literal>#</literal>) are recognized.
730+
The type of the existing value
731+
of <parameter>name</parameter> is preserved.
732+
</para>
733+
734+
<para>
735+
Paths will only appear once.
736+
Duplicate paths in <parameter>newpath</parameter> are removed,
737+
preserving the last occurrence to maintain path order.
738+
If <parameter>delete_existing</parameter> is true (the default),
739+
existing duplicates are removed before appending,
740+
otherwise, new duplicates are skipped.
741+
Paths are normalized during comparisons to avoid problems of
742+
"same path, spelled differently",
743+
but retain their original form in the result.
730744
</para>
731745

732746
<para>
@@ -1031,8 +1045,8 @@ env4 = env.Clone(tools=['msvc', MyTool])
10311045
The
10321046
<parameter>parse_flags</parameter>
10331047
keyword argument is also recognized, to allow merging command-line
1034-
style arguments into the appropriate construction
1035-
variables (see &f-link-env-MergeFlags;).
1048+
style arguments into the appropriate &consvars;
1049+
(see &f-link-env-MergeFlags;).
10361050
</para>
10371051

10381052
<example_commands>
@@ -3381,26 +3395,40 @@ and &f-link-env-PrependUnique;.
33813395
<varlistentry id="f-PrependENVPath">
33823396
<term><replaceable>env</replaceable>.<methodname>PrependENVPath</methodname>(<parameter>name, newpath, [envname, sep, delete_existing=True]</parameter>)</term>
33833397
<listitem><para>
3384-
Prepend path elements specified by <parameter>newpath</parameter>
3385-
to the given search path string or list <parameter>name</parameter>
3386-
in mapping <parameter>envname</parameter> in the &consenv;.
3387-
Supplying <parameter>envname</parameter> is optional:
3388-
the default is the execution environment &cv-link-ENV;.
3389-
Optional <parameter>sep</parameter> is used as the search path separator,
3390-
the default is the platform's separator (<systemitem>os.pathsep</systemitem>).
3391-
A path element will only appear once.
3392-
Any duplicates in <parameter>newpath</parameter> are dropped,
3393-
keeping the first appearing (to preserve path order).
3394-
If <parameter>delete_existing</parameter>
3395-
is <constant>False</constant>
3396-
any addition duplicating an existing path element is ignored;
3397-
if <parameter>delete_existing</parameter>
3398-
is <constant>True</constant> (the default) the existing value will
3399-
be dropped and the path element will be inserted at the beginning.
3400-
To help maintain uniqueness all paths are normalized (using
3401-
<systemitem>os.path.normpath</systemitem>
3402-
and
3403-
<systemitem>os.path.normcase</systemitem>).
3398+
Prepend directory paths from
3399+
<parameter>newpath</parameter> to
3400+
a search-path entry <parameter>name</parameter>
3401+
in &consvar; <parameter>envname</parameter>
3402+
in the current enviromment (<parameter>env</parameter>).
3403+
If <parameter>envname</parameter> is not given,
3404+
the default is <literal>"ENV"</literal>
3405+
(see &cv-link-ENV;).
3406+
<parameter>envname</parameter> is expected
3407+
to refer to a dictionary-like object;
3408+
if it does not exist in <parameter>env</parameter>
3409+
it will be created as an initially empty dict.
3410+
<parameter>newpath</parameter>
3411+
may be specified as a string,
3412+
a directory node, or a list of strings.
3413+
If a string, it may contain multiple paths separated
3414+
by the system path separator
3415+
(<systemitem>os.pathsep</systemitem>),
3416+
or, if specified, by the value of <parameter>sep</parameter>.
3417+
Top-relative path strings (starting with <literal>#</literal>) are recognized.
3418+
The type of the existing value
3419+
of <parameter>name</parameter> is preserved.
3420+
</para>
3421+
3422+
<para>
3423+
Paths will only appear once.
3424+
Duplicate paths in <parameter>newpath</parameter> are removed,
3425+
preserving the first occurrence to maintain path order.
3426+
If <parameter>delete_existing</parameter> is true (the default),
3427+
existing duplicates are removed before prepending,
3428+
otherwise, new duplicates are skipped.
3429+
Paths are normalized during comparisons to avoid problems of
3430+
"same path, spelled differently",
3431+
but retain their original form in the result.
34043432
</para>
34053433

34063434
<para>

0 commit comments

Comments
 (0)