safety-db icon indicating copy to clipboard operation
safety-db copied to clipboard

Access files as setuptools pkg_resource

Open ajw-aws opened this issue 5 years ago • 7 comments

from data/__init__.py:

with open("data/insecure.json") as __f:

That open is relative to your working directory, the reason it works for testing is that folder data is in the root of your package. The proper way to access this file is with pkg_resources from setuptools as a resource_filename.

ajw-aws avatar May 25 '20 16:05 ajw-aws

This looks great! Adding setuptools to install_requires in setup.py would be good, for completeness!

nrbgt avatar Jun 12 '20 17:06 nrbgt

PR updated

This looks great! Adding setuptools to install_requires in setup.py would be good, for completeness!

ajw-aws avatar Jun 12 '20 19:06 ajw-aws

Hello! Is there something I can help with to get this PR merged?

pawamoy avatar Nov 18 '20 16:11 pawamoy

Any reason why this has not merged yet?

lingrlongr avatar Jul 15 '21 15:07 lingrlongr

If I understand correctly stdlib's importlib.resources would be preferred over setuptools' pkg_resources, wouldn't they?

m-aciek avatar Dec 03 '21 10:12 m-aciek

stdlib's importlib.resources

Yep, wait a few more weeks on this until 3.6 is EOL and yeah, stdlib ftw!

bollwyvl avatar Dec 03 '21 14:12 bollwyvl

I've made a version of this PR which uses importlib.resources as suggested https://github.com/pyupio/safety-db/pull/2351

Let's get import safety_db working again!

efokschaner avatar Feb 04 '22 08:02 efokschaner