bitter-ability-32190
08/31/2023, 4:14 PMmain) apparently not being a namespace package?
So I'm trying to run pants from the latest release in main, so I set a pants_version and removed [DEFAULT]. Then pants runs, and errors on not being able to find pants.explorer.server.
That makes sense, since it isn't bundled into Pants itself. So I add "%(buildroot)s/src/python" to pythonpath. But the error persists!
Doing a little debugging, in extension_loader I do import pants;print(pants.__file__) and it prints /home/josh/.cache/nce/65aa4f2a6c1f9bac672c0df94ae34c7170e5c071cda35e9b725945831905c122/bindings/venvs/2.18.0a0/lib/python3.9/site-packages/pants/__init__.py.
According to the internet, namespace packages should have __file__ set to None (or just not have a __file__. WTF?!bitter-ability-32190
08/31/2023, 4:25 PMjosh@cephandrius:~/work/pants$ mkdir -p other_pants/pants
josh@cephandrius:~/work/pants$ cp src/python/pants/__init__.py other_pants/pants
josh@cephandrius:~/work/pants$ touch other_pants/pants/bar.py
josh@cephandrius:~/work/pants$ python3.9
Python 3.9.17 (main, Jun 6 2023, 20:11:04)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path.append("src/python")
>>> sys.path.append("other_pants")
>>> import pants
>>> pants.__file__
'/home/josh/work/pants/src/python/pants/__init__.py'bitter-ability-32190
08/31/2023, 4:34 PM>>> import sys; sys.path.append("src/python"); sys.path.append("other_pants")
>>> import pants.bar
>>> pants
<module 'pants' from '/home/josh/work/pants/src/python/pants/__init__.py'>
>>> import pants.util
>>> pants
<module 'pants' from '/home/josh/work/pants/src/python/pants/__init__.py'>
So I think __file__ is a red herring?bitter-ability-32190
08/31/2023, 4:38 PM__file__ is a red herring. The true way to tell how things will be loaded is to look at __path__.
In this case pants is loaded first to start, well, executing Pants. And in doing so, pythonpath from pants.toml isn't considered. That means the built-in Pants is marked down as the only path in __path__.
To put this back into `python3.9`:
josh@cephandrius:~/work/pants$ python3.9
Python 3.9.17 (main, Jun 6 2023, 20:11:04)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path.append("src/python")
>>> import pants.util
>>> pants.__path__
['/home/josh/work/pants/src/python/pants']
>>> sys.path.append("other_pants")
>>> import pants.bar
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pants.bar'bitter-ability-32190
08/31/2023, 4:53 PMpants name for plugins. Eventually I think we want another repo for blessed-but-not-baked-in plugins. This particular codepath isn't for plugins though.
Secondly, I think our backend_packages should only be packages baked into Pants itself. Anything not baked in belongs in internal_plugins.
@curved-television-6568 thoughts?bitter-ability-32190
08/31/2023, 5:19 PMcurved-television-6568
08/31/2023, 5:35 PMpants.explorer should move out, as that is not meant to be baked in.curved-television-6568
08/31/2023, 5:36 PMinternal_plugins either.. it’s meant to become a public pluginbitter-ability-32190
08/31/2023, 5:39 PMcurved-television-6568
08/31/2023, 5:40 PMpants_plugin.explorer ?bitter-ability-32190
08/31/2023, 5:42 PMbitter-ability-32190
08/31/2023, 5:42 PMcurved-television-6568
08/31/2023, 5:43 PMbitter-ability-32190
08/31/2023, 5:43 PMbitter-ability-32190
08/31/2023, 5:44 PMcurved-television-6568
08/31/2023, 5:46 PMbitter-ability-32190
08/31/2023, 5:47 PMcurved-television-6568
08/31/2023, 5:50 PMbitter-ability-32190
08/31/2023, 5:51 PMbitter-ability-32190
08/31/2023, 5:51 PMcurved-television-6568
08/31/2023, 5:51 PMcurved-television-6568
08/31/2023, 5:53 PMcurved-television-6568
08/31/2023, 5:53 PMbitter-ability-32190
08/31/2023, 5:54 PMpants is not the same as my pants in the same repo for the same commitcurved-television-6568
08/31/2023, 5:55 PMbitter-ability-32190
08/31/2023, 5:55 PMcurved-television-6568
08/31/2023, 5:56 PMbitter-ability-32190
08/31/2023, 5:56 PMcurved-television-6568
08/31/2023, 5:56 PMbitter-ability-32190
08/31/2023, 5:57 PMcurved-television-6568
08/31/2023, 5:57 PMbitter-ability-32190
08/31/2023, 5:57 PMcurved-television-6568
08/31/2023, 5:58 PMbitter-ability-32190
08/31/2023, 5:58 PMbitter-ability-32190
08/31/2023, 5:58 PMcurved-television-6568
08/31/2023, 5:59 PMcurved-television-6568
08/31/2023, 6:00 PMbitter-ability-32190
08/31/2023, 6:00 PMcurved-television-6568
08/31/2023, 6:00 PM