high-yak-85899
10/14/2022, 1:27 AMhigh-yak-85899
10/14/2022, 1:30 AM<http://MANIFEST.in|MANIFEST.in>
, but I'm not seeing mentions of that in pants docs.fast-nail-55400
10/14/2022, 1:51 AMhigh-yak-85899
10/14/2022, 2:00 AMhigh-yak-85899
10/14/2022, 2:01 AMpython_distribution
wheel that includes non-python files. When I build a pex of my system, it's exactly what I expect and includes my data files.fast-nail-55400
10/14/2022, 2:05 AMsrc/python/pants/backend/python/goals/setup_py.py
makes uses of ResourceSourceField
, so my inclination that it could be relevant.fast-nail-55400
10/14/2022, 2:06 AMresources
target as a direct dependency of the python_distribution
target?high-yak-85899
10/14/2022, 2:22 AMhappy-kitchen-89482
10/14/2022, 4:34 AMhappy-kitchen-89482
10/14/2022, 4:35 AMhigh-yak-85899
10/14/2022, 5:00 AMhigh-yak-85899
10/14/2022, 5:03 AM./pants paths --from=//:ops_distribution --to=astranis-python/astranis/gnc/external/iers/iau2000A_finals_ab.txt
[
[
"//:ops_distribution",
"ops/scripts/geosat_1/odet/spacex_opm_to_odet_prior.py:../../all_scripts",
"astranis-python/astranis/gnc/common/coordinate_transforms.py",
"astranis-python/astranis/gnc/refsys/refsys_earth_orientation.py",
"astranis-python/astranis/gnc/external/iers/iau2000A_finals_ab.txt:iau_finals"
],
[
"//:ops_distribution",
"ops/scripts/geosat_1/payload_iot/antenna_characterization/antenna_characterization_slew.py:../../../all_scripts",
"astranis-python/astranis/gnc/payload/payload_coordinate_transforms.py",
"astranis-python/astranis/gnc/refsys/refsys_earth_orientation.py",
"astranis-python/astranis/gnc/external/iers/iau2000A_finals_ab.txt:iau_finals"
],
[
"//:ops_distribution",
"ops/scripts/geosat_1/payload_iot/antenna_characterization/antenna_characterization_slew.py:../../../all_scripts",
"astranis-python/astranis/gnc/payload/payload_coordinate_transforms.py",
"astranis-python/astranis/gnc/ephem/ephem.py",
"astranis-python/astranis/gnc/refsys/refsys_earth_orientation.py",
"astranis-python/astranis/gnc/external/iers/iau2000A_finals_ab.txt:iau_finals"
]
]
high-yak-85899
10/14/2022, 5:03 AM./pants package
my distribution, they aren't in the wheelhigh-yak-85899
10/14/2022, 5:04 AMpython_distribution(
name="ops_distribution",
sdist=False,
provides=python_artifact(name="ops_dist", version="0"),
dependencies=[
"//ops/scripts:all_scripts",
"//astranis-python/astranis/ground/target_interface/script_runner.py",
"//astranis-python/astranis/shell/backdoor.py",
],
entry_points={
"console_scripts": {
"run_ops_script":
"astranis.ground.target_interface.script_runner:main",
"backdoor":
"astranis.shell.backdoor:main"
}
})
high-yak-85899
10/14/2022, 5:05 AMall_scripts
is a python_sources
target with a glob pattern like **/*.py
in case that's helpful.fast-nail-55400
10/14/2022, 5:10 AMastranis-python/astranis/gnc/external/iers/iau2000A_finals_ab.txt:iau_finals
?fast-nail-55400
10/14/2022, 5:11 AMhigh-yak-85899
10/14/2022, 5:11 AMresources
high-yak-85899
10/14/2022, 5:12 AMresources(
name="iau_finals",
sources=["*iau2000A_finals_ab.txt"],
)
high-yak-85899
10/14/2022, 5:14 AMpex_binary(
name="executable_scripts",
script="conscript",
dependencies=[":ops_distribution", ":reqs#conscript"])
high-yak-85899
10/14/2022, 5:14 AMiau
files I want in that unzipped directoryhigh-yak-85899
10/14/2022, 5:21 AMgenerate_setup=True
did not change the behaviorhigh-yak-85899
10/14/2022, 5:32 AMhigh-yak-85899
10/14/2022, 5:37 AMfast-nail-55400
10/14/2022, 5:48 AM# If resource is not in a package, ignore it. There's no principled way to load it anyway.
fast-nail-55400
10/14/2022, 5:50 AMhigh-yak-85899
10/14/2022, 4:29 PMhigh-yak-85899
10/14/2022, 4:29 PMhigh-yak-85899
10/14/2022, 4:31 PMfoo/
- bar.py
tree/
- file.txt
bar.py
depends on file.txt
in my scenario.happy-kitchen-89482
10/14/2022, 5:32 PMhappy-kitchen-89482
10/14/2022, 5:33 PMhigh-yak-85899
10/14/2022, 9:49 PMhappy-kitchen-89482
10/14/2022, 10:27 PMastranis-python/astranis/gnc/external/iers/iau2000A_finals_ab.txt
under a source root? (as seen by running ./pants roots
)happy-kitchen-89482
10/14/2022, 10:28 PMhappy-kitchen-89482
10/14/2022, 10:28 PMhigh-yak-85899
10/14/2022, 10:31 PM./pants paths
. We use it by doing things like pathlib.Path(__file__)
in one place and then navigating relative to that module to grab it.high-yak-85899
10/14/2022, 10:31 PMastranis/gnc/external
folder never shows up in my wheel when I unzip and inspect it.high-yak-85899
10/14/2022, 10:32 PMfind
with the unzipped wheel to make sure it wasn't anywhere in the wheel contents.happy-kitchen-89482
10/14/2022, 11:42 PMresources()
target then it should be there, as those other files are. Sounds like a subtle bug.happy-kitchen-89482
10/15/2022, 12:26 AMhigh-yak-85899
10/15/2022, 12:31 AMfast-nail-55400
10/15/2022, 12:31 AMpants_from_sources
script?fast-nail-55400
10/15/2022, 12:32 AMfast-nail-55400
10/15/2022, 12:32 AMpants_from_sources
script can be found here: https://github.com/pantsbuild/example-python/blob/main/pants_from_sourceshigh-yak-85899
10/26/2022, 5:21 AMhigh-yak-85899
10/26/2022, 5:42 AMlib/
external/
data/
-> BUILD.pants
-> my_data.txt
data_user/
-> BUILD.pants
-> my_module.py
In this scenario, despite using resources
in lib/external/data/BUILD.pants
and properly linking that to lib/data_user/my_module.py
in its BUILD file, we do not see the data file in the built distribution.high-yak-85899
10/26/2022, 5:43 AMlib/
data_user/
-> BUILD.pants
-> my_module.py
-> my_data.txt
and declare the resource in BUILD.pants
and link it to my_module.py
, I do see it in my output distribution.high-yak-85899
10/26/2022, 5:59 AMsetup.py
and <http://MANIFEST.in|MANIFEST.in>
? I think that would go a long way in debugging this.high-yak-85899
10/26/2022, 6:02 AMhigh-yak-85899
10/26/2022, 6:11 AMhigh-yak-85899
10/26/2022, 6:13 AMlib/
external/
data/
-> BUILD.pants
-> my_data.txt
-> dummy.py
data_user/
-> BUILD.pants
-> my_module.py
and then say that my_module.py
depends on dummy.py
in lib/data_user/BUILD.pants
, then that gets included in my built distribution.high-yak-85899
10/26/2022, 6:15 AMhigh-yak-85899
10/26/2022, 6:16 AM__init__.py
in our repo. We rely on namespace packaging.high-yak-85899
10/26/2022, 6:17 AMhigh-yak-85899
10/26/2022, 6:24 AMhigh-yak-85899
10/26/2022, 6:29 AMhappy-kitchen-89482
10/26/2022, 7:27 AMhappy-kitchen-89482
10/26/2022, 7:27 AMhappy-kitchen-89482
10/26/2022, 7:28 AMhappy-kitchen-89482
10/26/2022, 7:28 AMhigh-yak-85899
10/26/2022, 4:35 PMresources
target associated with the file we want to the dependencies of a python_sources
target in another directory. We expect the built package to place things in a similar relative path so we do something like pathlib.Path(__file__).parent / '<path to thing>'
to grab.high-yak-85899
10/26/2022, 4:36 PM<http://MANIFEST.in|MANIFEST.in>
to control data files when building distributions. I'm not sure how I would expect package_data
to look in this scenario.happy-kitchen-89482
10/26/2022, 4:38 PM<http://MANIFEST.in|MANIFEST.in>
doesn’t distinguish between source and data files, IIUChigh-yak-85899
10/26/2022, 4:41 PMhigh-yak-85899
10/26/2022, 4:49 PM~/devel/pants-distribution-bug (distribution-bug-repro)$ ./pants dependencies --transitive //:test_distribution
//:reqs#ansicolors
//:reqs#setuptools
//:reqs#types-setuptools
//requirements.txt:reqs
helloworld/external/data/top_secret.txt:secret_data
helloworld/greet/__init__.py:lib
helloworld/greet/greeting.py:lib
helloworld/greet:translations
helloworld/translator/translator.py:lib
~/devel/pants-distribution-bug (distribution-bug-repro)$ ./pants package //:test_distribution
10:48:48.50 [INFO] Wrote dist/test_dist-0-py3-none-any.whl
10:48:48.50 [INFO] Wrote dist/test_dist-0.tar.gz
~/devel/pants-distribution-bug (distribution-bug-repro)$ unzip -l dist/test_dist-0-py3-none-any.whl
Archive: dist/test_dist-0-py3-none-any.whl
Length Date Time Name
--------- ---------- ----- ----
0 2022-10-26 16:47 helloworld/greet/__init__.py
1317 2022-10-26 16:47 helloworld/greet/greeting.py
323 2022-10-26 16:47 helloworld/greet/translations.json
249 2022-10-26 16:47 test_dist-0.dist-info/METADATA
92 2022-10-26 16:47 test_dist-0.dist-info/WHEEL
62 2022-10-26 16:47 test_dist-0.dist-info/entry_points.txt
1 2022-10-26 16:47 test_dist-0.dist-info/namespace_packages.txt
11 2022-10-26 16:47 test_dist-0.dist-info/top_level.txt
737 2022-10-26 16:47 test_dist-0.dist-info/RECORD
--------- -------
2792 9 files
high-yak-85899
10/26/2022, 4:49 PMhigh-yak-85899
10/26/2022, 5:13 PM