My generated `sdist` doesn't contain any sources. ...
# general
r
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
Assuming you have `python_sources`in your build file, the
.py
files in that folder -should- be picked up. That's not happening?
r
No, it is not...
w
And nothing nested, correct? Just sibling files to the BUILD?
r
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
Oh, sorry, I mis-understood. I thought you meant
python_sources
wasn't working. The dependency makes sense
r
Yeah, but it feels weird to include its own sources as dependencies, no?
w
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
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
I've been using pants for a while, contributed some stuff, and I'm still trying to understand a lot too 🙂
🙂 2
h
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
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
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
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
Yeah, the consequences of publishing code you didn't mean to publish are not great, because it's hard to unpublish