Is there a good example somewhere of a python libr...
# general
h
Is there a good example somewhere of a python library monorepo? I think I must have majorly messed up configuration because every time I change something to do with pants, everything breaks. Most recently I added a new subproject that happens to import the same third party dependency as another and now neither can find it.
l
did you more or less start off with something like https://github.com/pantsbuild/example-python? If your configuration does not look wildly different from the kinds of things you see there, you could post a reduced version of your last working project setup here as well as the small change that makes it break.
h
I don’t think that example is very useful for my case, which is why I’m looking for others. It’s only a single project, and one with a very strange layout. It’s hard to map that back to a library layout like:
Copy code
.
├── mylibrary
│   ├── __init__.py
│   └── submodule
│       └── __init__.py
├── pyproject.toml
└── tests
    ├── __init__.py
    └── test_foo.py
That’s a pretty typical layout, and is generally how I want all of my subprojects to look (before the build files are added). Each sub-project is a separate library that will be published to pypi. Unfortunately I got pretty far in my refactoring work before I triggered this issue, but I’ll try to get a minimal example up tomorrow for a change that broke things.
The repo in question is here. Right now there’s two sub-projects in
python-packages
, and I’m breaking them up into 3 or 4 while keeping the older ones around until the whole thing is done. Not every directory has a build file since I had trouble making that work, but I’ve got a feeling that’s part of the problem.
l
You will usually need a build file in every dir with python sources. Or rather, removing them is rarely the best solution to a failure.
c
if you copy packages to a new location, while keeping the old around, it’s likely to cause conflicts, unless you keep one copy in a different resolve from the other.
👍 1
if you post command, expected output, actual output along with the link to the version of the repo you’re using we’re in a much better position to help you 🙂
h
Do you have multiple requirements.txt/pyproject.toml providing the same requirement? That can cause Pants to not know which target to pick (although in recent Pants that should be resolved by picking the one in the closest ancestor of the consuming code)
h
Mutliple pyrprojects is probably the issue, though I am on the latest version.
Here’s a draft that shows the changes that trigger it, as well as showing how I’m setting up these sub-projects