A.A
A.A

Reputation: 4101

np.load from relative file in the python package

I have created a python package and I need to have np.load('./my_file.npy') in my package. when I install package and run the code the path is not correct and python cannot find the file

I tried the following code as well

dirname = Path(__file__).parent
path = dirname / 'my_file.npy'
np.load(str(path))

In pyproject.toml file I have as well

[tool.flit.sdist]
include = [
    "my_file.npy",
]

Upvotes: -1

Views: 71

Answers (1)

mokko
mokko

Reputation: 186

Do I understand you correctly that you want to include the file my_file.npy in your package using flit?

Flit‘s docs about data files: https://flit.pypa.io/en/stable/pyproject_toml.html?highlight=Data#external-data-section

I have nothing special in my toml file and it includes my data files in the package.

Upvotes: 1

Related Questions