Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update doc to use pkg_resources #120

Merged
merged 6 commits into from
Nov 18, 2019
Merged

Conversation

remram44
Copy link
Contributor

@remram44 remram44 commented Nov 7, 2019

Follow up on #117

Using pkg_resources instead of os.path calls is less error-prone and allows one's package to work from ZIPs (zip-safe).

Reminders

  • Run make format and make check to make sure the code follows the style guide.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Add new public functions/methods/classes to doc/api/index.rst.
  • Write detailed docstrings for all functions/methods.
  • If adding new functionality, add an example to the docstring, gallery, and/or tutorials.

@remram44
Copy link
Contributor Author

remram44 commented Nov 7, 2019

I expect some bike-shedding to happen here, I'm really not sure what's the best way to present this.

doc/usage.rst Outdated
The ``registry.txt`` file in this case is in the ``plumbus/`` directory module and should be
shipped with the package. We use `pkg_resources <https://setuptools.readthedocs.io/en/latest/pkg_resources.html#basic-resource-access)`__
to access it, giving it the name of our Python package (the one we'll put in ``setup.py``).
Its contents are:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wasn't sure what width is used for word-wrapping rst files. Also this link is too long 😅

Copy link
Member

Choose a reason for hiding this comment

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

😄 for rst files it doesn't really matter too much. I usually do 79 or 88 (whichever you prefer). Not much we can do about the link, though.

Copy link
Member

@leouieda leouieda left a comment

Choose a reason for hiding this comment

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

Thanks @remram44! Yeah, it's tricky to have opinionated docs but I find it useful. Actually, all my other packages using Pooch need to implement this change. Made a few minor comments on the wording but this is good overall.

doc/usage.rst Outdated
GOODBOY.load_registry(registry_file)

The ``registry.txt`` file in this case is in the ``plumbus/`` directory module and should be
shipped with the package. We use `pkg_resources <https://setuptools.readthedocs.io/en/latest/pkg_resources.html#basic-resource-access)`__
Copy link
Member

Choose a reason for hiding this comment

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

Maybe instead of "We use package_resources" you could say:

We access the file contents using pkg_resources (instead of os.path.dirname(__file__)) because it's safer alternative. For example, it makes sure our code can work out of a zip archive, which is necessary depending on how the user installs the package.

doc/usage.rst Outdated
# Load this registry file
GOODBOY.load_registry(registry_file)

The ``registry.txt`` file in this case is in the ``plumbus/`` directory module and should be
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The ``registry.txt`` file in this case is in the ``plumbus/`` directory module and should be
The ``registry.txt`` file is in the ``plumbus/`` directory (the package) and should be

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this repeats "the package"

Copy link
Member

Choose a reason for hiding this comment

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

Right, didn't see that one in the next line. Just feel like "directory module" sounds strange.

@leouieda
Copy link
Member

@remram44 I pushed a fix for the broken hyperlink and removed the repeated "package". Looks good to me now and will merge as soon as CIs are happy. Thank you for this! 👍

@leouieda leouieda merged commit 0809acd into fatiando:master Nov 18, 2019
@remram44 remram44 deleted the doc-pkg-resources branch November 18, 2019 18:49
leouieda added a commit to fatiando/verde that referenced this pull request Jan 16, 2020
With Pooch 0.7.0, the recommended way of loading the registry file is
with `pkg_resources` (see fatiando/pooch#120). It's also better to use
the default cache location so users can more easily clean up unused
files. Because this is system specific, add the `verde.datasets.locate`
function to return the cache folder location.
leouieda added a commit to fatiando/verde that referenced this pull request Jan 20, 2020
With Pooch 0.7.0, the recommended way of loading the registry file is
with `pkg_resources` (see fatiando/pooch#120). It's also better to use
the default cache location so users can more easily clean up unused
files. Because this is system specific, add the `verde.datasets.locate`
function to return the cache folder location.
leouieda added a commit to fatiando/harmonica that referenced this pull request Jan 20, 2020
With Pooch 0.7.0, the recommended way of loading the registry file is
with `pkg_resources` (see fatiando/pooch#120). It's also better to use
the default cache location so users can more easily clean up unused
files. Because this is system specific, add the
`harmonica.datasets.locate` function to return the cache folder
location.
santisoler pushed a commit to fatiando/harmonica that referenced this pull request Jan 21, 2020
With Pooch 0.7.0, the recommended way of loading the registry file is
with `pkg_resources` (see fatiando/pooch#120). It's also better to use
the default cache location so users can more easily clean up unused
files. Because this is system specific, add the
`harmonica.datasets.locate` function to return the cache folder
location.
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants