https://pantsbuild.org/ logo
r

rhythmic-glass-66959

07/27/2022, 5:24 PM
My generated
sdist
doesn't contain any sources. Any ideas of what could be the problem? I have the
python_sources
target defined...
Ok, I need to include the actual code in the dependencies. I thought it would be picked-up by default...
w

wide-midnight-78598

07/27/2022, 6:01 PM
Assuming you have `python_sources`in your build file, the
.py
files in that folder -should- be picked up. That's not happening?
r

rhythmic-glass-66959

07/27/2022, 6:04 PM
No, it is not...
w

wide-midnight-78598

07/27/2022, 6:07 PM
And nothing nested, correct? Just sibling files to the BUILD?
r

rhythmic-glass-66959

07/27/2022, 6:07 PM
src/python/my_package/BUILD
Copy code
python_distribution(
    name="dist",
    dependencies=["src/python/my_package"], <--- Need this or no sources are included in the sdist
    provides=python_artifact(
        name="my_package",
        version="0.1.0",
    ),
)

python_sources()
w

wide-midnight-78598

07/27/2022, 6:08 PM
Oh, sorry, I mis-understood. I thought you meant
python_sources
wasn't working. The dependency makes sense
r

rhythmic-glass-66959

07/27/2022, 6:09 PM
Yeah, but it feels weird to include its own sources as dependencies, no?
w

wide-midnight-78598

07/27/2022, 6:11 PM
https://www.pantsbuild.org/docs/reference-python_distribution#codedependenciescode Reading this, I think the only way it would pick anything up automatically is if there was some dependencies that could be inferred? But, other than folder location, is there anything else it could infer from? Like a setup.py or something I guess... ?
r

rhythmic-glass-66959

07/27/2022, 6:14 PM
Humm, not clear in my head, but you're probably right. I'm still learning
pants
and I don't understand all its concepts yet...
w

wide-midnight-78598

07/27/2022, 6:15 PM
I've been using pants for a while, contributed some stuff, and I'm still trying to understand a lot too 🙂
🙂 2
h

happy-kitchen-89482

07/27/2022, 9:00 PM
The way to think about it is: The
python_sources
is what owns the sources. The
python_distribution
is a layer on top that says, "package these sources into a distribution". There is no way to infer what "these sources" are.
Although it sounds like what you were expecting was for it to infer a dep on a sibling
python_sources
?
👍 1
Which is not unreasonable 🙂
But is more complicated than it first appears. E.g., what if there are a few
python_sources
in that dir?
r

rhythmic-glass-66959

07/27/2022, 9:06 PM
As you said, the
python_sources
own the sources. If there's a
python_distribution
inside the same BUILD file, why it cannot package those sources into the distribution?
But I agree with you, it can become complicated if there's many
python_sources
inside the directory. I have mixed feeling about this... Maybe because I do not have much experience with
Pants
.
h

happy-kitchen-89482

07/27/2022, 10:57 PM
As you said, the python_sources own the sources. If there's a python_distribution inside the same BUILD file, why it cannot package those sources into the distribution?
It could if we assumed that a
python_distribution
by default depends on any sibling
python_sources
, without an explicit dep. But we've just not made that assumption in the past...
👍 1
w

wide-midnight-78598

07/28/2022, 12:03 AM
I think it's a risky assumption to make for something that will be published/exported/produced - I feel like that should undergo some rigour to see what should be packaged inside
👍 1
h

happy-kitchen-89482

07/28/2022, 12:22 AM
Yeah, the consequences of publishing code you didn't mean to publish are not great, because it's hard to unpublish
3 Views