Fix remote builds by making build-config contents deterministic
Because of the usage of `env!`, we were baking paths to generated files
in `lib.rs`. In setups where the build can be executed remotely (e.g.
when building with Buck2), those paths would be different depending on
whether the build ran locally or remotely.
This difference propagates to `pyo3-macros`. Because Buck2 runs the
metadata and codegen builds separately (for increased parallelism), they
can have different contents due to the above, causing rustc to find two
versions of the crate, and erroring out. This is not observable with
Cargo because it runs both builds with the same rustc invocation.
See https://github.com/facebook/buck2/issues/1206 and
https://github.com/rwf2/Rocket/pull/2797 for more context.
This commit fixes the issue by simply reading `OUT_DIR` at run-time,
rather than compile-time, so that the content of `lib.rs` is fixed.
Closes https://github.com/facebook/buck2/issues/1206
Many thanks to https://github.com/cormacrelf for pointing out the root
of the issue.