Open charliermarsh opened 1 week ago
For example, this is a candidate though could obviously cause problems (false negatives or false positives):
>>> sysconfig.get_config_vars()['prefix']
'/install'
But if there's some kind of dedicated flag or metadata, it would of course be preferable.
There shouldn't be false negatives from the sysconfig
prefix variable, unless of course, the build process changes. I'm not opposed to setting something specific to reflect that it's a python-build-standalone
build. I'm not sure where the correct place for that is. Probably something in sysconfig
still?
(I just meant false negatives in the event that the value differed at some previous point in the python-build-standalone
history -- but I didn't verify whether that's true.)
For what it's worth, I think there are good reasons not to have this exposed. It does enable clients to special-case python-build-standalone
which ideally they shouldn't have to do.
The standalone distributions do need to be special cased though, i.e., sysconfig
is known to be broken and installers (or other consumers) need to understand that and adjust their behavior accordingly — there's no clear path towards fixing these values at build time.
Analogy to a web browser...
Issue is asking to use User-Agent detection.
Seasoned web developers will tell you to sniff for features/bugs and not use the UA string as a proxy.
For the same reason you shouldn't use UA strings, we shouldn't key off an "is PBS" flag.
But it could be nice to know a Python is PBS.
If someone wants to footgun themselves keying functionality off that flag, so be it.
Perhaps we could add the PBS advertisement in the Python --version output? I think there's a configure flag to add supplemental text here. It's analogous to a UA string and feels like the right place to put it.
@indygreg -- Can you think of anything we might use for the existing releases? :)
For existing releases, the /install or /build references are probably the best we have. And those are prone to false positives.
It makes sense to expose something more explicit going forward.
Something in the version metadata (I think there's a vendor string or something) and maybe a new sysconfig define if a vendor string can't be easily read/parsed at runtime.
Due to #380, I'm looking for a way to detect whether a given Python interpreter was built by
python-build-standalone
. Is there any reliable metadata (maybe something onsysconfig.get_config_vars()
) to support this?