Oh I see. I think that I've actually misunderstood the use-package code and that's precisely the behavior they're going for: they want to install the package immediately not when use-package is being byte-compiled, but when it is being used from any file that is being byte-compiled. So it works for them, but it's not the behavior we want here.
> (message
> (eval-when-compile
> (if (bound-and-true-p byte-compile-current-file)
> "I'm being byte-compiled!"
> "I'm being evaluated :(")))
Let's say, this is in a file foo.el. And let's say we have a file
bar.el which contains:
(require 'foo)
...
Then byte-compiling bar.el (when foo.el has not been byte-compiled)
will emit a message "I'm being byte-compiled!".
But yes, there are other ways. I think I remember using something like
(setq my-witness t)
(eval-when-compile
(message (if (bound-and-true-p my-witness)
"Loading this file non-compiled"
"Byte-compiling this file")))
(setq my-witness nil)
in the past,
Stefan