miniature-dawn-49992
07/31/2019, 6:17 PMresources()
in a python context? i have a few openapi specs i want to include but when they make it into the pythonpath, they are packageless so pkgutil.get_data
can't find them.miniature-dawn-49992
07/31/2019, 6:18 PMpython_library()
worked but eugh it just feels wronghappy-kitchen-89482
07/31/2019, 7:45 PMhappy-kitchen-89482
07/31/2019, 7:48 PMresources()
should be in the package implied by their location in the source tree under their source roothappy-kitchen-89482
07/31/2019, 7:50 PMpython_library(...
dependencies = [
:somefiles
]
)
resources(name='somefiles',
sources=['foo.txt', 'bar.txt'])
Where foo.txt and bar.txt are in the same dir as the BUILD file. Then we can access them from code in the sibling library with e.g., pkg_resources.resource_string(__name__, 'foo.txt')
happy-kitchen-89482
07/31/2019, 7:50 PMminiature-dawn-49992
07/31/2019, 8:43 PMhappy-kitchen-89482
08/01/2019, 3:47 PMpkg_resources.resource_string()
happy-kitchen-89482
08/01/2019, 3:47 PM__name__
workshappy-kitchen-89482
08/01/2019, 3:52 PMpkg_resources.resource_string()
means that the resource names are interpreted as relative to that modulehappy-kitchen-89482
08/01/2019, 3:53 PMhappy-kitchen-89482
08/01/2019, 3:53 PM