I have everything set up with pants and it works l...
# general
c
I have everything set up with pants and it works like a charm - Thanks for the help @curved-television-6568 and @happy-kitchen-89482. One last question remains to me: First party dependency which are packaged separately. My currently workflow is to have a poetry pyproject.toml to specify the first party dependency (and to override it in the dev dependencies with an editable install). Pants doesn't understand editable installs, therefore I also include the dependency in my BUILD file, which works as intended. (The dependency + editable install I still have from the days before pants). If I now what to package all my modules and libraries I need to keep the dependency declared in my pyproject.toml, otherwise the generated setup.py in the distribution doesn't know anything about this dependency. If I don't declare the editable install in the dev dependency, pants generate lockfiles doesn't work anymore. (which makes sense). So if I keep the dependency in the BUILD file, as well as in the pyproject.toml + editable install as dev-dependency everything works - But it feels kind of like a workaround. My thought process was, that if libraryA declares a distribution in its BUILD file and moduleB depends on this libraryA, it should add it to the install_requires section of the setup.py (As mentioned here https://www.pantsbuild.org/docs/python-distributions#mapping-source-files-to-distributions). Or does this not work because of me using poetry?
đź‘Ť 1
h
Hmm, this should work, IIRC, if libraryA and libraryB have
python_distribution
targets, and code in libraryB depends on code in libraryA then when running tests etc. the dependency will be resolved in-repo, but when packaging libraryA and libraryB will be packaged separately, and an
install_requires
will be generated into the
setup.py
.
But this assumes you’re letting Pants generate the
setup.py
, and it sounds like you’re hand-writing the distribution’s build using poetry?
c
@happy-kitchen-89482 Thanks for your answer - So this only works when I use the
python_requirements
goal, not the
poetry_requirements
goal?
h
Well, the
*_requirements
targets are about defining existing published 3rdparty deps for Pants to resolve and use. What I’m referring to is
python_distribution
, which is about Pants packaging a distribution from your code.
I assumed the latter was what you were referring to
If you publish distA, distB from your repo, code in distB can depend on code in distA in-repo for tests etc. but Pants can still package the two dists separately, with the right install_requires injected in distB’s metadata
c
@happy-kitchen-89482 That's exactly what I thought as well, and what I meant. I will try it once more later when not using poetry, maybe that helps, because even with a generated setup py it doesn't seem to work for me (the injection of libB into libA's setup.py)