Skip to content

Access files as setuptools pkg_resource#2309

Open
ajw-aws wants to merge 5 commits into
pyupio:masterfrom
ajw-aws:2308
Open

Access files as setuptools pkg_resource#2309
ajw-aws wants to merge 5 commits into
pyupio:masterfrom
ajw-aws:2308

Conversation

@ajw-aws

@ajw-aws ajw-aws commented May 25, 2020

Copy link
Copy Markdown

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.

@nrbgt

nrbgt commented Jun 12, 2020

Copy link
Copy Markdown

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

@ajw-aws

ajw-aws commented Jun 12, 2020

Copy link
Copy Markdown
Author

PR updated

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

Comment thread setup.py Outdated
packages=['safety_db'],
license='Attribution-NonCommercial-ShareAlike 4.0 International',
install_requires=[],
install_requires=['install_requires'],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

erm, setuptools

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...and 👍 for the quick response!

@pawamoy

pawamoy commented Nov 18, 2020

Copy link
Copy Markdown

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

pawamoy referenced this pull request Nov 18, 2020
Not doing so causes nothing in the data directory to be included in the
distribution.
@lingrlongr

Copy link
Copy Markdown

Any reason why this has not merged yet?

@m-aciek

m-aciek commented Dec 3, 2021

Copy link
Copy Markdown

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

@bollwyvl

bollwyvl commented Dec 3, 2021

Copy link
Copy Markdown

stdlib's importlib.resources

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

efokschaner added a commit to efokschaner/safety-db that referenced this pull request Feb 4, 2022
This is a updated fix for pyupio#2308
and supersedes pyupio#2309

It uses importlib.resources which means dropping
support for python 3.6 and below
@efokschaner

Copy link
Copy Markdown

I've made a version of this PR which uses importlib.resources as suggested #2351

Let's get import safety_db working again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants