Hi there, I'm using pants as my build system in my...
# general
i
Hi there, I'm using pants as my build system in my python monorepo. All the dependencies I use in my projects are included in 3rdparty/pyproject.toml file with my package registry defined in [[tool.poetry.source]]. From project.toml I create a poetry.lock and requirements.txt file. I know that pants is capable of dependency inference, so when I build a sub-project in docker, only the used dependencies from the list of all dependencies will be installed. What I'm trying to do is to create a requirements.txt file for a sub-project myself. The reason for this is that some projects I want to build differently (via nuitka) and not with pants, and for that I need the requirements.txt file with the dependencies for that specific project. What I figured out is that with "./pants dependencies --dependencies-transitive <file>" you get a list with all the packages and files used in a speciific project. Right now I am adding all the packages to a new pyproject.toml file myself, from which again all the dependecies will be resolved from my package registry via poetry install and a poetry.lock/requirements.txt file can be created. Is there a way to do this automatically as I want to include this build process into my gitlab pipeline? I do not want to have to manually create the toml file anymore but instead pants directly create a requirements.txt file for a sub-project for me
b
Something like https://github.com/pantsbuild/pants/discussions/19035#discussioncomment-5940410 might be a starting point, but using
pants dependencies --transitive path/to/subproject/entrypoint.py
to first list out everything your subproject depends on and then filter/peek it to pick out the
python_requirement
targets. This has some limitations, but might be a good enough starting point?
Some alternatives might be: • build the project into a
pex_binary
as normal, and then transform the PEX with Nukita (eg extract the contents to a venv and compile it) • use a
python_distribution
with a setup.py similar to how some others use Cython, I believe • use a pants plug-in that runs nukita similar to how there’s a plug-in for pyoxidizer? That said, I’m completely unfamiliar with how nukita works, so none of these may make sense