thanks for reading the Q.
I've come across SO post where one solution discusses using pkg_resources
which I'm trying to use.
My file structure
x
- x
- to_read.json
- __init__.py
- to_read.json
- __init__.py
Yes, I duplicated it. under the x folder as well
My setup file
from setuptools import find_packages, setup
setup(
name='x',
version='0.160',
packages=find_packages(exclude="tests/"),
url="git@github.com:A/B.git",
package_data={'x': [
'to_read.json',
"x/to_read.json"
]},
install_requires=["foo", "bar"]
)
Code attempting to read it
- Error:
Exception: the 'package' argument is required to perform a relative import for '.'
return json.loads(str(pkg_resources.open_text(".", 'to_read'))) # note, I removed the extension as mentioned in the solution
- FileNotFoundError
return json.loads(str(pkg_resources.open_text("x", 'to_read'))) # note, I removed the extension as mentioned in the solution
I figured that I wouldn't have to import anything (the SO post imported "template") since it's sitting at the top level of my directory?
Thanks!