is there a way to include my `python_distribution`...
# general
c
is there a way to include my
python_distribution
as a first party dependency in other code? i have a repo that looks something like this:
Copy code
- src
   - internal_lib
       - setup.py
       - internal_lib
           - __init__.py (and other files)
   - other_app:
      python files that ideally do import internal_lib.asdf
internal_lib has a
python_distribution
in its
BUILD
file, so i’d basically like to be able to just do
import internal_lib.module
in my other
src
code instead of having to do
import internal_lib.internal_lib
. The reason I need it to be an actual distribution is so I can distribute that code elsewhere as well.
h
This should just work, as far as I can tell. If you
import internal_lib.asdf
pants should infer the dependency on that module. There is no logic that says “since this is in a distribution, don’t depend on it. If that dep isn’t being inferred, it may be because source roots aren’t set up correctly in this case. In fact, since you mentioned that there would be a different import path depending on whether you consumed the code as first party or as a published artifact, that leads me to believe that there is a source roots issue.
You shouldn’t have to change the import path (
internal_lib.internal_lib.module
vs
internal_lib.module
) based on how you consume the code
I suspect that you want
src/internal_lib
to be a source root, so that imports are always
import internal_lib.module
, and you want your
setup.py
to respect that.
c
yeah the source root was the issue, thanks 🙂
hmm but now my package command is goofy
i’ll have to take a look