Some annoyance that I’d love some help figuring ou...
# development
a
Some annoyance that I’d love some help figuring out. As part of my PyOxidizer work, I need to replace instances where Pants uses
pkgutil.get_data
internally, because it’s not supported by PEP 304-style pluggable importers (PyOx…r uses one). The problem is that the replacement,
importlib.resources
, cannot currently load resources from namespace packages, and the very first thing that Pants does on startup is load the
VERSION
file from the
pants
namespace package using
get_data
. There’s a backport library that fixes this issue, but that would require users install an external requirement into their python environment. One option is to vendor the code in (it looks relatively small). Easier would be if I could move the
VERSION
file into a non-namespace package. It appears, though, that our installer script depends on the location of the
VERSION
file. I could leave the current version of the file as a symlink (or the importable version, for that matter). Do we have a preference here?
👀 1
(Further background: there are good technical reasons why
pants
must remain a namespace package; putting an
__init__.py
into
pants
was the first thing I tried)
Solution A: vendor
importlib-resources
project Solution B: create
pants.version
, move
src/python/pants/VERSION
into that package, and replace
src/python/pants/VERSION
with a symlink Solution C: create
pants.version
, containing a symlink of
src/python/pants/VERSION
b
You said our installer script depends on VERSION. Can you elaborate? Can we not update the script to do something else?
a
https://github.com/pantsbuild/setup/blob/gh-pages/pants#L337 Every pants install has the
VERSION
file’s location hardcoded
b
So that looks like it's just to support PANTS_SHA. Surely we can support this another way? Or change it in a backwards-compatible way and tell people to upgrade?
a
Again, we can’t replace existing versions of the pants script
b
No but users can. I'm not sure it's a reasonable expectation for this bootstrap script to work with pants always and forever without needing bumping occasionally
especially for a feature as side-loaded as PANTS_SHA
h
Yeah, I wouldn't let the
./pants
script block this work, particularly because this is for an advanced use case w/ PANTS_SHA I suspect we will need to rework this script anyways for PyOxyidzer Note that we required everyone to change their script when Pants switched from Py2 to Py3. Obviously we want to keep disruptions minimal, but it is valid to change the script when necessary
b
If we can keep it backwards compatible (with older versions of pants) then the surface vector for issues should be minimal. Although the fact that the bootstrapper is in SCC means rollback should also be easy
h
the fact that the bootstrapper is in SCC
SCC?
b
Source Code Control
a
I’ll go check my install of Microsoft Visual SourceSafe
🙂
To unblock me, I’m going to go with the symlink approach for now, and come back to updating the bootstrapper later
👍 1