From f91a8ae9c6382f9f63ccabb219a9b0e6e2d4fd56 Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Mon, 24 Jun 2024 14:51:10 -0700 Subject: [PATCH 01/10] Start moving folders and files to src-layout --- {pooch => src/pooch}/__init__.py | 0 {pooch => src/pooch}/core.py | 0 {pooch => src/pooch}/downloaders.py | 0 {pooch => src/pooch}/hashes.py | 0 {pooch => src/pooch}/processors.py | 0 {pooch => src/pooch}/utils.py | 0 {pooch/tests => tests}/__init__.py | 0 {pooch/tests => tests}/data/large-data.txt | 0 {pooch/tests => tests}/data/registry-custom-url.txt | 0 {pooch/tests => tests}/data/registry-invalid.txt | 0 {pooch/tests => tests}/data/registry-spaces.txt | 0 {pooch/tests => tests}/data/registry.txt | 0 {pooch/tests => tests}/data/registry_comments.txt | 0 {pooch/tests => tests}/data/store.tar.gz | Bin {pooch/tests => tests}/data/store.zip | Bin .../tests => tests}/data/store/subdir/tiny-data.txt | 0 {pooch/tests => tests}/data/store/tiny-data.txt | 0 {pooch/tests => tests}/data/tiny-data.tar.gz | Bin {pooch/tests => tests}/data/tiny-data.txt | 0 {pooch/tests => tests}/data/tiny-data.txt.bz2 | Bin {pooch/tests => tests}/data/tiny-data.txt.gz | Bin {pooch/tests => tests}/data/tiny-data.txt.xz | Bin {pooch/tests => tests}/data/tiny-data.zip | Bin {pooch/tests => tests}/test_core.py | 0 {pooch/tests => tests}/test_downloaders.py | 0 {pooch/tests => tests}/test_hashes.py | 0 {pooch/tests => tests}/test_integration.py | 0 {pooch/tests => tests}/test_processors.py | 0 {pooch/tests => tests}/test_utils.py | 0 {pooch/tests => tests}/test_version.py | 0 {pooch/tests => tests}/utils.py | 0 31 files changed, 0 insertions(+), 0 deletions(-) rename {pooch => src/pooch}/__init__.py (100%) rename {pooch => src/pooch}/core.py (100%) rename {pooch => src/pooch}/downloaders.py (100%) rename {pooch => src/pooch}/hashes.py (100%) rename {pooch => src/pooch}/processors.py (100%) rename {pooch => src/pooch}/utils.py (100%) rename {pooch/tests => tests}/__init__.py (100%) rename {pooch/tests => tests}/data/large-data.txt (100%) rename {pooch/tests => tests}/data/registry-custom-url.txt (100%) rename {pooch/tests => tests}/data/registry-invalid.txt (100%) rename {pooch/tests => tests}/data/registry-spaces.txt (100%) rename {pooch/tests => tests}/data/registry.txt (100%) rename {pooch/tests => tests}/data/registry_comments.txt (100%) rename {pooch/tests => tests}/data/store.tar.gz (100%) rename {pooch/tests => tests}/data/store.zip (100%) rename {pooch/tests => tests}/data/store/subdir/tiny-data.txt (100%) rename {pooch/tests => tests}/data/store/tiny-data.txt (100%) rename {pooch/tests => tests}/data/tiny-data.tar.gz (100%) rename {pooch/tests => tests}/data/tiny-data.txt (100%) rename {pooch/tests => tests}/data/tiny-data.txt.bz2 (100%) rename {pooch/tests => tests}/data/tiny-data.txt.gz (100%) rename {pooch/tests => tests}/data/tiny-data.txt.xz (100%) rename {pooch/tests => tests}/data/tiny-data.zip (100%) rename {pooch/tests => tests}/test_core.py (100%) rename {pooch/tests => tests}/test_downloaders.py (100%) rename {pooch/tests => tests}/test_hashes.py (100%) rename {pooch/tests => tests}/test_integration.py (100%) rename {pooch/tests => tests}/test_processors.py (100%) rename {pooch/tests => tests}/test_utils.py (100%) rename {pooch/tests => tests}/test_version.py (100%) rename {pooch/tests => tests}/utils.py (100%) diff --git a/pooch/__init__.py b/src/pooch/__init__.py similarity index 100% rename from pooch/__init__.py rename to src/pooch/__init__.py diff --git a/pooch/core.py b/src/pooch/core.py similarity index 100% rename from pooch/core.py rename to src/pooch/core.py diff --git a/pooch/downloaders.py b/src/pooch/downloaders.py similarity index 100% rename from pooch/downloaders.py rename to src/pooch/downloaders.py diff --git a/pooch/hashes.py b/src/pooch/hashes.py similarity index 100% rename from pooch/hashes.py rename to src/pooch/hashes.py diff --git a/pooch/processors.py b/src/pooch/processors.py similarity index 100% rename from pooch/processors.py rename to src/pooch/processors.py diff --git a/pooch/utils.py b/src/pooch/utils.py similarity index 100% rename from pooch/utils.py rename to src/pooch/utils.py diff --git a/pooch/tests/__init__.py b/tests/__init__.py similarity index 100% rename from pooch/tests/__init__.py rename to tests/__init__.py diff --git a/pooch/tests/data/large-data.txt b/tests/data/large-data.txt similarity index 100% rename from pooch/tests/data/large-data.txt rename to tests/data/large-data.txt diff --git a/pooch/tests/data/registry-custom-url.txt b/tests/data/registry-custom-url.txt similarity index 100% rename from pooch/tests/data/registry-custom-url.txt rename to tests/data/registry-custom-url.txt diff --git a/pooch/tests/data/registry-invalid.txt b/tests/data/registry-invalid.txt similarity index 100% rename from pooch/tests/data/registry-invalid.txt rename to tests/data/registry-invalid.txt diff --git a/pooch/tests/data/registry-spaces.txt b/tests/data/registry-spaces.txt similarity index 100% rename from pooch/tests/data/registry-spaces.txt rename to tests/data/registry-spaces.txt diff --git a/pooch/tests/data/registry.txt b/tests/data/registry.txt similarity index 100% rename from pooch/tests/data/registry.txt rename to tests/data/registry.txt diff --git a/pooch/tests/data/registry_comments.txt b/tests/data/registry_comments.txt similarity index 100% rename from pooch/tests/data/registry_comments.txt rename to tests/data/registry_comments.txt diff --git a/pooch/tests/data/store.tar.gz b/tests/data/store.tar.gz similarity index 100% rename from pooch/tests/data/store.tar.gz rename to tests/data/store.tar.gz diff --git a/pooch/tests/data/store.zip b/tests/data/store.zip similarity index 100% rename from pooch/tests/data/store.zip rename to tests/data/store.zip diff --git a/pooch/tests/data/store/subdir/tiny-data.txt b/tests/data/store/subdir/tiny-data.txt similarity index 100% rename from pooch/tests/data/store/subdir/tiny-data.txt rename to tests/data/store/subdir/tiny-data.txt diff --git a/pooch/tests/data/store/tiny-data.txt b/tests/data/store/tiny-data.txt similarity index 100% rename from pooch/tests/data/store/tiny-data.txt rename to tests/data/store/tiny-data.txt diff --git a/pooch/tests/data/tiny-data.tar.gz b/tests/data/tiny-data.tar.gz similarity index 100% rename from pooch/tests/data/tiny-data.tar.gz rename to tests/data/tiny-data.tar.gz diff --git a/pooch/tests/data/tiny-data.txt b/tests/data/tiny-data.txt similarity index 100% rename from pooch/tests/data/tiny-data.txt rename to tests/data/tiny-data.txt diff --git a/pooch/tests/data/tiny-data.txt.bz2 b/tests/data/tiny-data.txt.bz2 similarity index 100% rename from pooch/tests/data/tiny-data.txt.bz2 rename to tests/data/tiny-data.txt.bz2 diff --git a/pooch/tests/data/tiny-data.txt.gz b/tests/data/tiny-data.txt.gz similarity index 100% rename from pooch/tests/data/tiny-data.txt.gz rename to tests/data/tiny-data.txt.gz diff --git a/pooch/tests/data/tiny-data.txt.xz b/tests/data/tiny-data.txt.xz similarity index 100% rename from pooch/tests/data/tiny-data.txt.xz rename to tests/data/tiny-data.txt.xz diff --git a/pooch/tests/data/tiny-data.zip b/tests/data/tiny-data.zip similarity index 100% rename from pooch/tests/data/tiny-data.zip rename to tests/data/tiny-data.zip diff --git a/pooch/tests/test_core.py b/tests/test_core.py similarity index 100% rename from pooch/tests/test_core.py rename to tests/test_core.py diff --git a/pooch/tests/test_downloaders.py b/tests/test_downloaders.py similarity index 100% rename from pooch/tests/test_downloaders.py rename to tests/test_downloaders.py diff --git a/pooch/tests/test_hashes.py b/tests/test_hashes.py similarity index 100% rename from pooch/tests/test_hashes.py rename to tests/test_hashes.py diff --git a/pooch/tests/test_integration.py b/tests/test_integration.py similarity index 100% rename from pooch/tests/test_integration.py rename to tests/test_integration.py diff --git a/pooch/tests/test_processors.py b/tests/test_processors.py similarity index 100% rename from pooch/tests/test_processors.py rename to tests/test_processors.py diff --git a/pooch/tests/test_utils.py b/tests/test_utils.py similarity index 100% rename from pooch/tests/test_utils.py rename to tests/test_utils.py diff --git a/pooch/tests/test_version.py b/tests/test_version.py similarity index 100% rename from pooch/tests/test_version.py rename to tests/test_version.py diff --git a/pooch/tests/utils.py b/tests/utils.py similarity index 100% rename from pooch/tests/utils.py rename to tests/utils.py From de1f85528116c51db596ad3b7c241ba607c2830b Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Mon, 24 Jun 2024 15:02:32 -0700 Subject: [PATCH 02/10] Change location of _version.py file --- .gitignore | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index bf37484c..77e7cf19 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,4 @@ doc/api/generated *.egg-info MANIFEST .coverage.* -pooch/_version.py +src/pooch/_version.py diff --git a/pyproject.toml b/pyproject.toml index 1bfb3adb..cea607b1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,7 +60,7 @@ build-backend = "setuptools.build_meta" [tool.setuptools_scm] version_scheme = "post-release" local_scheme = "node-and-date" -write_to = "pooch/_version.py" +write_to = "src/pooch/_version.py" [tool.pytest.ini_options] markers = [ From 1a21ff0d66bcfbdb92a401605252a78343fcdb40 Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Mon, 24 Jun 2024 15:03:06 -0700 Subject: [PATCH 03/10] Configure setuptools find --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index cea607b1..32706f87 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,8 +45,8 @@ xxhash = ["xxhash>=1.4.3"] "Bug Tracker" = "https://github.com/fatiando/pooch/issues" "Source Code" = "https://github.com/fatiando/pooch" -[tool.setuptools.packages] -find = {} # Scanning implicit namespaces is active by default +[tool.setuptools.packages.find] +where = ["src"] [tool.setuptools.package-data] "pooch.tests.data" = ["*.txt", "*.zip", "*.gz", "*.xz", "*.bz2"] From d3db2e10bf68138c3741978ec28c0d363ebb25bb Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Mon, 24 Jun 2024 15:04:40 -0700 Subject: [PATCH 04/10] Update Makefile Change the commands for the `test` target. Update some locations in the `clean` target. --- Makefile | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 9d7ec156..4bd4a616 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # Build, package, test, and clean PROJECT=pooch -TESTDIR=tmp-test-dir-with-unique-name -PYTEST_ARGS=--cov-config=../.coveragerc --cov-report=term-missing --cov=$(PROJECT) --doctest-modules -v --pyargs +TESTS=tests +PYTEST_ARGS=--cov-config=.coveragerc --cov-report=term-missing --cov=$(PROJECT) --doctest-modules -v --pyargs LINT_FILES=$(PROJECT) CHECK_STYLE=$(PROJECT) doc @@ -24,11 +24,7 @@ install: python -m pip install --no-deps -e . test: - # Run a tmp folder to make sure the tests are run on the installed version - mkdir -p $(TESTDIR) - cd $(TESTDIR); pytest $(PYTEST_ARGS) $(PROJECT) - cp $(TESTDIR)/.coverage* . - rm -r $(TESTDIR) + pytest $(PYTEST_ARGS) $(TESTS) format: black $(CHECK_STYLE) @@ -50,5 +46,5 @@ clean: find . -name "*.pyc" -exec rm -v {} \; find . -name "*.orig" -exec rm -v {} \; find . -name ".coverage.*" -exec rm -v {} \; - rm -rvf build dist MANIFEST *.egg-info __pycache__ .coverage .cache .pytest_cache $(PROJECT)/_version.py - rm -rvf $(TESTDIR) dask-worker-space + rm -rvf build dist MANIFEST *.egg-info __pycache__ .coverage .cache .pytest_cache src/$(PROJECT)/_version.py + rm -rvf dask-worker-space From 02a31b010dcf5bc1b184fd0c766736e8dbbb558a Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Mon, 24 Jun 2024 15:05:29 -0700 Subject: [PATCH 05/10] Add .PHONY to Makefile --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 4bd4a616..510fdf6a 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,8 @@ PYTEST_ARGS=--cov-config=.coveragerc --cov-report=term-missing --cov=$(PROJECT) LINT_FILES=$(PROJECT) CHECK_STYLE=$(PROJECT) doc +.PHONY: help build install test format check check-format check-style lint clean + help: @echo "Commands:" @echo "" From ae150354592065a363029177f05478046c8c3c39 Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Mon, 24 Jun 2024 15:16:36 -0700 Subject: [PATCH 06/10] Update imports in tests Replace relative imports in tests to absolute imports. --- tests/test_core.py | 10 +++++----- tests/test_downloaders.py | 6 +++--- tests/test_hashes.py | 4 ++-- tests/test_integration.py | 4 ++-- tests/test_processors.py | 4 ++-- tests/test_utils.py | 2 +- tests/utils.py | 4 ++-- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/test_core.py b/tests/test_core.py index fceda0a0..8be7773b 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -15,13 +15,13 @@ import pytest -from ..core import create, Pooch, retrieve, download_action, stream_download -from ..utils import get_logger, temporary_file, os_cache -from ..hashes import file_hash, hash_matches +from pooch.core import create, Pooch, retrieve, download_action, stream_download +from pooch.utils import get_logger, temporary_file, os_cache +from pooch.hashes import file_hash, hash_matches # Import the core module so that we can monkeypatch some functions -from .. import core -from ..downloaders import HTTPDownloader, FTPDownloader +from pooch import core +from pooch.downloaders import HTTPDownloader, FTPDownloader from .utils import ( pooch_test_url, diff --git a/tests/test_downloaders.py b/tests/test_downloaders.py index 14e32f92..0c084cfd 100644 --- a/tests/test_downloaders.py +++ b/tests/test_downloaders.py @@ -23,8 +23,8 @@ except ImportError: paramiko = None -from .. import Pooch -from ..downloaders import ( +from pooch import Pooch +from pooch.downloaders import ( HTTPDownloader, FTPDownloader, SFTPDownloader, @@ -35,7 +35,7 @@ DataverseRepository, doi_to_url, ) -from ..processors import Unzip +from pooch.processors import Unzip from .utils import ( pooch_test_url, check_large_data, diff --git a/tests/test_hashes.py b/tests/test_hashes.py index cf6897e2..0db32504 100644 --- a/tests/test_hashes.py +++ b/tests/test_hashes.py @@ -22,8 +22,8 @@ xxhash = None XXHASH_MAJOR_VERSION = 0 -from ..core import Pooch -from ..hashes import ( +from pooch.core import Pooch +from pooch.hashes import ( make_registry, file_hash, hash_matches, diff --git a/tests/test_integration.py b/tests/test_integration.py index 831a41f9..e09e02c9 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -14,8 +14,8 @@ import pytest -from .. import create, os_cache -from .. import __version__ as full_version +from pooch import create, os_cache +from pooch import __version__ as full_version from .utils import check_tiny_data, capture_log diff --git a/tests/test_processors.py b/tests/test_processors.py index 1a2a1e2a..f4174099 100644 --- a/tests/test_processors.py +++ b/tests/test_processors.py @@ -13,8 +13,8 @@ import pytest -from .. import Pooch -from ..processors import Unzip, Untar, Decompress +from pooch import Pooch +from pooch.processors import Unzip, Untar, Decompress from .utils import pooch_test_url, pooch_test_registry, check_tiny_data, capture_log diff --git a/tests/test_utils.py b/tests/test_utils.py index 71401297..09bad6a6 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -17,7 +17,7 @@ import pytest -from ..utils import ( +from pooch.utils import ( parse_url, make_local_storage, temporary_file, diff --git a/tests/utils.py b/tests/utils.py index a248ead7..fe0b8a4c 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -15,8 +15,8 @@ from pathlib import Path from contextlib import contextmanager -from .. import __version__ as full_version -from ..utils import check_version, get_logger +from pooch import __version__ as full_version +from pooch.utils import check_version, get_logger def check_tiny_data(fname): From 2d6289cdba0458c7fa2dca33e5f6e297e3d2885b Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Mon, 24 Jun 2024 15:26:13 -0700 Subject: [PATCH 07/10] Remove test data from MANIFEST.in --- MANIFEST.in | 1 - 1 file changed, 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index fc94b5de..9688f73c 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -12,4 +12,3 @@ exclude Makefile exclude .gitignore exclude .gitattributes exclude environment.yml -include pooch/tests/data From 7534686d0a9b6cab2d8495597a3cdb1e293308fa Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Tue, 25 Jun 2024 09:33:14 -0700 Subject: [PATCH 08/10] Update path to source code in Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 510fdf6a..fb596ac9 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ PROJECT=pooch TESTS=tests PYTEST_ARGS=--cov-config=.coveragerc --cov-report=term-missing --cov=$(PROJECT) --doctest-modules -v --pyargs LINT_FILES=$(PROJECT) -CHECK_STYLE=$(PROJECT) doc +CHECK_STYLE=src/$(PROJECT) doc .PHONY: help build install test format check check-format check-style lint clean From 5a6340b1bbe911bc6e2a91dafe11fb644407dd6a Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Tue, 25 Jun 2024 11:50:14 -0700 Subject: [PATCH 09/10] Install Pooch before running pylint in Actions --- .github/workflows/style.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index 87e9d4db..b8a4421b 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -32,6 +32,10 @@ jobs: - name: Install requirements run: python -m pip install -r env/requirements-style.txt + # Need to install Pooch to allow pylint to run + - name: Install Pooch + run: python -m pip install . + - name: List installed packages run: python -m pip freeze From 64a9b24ffaf54f6be40ace097d11b6de4a1450dd Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Tue, 25 Jun 2024 12:02:55 -0700 Subject: [PATCH 10/10] Include src in test target to run doctests --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index fb596ac9..60715fb2 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # Build, package, test, and clean PROJECT=pooch -TESTS=tests +TESTS=tests src/$(PROJECT) PYTEST_ARGS=--cov-config=.coveragerc --cov-report=term-missing --cov=$(PROJECT) --doctest-modules -v --pyargs LINT_FILES=$(PROJECT) CHECK_STYLE=src/$(PROJECT) doc