* [PATCH v1 1/1] binman: Do not pollute source tree when build with `make O=...`
@ 2021-11-30 18:42 Andy Shevchenko
2021-11-30 18:52 ` Tom Rini
0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2021-11-30 18:42 UTC (permalink / raw)
To: Andy Shevchenko, u-boot; +Cc: Simon Glass, Tom Rini
Importing libraries in Python caches the bytecode by default.
Since we run scripts in source tree it ignores the current directory
settings, which is $(srctree), and creates cache just in the middle
of the source tree. Move cache to the current directory.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
tools/binman/main.py | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tools/binman/main.py b/tools/binman/main.py
index 8c1e478d54ce..d5ab59948ec9 100755
--- a/tools/binman/main.py
+++ b/tools/binman/main.py
@@ -16,6 +16,13 @@ import sys
import traceback
import unittest
+#
+# Do not pollute source tree with cache files:
+# https://stackoverflow.com/a/60024195/2511795
+# https://bugs.python.org/issue33499
+#
+sys.pycache_prefix = os.path.relpath(os.path.dirname(sys.argv[0]), os.environ['srctree'])
+
# Bring in the patman and dtoc libraries (but don't override the first path
# in PYTHONPATH)
our_path = os.path.dirname(os.path.realpath(__file__))
--
2.33.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/1] binman: Do not pollute source tree when build with `make O=...`
2021-11-30 18:42 [PATCH v1 1/1] binman: Do not pollute source tree when build with `make O=...` Andy Shevchenko
@ 2021-11-30 18:52 ` Tom Rini
2021-11-30 18:58 ` Andy Shevchenko
0 siblings, 1 reply; 6+ messages in thread
From: Tom Rini @ 2021-11-30 18:52 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: u-boot, Simon Glass
[-- Attachment #1: Type: text/plain, Size: 1546 bytes --]
On Tue, Nov 30, 2021 at 09:42:04PM +0300, Andy Shevchenko wrote:
> Importing libraries in Python caches the bytecode by default.
> Since we run scripts in source tree it ignores the current directory
> settings, which is $(srctree), and creates cache just in the middle
> of the source tree. Move cache to the current directory.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> tools/binman/main.py | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/tools/binman/main.py b/tools/binman/main.py
> index 8c1e478d54ce..d5ab59948ec9 100755
> --- a/tools/binman/main.py
> +++ b/tools/binman/main.py
> @@ -16,6 +16,13 @@ import sys
> import traceback
> import unittest
>
> +#
> +# Do not pollute source tree with cache files:
> +# https://stackoverflow.com/a/60024195/2511795
> +# https://bugs.python.org/issue33499
> +#
> +sys.pycache_prefix = os.path.relpath(os.path.dirname(sys.argv[0]), os.environ['srctree'])
> +
> # Bring in the patman and dtoc libraries (but don't override the first path
> # in PYTHONPATH)
> our_path = os.path.dirname(os.path.realpath(__file__))
Do we need some wrapper around this so it doesn't blow up on older than
Python 3.8? Looking over the logs, we force 3.8 to be the minimum
version, I think it's 3.6. Which means that we aren't documenting the
minimum version well, and should. But, 3.8 is only 2 years old and I
always get a little itchy around saying we need tools that feel to me to
be super recent still.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/1] binman: Do not pollute source tree when build with `make O=...`
2021-11-30 18:52 ` Tom Rini
@ 2021-11-30 18:58 ` Andy Shevchenko
2021-11-30 19:06 ` Tom Rini
0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2021-11-30 18:58 UTC (permalink / raw)
To: Tom Rini; +Cc: Andy Shevchenko, U-Boot Mailing List, Simon Glass
On Tue, Nov 30, 2021 at 8:52 PM Tom Rini <trini@konsulko.com> wrote:
> On Tue, Nov 30, 2021 at 09:42:04PM +0300, Andy Shevchenko wrote:
> > +#
> > +# Do not pollute source tree with cache files:
> > +# https://stackoverflow.com/a/60024195/2511795
> > +# https://bugs.python.org/issue33499
> > +#
> > +sys.pycache_prefix = os.path.relpath(os.path.dirname(sys.argv[0]), os.environ['srctree'])
> > +
> > # Bring in the patman and dtoc libraries (but don't override the first path
> > # in PYTHONPATH)
> > our_path = os.path.dirname(os.path.realpath(__file__))
>
> Do we need some wrapper around this so it doesn't blow up on older than
> Python 3.8?
Why does it blow? Some global variables which won't be used by older versions.
> Looking over the logs, we force 3.8 to be the minimum
> version, I think it's 3.6. Which means that we aren't documenting the
> minimum version well, and should. But, 3.8 is only 2 years old and I
> always get a little itchy around saying we need tools that feel to me to
> be super recent still.
P.S. scratch above, I have a v2
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/1] binman: Do not pollute source tree when build with `make O=...`
2021-11-30 18:58 ` Andy Shevchenko
@ 2021-11-30 19:06 ` Tom Rini
2021-11-30 19:10 ` Andy Shevchenko
0 siblings, 1 reply; 6+ messages in thread
From: Tom Rini @ 2021-11-30 19:06 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: Andy Shevchenko, U-Boot Mailing List, Simon Glass
[-- Attachment #1: Type: text/plain, Size: 984 bytes --]
On Tue, Nov 30, 2021 at 08:58:25PM +0200, Andy Shevchenko wrote:
> On Tue, Nov 30, 2021 at 8:52 PM Tom Rini <trini@konsulko.com> wrote:
> > On Tue, Nov 30, 2021 at 09:42:04PM +0300, Andy Shevchenko wrote:
>
> > > +#
> > > +# Do not pollute source tree with cache files:
> > > +# https://stackoverflow.com/a/60024195/2511795
> > > +# https://bugs.python.org/issue33499
> > > +#
> > > +sys.pycache_prefix = os.path.relpath(os.path.dirname(sys.argv[0]), os.environ['srctree'])
> > > +
> > > # Bring in the patman and dtoc libraries (but don't override the first path
> > > # in PYTHONPATH)
> > > our_path = os.path.dirname(os.path.realpath(__file__))
> >
> > Do we need some wrapper around this so it doesn't blow up on older than
> > Python 3.8?
>
> Why does it blow? Some global variables which won't be used by older versions.
Does it? I don't know, I wasn't clear enough, sorry. What happens on
an older python here? Silent ignore is fine.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/1] binman: Do not pollute source tree when build with `make O=...`
2021-11-30 19:06 ` Tom Rini
@ 2021-11-30 19:10 ` Andy Shevchenko
2021-11-30 19:23 ` Tom Rini
0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2021-11-30 19:10 UTC (permalink / raw)
To: Tom Rini; +Cc: Andy Shevchenko, U-Boot Mailing List, Simon Glass
On Tue, Nov 30, 2021 at 9:06 PM Tom Rini <trini@konsulko.com> wrote:
> On Tue, Nov 30, 2021 at 08:58:25PM +0200, Andy Shevchenko wrote:
> > On Tue, Nov 30, 2021 at 8:52 PM Tom Rini <trini@konsulko.com> wrote:
> > > On Tue, Nov 30, 2021 at 09:42:04PM +0300, Andy Shevchenko wrote:
> > > > +#
> > > > +# Do not pollute source tree with cache files:
> > > > +# https://stackoverflow.com/a/60024195/2511795
> > > > +# https://bugs.python.org/issue33499
> > > > +#
> > > > +sys.pycache_prefix = os.path.relpath(os.path.dirname(sys.argv[0]), os.environ['srctree'])
> > > > +
> > > > # Bring in the patman and dtoc libraries (but don't override the first path
> > > > # in PYTHONPATH)
> > > > our_path = os.path.dirname(os.path.realpath(__file__))
> > >
> > > Do we need some wrapper around this so it doesn't blow up on older than
> > > Python 3.8?
> >
> > Why does it blow? Some global variables which won't be used by older versions.
>
> Does it? I don't know, I wasn't clear enough, sorry. What happens on
> an older python here? Silent ignore is fine.
Usually that's the idea that new features are hardly tried to be
backward compatible (yes, I know that the history of Python had a lot
of counter examples, but still). In any case, that one was never used
before.
You may try yourself, btw:
sys.foobar = "blablabla"
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/1] binman: Do not pollute source tree when build with `make O=...`
2021-11-30 19:10 ` Andy Shevchenko
@ 2021-11-30 19:23 ` Tom Rini
0 siblings, 0 replies; 6+ messages in thread
From: Tom Rini @ 2021-11-30 19:23 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: Andy Shevchenko, U-Boot Mailing List, Simon Glass
[-- Attachment #1: Type: text/plain, Size: 1513 bytes --]
On Tue, Nov 30, 2021 at 09:10:11PM +0200, Andy Shevchenko wrote:
> On Tue, Nov 30, 2021 at 9:06 PM Tom Rini <trini@konsulko.com> wrote:
> > On Tue, Nov 30, 2021 at 08:58:25PM +0200, Andy Shevchenko wrote:
> > > On Tue, Nov 30, 2021 at 8:52 PM Tom Rini <trini@konsulko.com> wrote:
> > > > On Tue, Nov 30, 2021 at 09:42:04PM +0300, Andy Shevchenko wrote:
> > > > > +#
> > > > > +# Do not pollute source tree with cache files:
> > > > > +# https://stackoverflow.com/a/60024195/2511795
> > > > > +# https://bugs.python.org/issue33499
> > > > > +#
> > > > > +sys.pycache_prefix = os.path.relpath(os.path.dirname(sys.argv[0]), os.environ['srctree'])
> > > > > +
> > > > > # Bring in the patman and dtoc libraries (but don't override the first path
> > > > > # in PYTHONPATH)
> > > > > our_path = os.path.dirname(os.path.realpath(__file__))
> > > >
> > > > Do we need some wrapper around this so it doesn't blow up on older than
> > > > Python 3.8?
> > >
> > > Why does it blow? Some global variables which won't be used by older versions.
> >
> > Does it? I don't know, I wasn't clear enough, sorry. What happens on
> > an older python here? Silent ignore is fine.
>
> Usually that's the idea that new features are hardly tried to be
> backward compatible (yes, I know that the history of Python had a lot
> of counter examples, but still). In any case, that one was never used
> before.
>
> You may try yourself, btw:
>
> sys.foobar = "blablabla"
Ah ok, thanks!
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-11-30 19:23 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-30 18:42 [PATCH v1 1/1] binman: Do not pollute source tree when build with `make O=...` Andy Shevchenko
2021-11-30 18:52 ` Tom Rini
2021-11-30 18:58 ` Andy Shevchenko
2021-11-30 19:06 ` Tom Rini
2021-11-30 19:10 ` Andy Shevchenko
2021-11-30 19:23 ` Tom Rini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.