<#21106 Trouble with Source Roots and Pex Binaries...
# github-notifications
c
#21106 Trouble with Source Roots and Pex Binaries New discussion created by jhamet93 As a prior heavy user of Pants V1 at my past employment, I'm attempting a proof of concept of leveraging Pants V2 for a monorepo compared to the current decentralized Python repositories primarily using Poetry that exist today where I currently work. I have a directory called
src/python/block
. Within this directory are then to be projects that should all be importable via a block namespace. As an example, I have a Python project at
src/python/block/hello_world
. Within
src/python/block/hello_world/BUILD
, I have the following:
Copy code
# Probably irrelevant but just including this since
# showcasing a path to migration of existing projects
# is important
poetry_requirements(
    name="poetry",
)

pex_binary(
  name="bin",
  entry_point="cli:cli"
)
The main gist is that when i unzip a pex produced from this project, I do not see the desired import path of Python modules which results in import paths being broken. The source code is not listed in the
block
directory when listing the context of a path. In this example above, rather than
block/cli/__init__.py
being in the pex, just
cli/__init__.py
is in the pex. I believe this is quite simple given this was one of the support "styles" at my previous employer I'm just a little rusty and having difficulties resolving this via the documentation. pantsbuild/pants