okay, so i’m trying to develop my first plugin (da...
# general
okay, so i’m trying to develop my first plugin (daunting 😅), and yet again i’m asking for IDE support (mostly for documentation purposes), and since this is now just regular python3 code that should allow for using all the bells and whistles of whatever python language server integration my editor has? … but, i sort of expected more paths to show up after enabling python + plugin development plugins …
Copy code
❯ ./pants roots
where do i point my editor to to get the proper path for the current version of the pants python libraries? as i understand it pants bundles it’s own python somewhere digging around in
i’ve found
…. which looks promising, but is there some established way through a similar command to get to this path without manual spelunking? and is this enough to get lsp support? let me iterate — i’m in no way a python developer 😆
Hi there, welcome! We're definitely happy to help and we try to be Python beginner friendly 🙂 For your IDE, you'd want to use the
goal: https://www.pantsbuild.org/docs/setting-up-an-ide#python-third-party-dependencies-and-tools
ah, so pants own python libraries are considered 3rd party code? — i guess that makes sense since it’s all — uh hermetic/self-contained or whatever 😉 thanks, i’ll be sure to try that out!
Precisely 🙂 that is if you want to run Pants on Pants plugin code, e.g. run tests. Which is recommended but not required
target generator makes sure Pants-as-a-library is the same version used as Pants-as-a-binary
okay, so — trying export and i get
Copy code
❯ ./pants export
08:06:30.66 [INFO] Completed: Building pytest.pex from pytest_default.lock
08:06:30.66 [ERROR] 1 Exception encountered:

  ProcessExecutionFailure: Process 'Building pytest.pex from pytest_default.lock' failed with exit code 1.

    ERROR: Command errored out with exit status 1:
     command: /Users/dreuss/.cache/pants/named_caches/pex_root/venvs/s/51b60de7/venv/bin/python3.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/Users/dreuss/.cache/pants/named_caches/pex_root/tmp/pip-req-build-if47ksg3/setup.py'"'"'; __file__='"'"'/Users/dreuss/.cache/pants/named_caches/pex_root/tmp/pip-req-build-if47ksg3/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' --no-user-cfg egg_info --egg-base /Users/dreuss/.cache/pants/named_caches/pex_root/tmp/pip-pip-egg-info-_hh2wnqu
         cwd: /Users/dreuss/.cache/pants/named_caches/pex_root/tmp/pip-req-build-if47ksg3/
    Complete output (11 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/Users/dreuss/.cache/pants/named_caches/pex_root/venvs/s/51b60de7/venv/lib/python3.7/site-packages/setuptools/__init__.py", line 37, in <module>
        from setuptools.dist import Distribution, Feature  # vendor:skip
      File "/Users/dreuss/.cache/pants/named_caches/pex_root/venvs/s/51b60de7/venv/lib/python3.7/site-packages/setuptools/dist.py", line 57, in <module>
        from setuptools import windows_support  # vendor:skip
      File "/Users/dreuss/.cache/pants/named_caches/pex_root/venvs/s/51b60de7/venv/lib/python3.7/site-packages/setuptools/windows_support.py", line 2, in <module>
        import ctypes
      File "/Users/dreuss/.pyenv/versions/3.7.13/lib/python3.7/ctypes/__init__.py", line 7, in <module>
        from _ctypes import Union, Structure, Array
    ModuleNotFoundError: No module named '_ctypes'
this is sort of exactly the types of problems i was hoping not to battle with a tool like pants 😆
Is this something that could be a public repo so we could take a look at? This one is weird, because I thought this kinda implies that the installation is whack, or the system is missing the FFI dependencies - but it looks like you're on a Mac? Are you on a Mac M1?
yeah, i’m on an M1 — i suspected that was the problem too
it could probably be public — i’ll check if i can repro, it contains basically a hello world plugin, and that’s all
I recall there was some stuff to do on an M1, either with homebrew or pyenv first, or maybe it was Python version? But I haven't run into that yet, so, I need to defer to one of the m1 peeps for more info. There are a couple links in the docs that might be useful? https://www.pantsbuild.org/docs/prerequisites#macos
If you're able to publish it, I can test it out on a non-M1
@freezing-lamp-12123 I see Python 3.7 there. You will almost certainly need to use 3.9+ if you're on an M1. https://www.pantsbuild.org/docs/python-interpreter-compatibility
ah — got it — i’ll try and see if that helps, or i can make it work somehow — thanks for the pointers
❤️ 1
now we’re talking
Copy code
❯ ./pants export
20:27:30.09 [INFO] Initializing scheduler...
20:27:30.20 [INFO] Scheduler initialized.
20:27:33.59 [INFO] Completed: Building pytest.pex from pytest_default.lock
Wrote virtualenv for the tool 'pytest' to dist/export/python/virtualenvs/tools
thanks! .. using 3.9 did the trick ❤️
❤️ 1