Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/github_actions/pypa/gh-action-pyp…
Browse files Browse the repository at this point in the history
…i-publish-1.12.3
  • Loading branch information
santisoler authored Jan 6, 2025
2 parents 6ae493e + 5860444 commit e52f4b9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ For **package developers** including sample data in their projects:
"""
Module mypackage/datasets.py
"""
import pkg_resources
from importlib import resources
import pandas
import pooch

Expand Down Expand Up @@ -154,7 +154,7 @@ GOODBOY = pooch.create(
# manage large numbers of data files. The registry file should be packaged
# and distributed with your software.
GOODBOY.load_registry(
pkg_resources.resource_stream("mypackage", "registry.txt")
resources.open_text("mypackage", "registry.txt")
)

# Define functions that your users can call to get back the data in memory
Expand Down
9 changes: 5 additions & 4 deletions doc/registry-files.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ hashes in a file and use :meth:`pooch.Pooch.load_registry` to read them.
.. code:: python
import os
import pkg_resources
from importlib import resources
POOCH = pooch.create(
path=pooch.os_cache("plumbus"),
Expand All @@ -24,14 +24,15 @@ hashes in a file and use :meth:`pooch.Pooch.load_registry` to read them.
registry=None,
)
# Get registry file from package_data
registry_file = pkg_resources.resource_stream("plumbus", "registry.txt")
registry_file = resources.open_text("plumbus", "registry.txt")
# Load this registry file
POOCH.load_registry(registry_file)
In this case, the ``registry.txt`` file is in the ``plumbus/`` package
directory and should be shipped with the package (see below for instructions).
We use `pkg_resources <https://setuptools.readthedocs.io/en/latest/pkg_resources.html#basic-resource-access>`__
to access the ``registry.txt``, giving it the name of our Python package.
We use `importlib.resources
<https://docs.python.org/3/library/importlib.resources.html>`__ to access the
``registry.txt``, giving it the name of our Python package.

Registry file format
--------------------
Expand Down

0 comments on commit e52f4b9

Please sign in to comment.