lively-football-87758
10/24/2023, 2:17 PMresouces
added to the dependencies of the python_sources
) into the wheel. When I run the code as a .pex
file everything works nicely and we can get the files from importlib
. However, if we generate a wheel, the files don't get packaged and the python_resources
keyword in setup.py is an empty dict. Is including resources in wheel in general not supported?high-magician-46188
10/24/2023, 2:51 PMsetup.py
or its own generated one?
In my case, I have the following definition template:
python_distribution(
name="PROJECT_NAME-dist-pure-wheel",
dependencies=[
":pyproject",
":PROJECT_NAME-sources",
],
provides=python_artifact(
name="PROJECT_NAME",
),
wheel_config_settings={
"--build-option": ["--python-tag", "py3"]
},
generate_setup=True,
sdist=False,
wheel=True,
)
Where PROJECT_NAME
is replaced with the projects' name.
And you need the dependency on your resource to be somehow linked back to the python_distribution
directive.
For instance, it could be listed under dependencies
, or be a dependency of something that is under dependencies
.lively-football-87758
10/24/2023, 2:55 PMgenerate_setup=True,
and have it listed in the dependencies (both of the distribution and the sources targets). It seems to be understood by pants (otherwise it would not be in the pex venv), so I wonder what else could be the culpritlively-football-87758
10/24/2023, 2:57 PMpants dependencies
command for that targethigh-magician-46188
10/24/2023, 3:01 PMpants package TARGET
and unzip the result, you don't see the file?lively-football-87758
10/24/2023, 3:01 PMhigh-magician-46188
10/24/2023, 3:02 PMlively-football-87758
10/24/2023, 3:02 PMcurved-television-6568
10/24/2023, 3:27 PM--keep-sandboxes=always
and see if you have the resources in there.. can help follow the thread to the root of the issue.happy-kitchen-89482
10/24/2023, 3:31 PMresources
should be packed into the wheelhappy-kitchen-89482
10/24/2023, 3:31 PMhappy-kitchen-89482
10/24/2023, 3:32 PMlively-football-87758
10/24/2023, 3:33 PMlively-football-87758
10/24/2023, 4:05 PM/private
(macos) are printed but they only contain a single file (such as __run.sh
)lively-football-87758
10/24/2023, 4:06 PM# projects/minimal/BUILD
resources(name="minimal_templates", sources=["templates/*/*.*"])
python_distribution(
name="pkg",
dependencies=[
":minimal_templates", # templates
"./src/minimal:minimal", # sources
],
provides=python_artifact(name="minimal", version="0.0.1"),
generate_setup=True,
)
and there is only an init in the soures:
python_sources(
dependencies=["//projects/minimal:minimal_templates"]
)
Commenting out the dependencies has no effect. In fact, having it here does not list the template in pants dependencies project/minimal:pkg
The template(s) are in a folder /project/minimal/templates/template.yaml
If I uncomment the template in the distribution, it will vanish from pants dependencies project/minimal.pkg
otherwise the result is:
projects/minimal/src/minimal/__init__.py
projects/minimal:minimal_templates
The template is not in the package
pants package projects/minimal:pkg
tar xvzf dist/minimal-0.0.1.tar.gz
x minimal-0.0.1/
x minimal-0.0.1/MANIFEST.in
x minimal-0.0.1/PKG-INFO
x minimal-0.0.1/backend_shim.py
x minimal-0.0.1/minimal/
x minimal-0.0.1/minimal/__init__.py
x minimal-0.0.1/minimal.egg-info/
x minimal-0.0.1/minimal.egg-info/PKG-INFO
x minimal-0.0.1/minimal.egg-info/SOURCES.txt
x minimal-0.0.1/minimal.egg-info/dependency_links.txt
x minimal-0.0.1/minimal.egg-info/namespace_packages.txt
x minimal-0.0.1/minimal.egg-info/top_level.txt
x minimal-0.0.1/setup.cfg
x minimal-0.0.1/setup.py
curved-television-6568
10/24/2023, 5:20 PM--no-local-cache
(or --no-cache
)lively-football-87758
10/24/2023, 5:28 PMchroot
subfoldercurved-television-6568
10/24/2023, 5:41 PMpants paths --from=a --to=b
to ensure it is what you think it is.lively-football-87758
10/24/2023, 8:01 PMpants paths --from=projects/minimal:minimal_templates --to=projects/minimal:pkg
Like that (given the example above)? This gives me an empty result []
curved-television-6568
10/24/2023, 8:07 PMcurved-television-6568
10/24/2023, 8:09 PMlively-football-87758
10/25/2023, 7:14 AMpants paths --from=projects/minimal/src/minimal:minimal --to=projects/minimal:pkg
[]
This I did not expect. The sources end up in the packagelively-football-87758
10/25/2023, 7:41 AMlively-football-87758
10/25/2023, 8:44 AMpants peek projects/minimal:pkg
[
{
"address": "projects/minimal:pkg",
"target_type": "python_distribution",
"dependencies": [
"projects/minimal/templates/tmpl.yaml:../minimal_templates",
"projects/minimal/src/minimal/__init__.py:lib"
],
"dependencies_raw": [
":minimal_templates",
"./src/minimal:lib"
],
"description": null,
"entry_points": null,
"env_vars": null,
"generate_setup": true,
"interpreter_constraints": null,
"long_description_path": null,
"output_path": "",
"provides": {
"name": "minimal",
"version": "0.0.1"
},
"sdist": true,
"sdist_config_settings": null,
"tags": null,
"wheel": true,
"wheel_config_settings": null
}
]
(I added name='lib'
to the sources) .. this all looks fine, doesn't it? Where would I expect the yaml file to appear?lively-football-87758
10/25/2023, 1:36 PMcurved-television-6568
10/25/2023, 2:50 PM❯ tar -tzf dist/minimal-0.0.1.tar.gz
minimal-0.0.1/
minimal-0.0.1/MANIFEST.in
minimal-0.0.1/PKG-INFO
minimal-0.0.1/backend_shim.py
minimal-0.0.1/minimal/
minimal-0.0.1/minimal/__init__.py
minimal-0.0.1/minimal/templates/
minimal-0.0.1/minimal/templates/tmpl.yaml
minimal-0.0.1/minimal.egg-info/
minimal-0.0.1/minimal.egg-info/PKG-INFO
minimal-0.0.1/minimal.egg-info/SOURCES.txt
minimal-0.0.1/minimal.egg-info/dependency_links.txt
minimal-0.0.1/minimal.egg-info/namespace_packages.txt
minimal-0.0.1/minimal.egg-info/top_level.txt
minimal-0.0.1/setup.cfg
minimal-0.0.1/setup.py
lively-football-87758
10/25/2023, 9:00 PMcurved-television-6568
10/25/2023, 9:02 PMlively-football-87758
10/25/2023, 9:03 PMhappy-kitchen-89482
10/26/2023, 4:09 AMlively-football-87758
10/26/2023, 10:00 AM