https://pantsbuild.org/ logo
#general
Title
# general
r

rhythmic-airport-91451

08/15/2022, 4:21 PM
Hey All 👋 I'm adopting a project that utilized Pants for Python and am trying to learn while doing. Just had a couple of questions to help troubleshoot. 1. I'm currently on an M1 mac and the project was developed on an intel based mac and we were using python 3.8.13 to do our development and configure Pants against (using Pants v2.10). I'm having some issues trying to use 3.8.13 and 2.10 respectively where I'll receive the ERROR: No matching distribution found for pantsbuild.pants==2.10.0 while trying to run any Pants command, though this does work when I swap to Python 3.9.x. Just was wondering if this is an issue around arm not being supported for anything below 3.9. 2. If I understood correctly, Pants only focuses on the directory and subdirectories that it belongs in and doesn't recognize anything outside of it. I'm trying to utilize a common directory for doing configuration setups and am having a hard time trying to get Pants to notice that library in the BUILD file. Just looking for any suggestions on how to recognize another directory or file in the file structure outside of directory the BUILD file is in.
w

wide-midnight-78598

08/15/2022, 4:23 PM
There is another chat in here re: m1's that might be helpful, I'll try to look for it
e

enough-analyst-54434

08/15/2022, 4:49 PM
@rhythmic-airport-91451 as a good general debugging step that works with any PyPI project and not just Pants, check what's available here: https://pypi.org/project/pantsbuild.pants/2.10.0/#files There are 2 things of note. 1 - there is no sdist; so you won't be able to get the project for any random Python, but just for the wheels published instead. 2 - there is only a cp39 wheel for macos arm.
h

happy-kitchen-89482

08/15/2022, 5:26 PM
Hi @rhythmic-airport-91451, sorry for the trouble - but yeah, we only support running Pants on 3.9 on M1s, because of technical issues with earlier interpreter versions on that platform. But note that Pants can test and run your own code on other Python versions, this is just about the interpreter Pants uses to run itself.
r

rhythmic-airport-91451

08/15/2022, 6:48 PM
Got it, thanks everyone! I'll try to resolve with 3.9, just need assistance with the other question I had.
e

enough-analyst-54434

08/15/2022, 7:04 PM
Pants can deal with any file that is a sibling of pants.toml or anywhere in that tree. You might want to explain the problem you're running into in 2. in more detail is evrything you're trying to act on is, in fact, in the pants.toml parent directory's tree.
r

rhythmic-airport-91451

08/16/2022, 8:43 PM
Hey all, apologies - got caught up. Basically, my file structure is like so: main_repo: |- BUILD | |- common_dir: |- config.py |- BUILD | |- service_dir: |- service.py (requires config.py) |- BUILD What I'm trying to do reference the config.py from the common_dir within the BUILD file under the service_dir in order to bring it in as a dependency. There's a parent BUILD across the whole project and each module has a BUILD within it.
e

enough-analyst-54434

08/16/2022, 8:57 PM
It will really help to also include the output of
./pants roots
, the (relevant) BUILD file contents (i.e.: how you're attempting to wire this up) as well as the Pants command you run and the failure or unexpected result you get from that command. The more self-contained you can make the example, the easier it is to help you.
In other words - the sketch you provided is totally normal / workable with Pants, so this will come down to some details.
r

rhythmic-airport-91451

08/16/2022, 9:53 PM
Got it, when I rant
./pants roots
it only shows the
.
and
common
in the output. I tried to throw in
python_requirements
and
python_sources
but it wasn't able to resolve. I guess I'll tailor my question more towards the following: with the structure of the project that I defined above, what's the best way to bring in the
common_dir
as a dependency for the
service_dor
? Is it through adding it as a requirement to the parent BUILD and referring to it in the services dir?
e

enough-analyst-54434

08/16/2022, 11:01 PM
At the highest level you shouldn't need to do anything at all. If
./pants roots
prints out the paths you would need to add to
PYTHONPATH
to get a standard Python repl session to see and be able to import all of your code, and then you run
./pants tailor
to generate BUILD files, everything should normally just work and Pants should infer all the dependencies automatically. Only if
config.py
is imported in a non-standard way by `service.py`will that automatic dependency inference fail: say via something like
config = importlib.import_module("con" + "fig")
. If the import is a normal
import config
then we should work out why dependency inference isn't working. If the import is tricky like the example, then you do need to add a manual dependency and we could talk about your BUILD file contents.
Always the easiest for this side of the help is a sample repo you can share. If the code is private, this requires more work from your end though to create a sample repo.