Skip to content

Commit d1e9539

Browse files
committed
fix for registry.txt not packaged to pypi
1 parent ab158ea commit d1e9539

5 files changed

Lines changed: 32 additions & 23 deletions

File tree

MANIFEST.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include pyproject.toml
2+
include README.md
3+
include LICENSE
4+
recursive-include yabplot *.txt *.json *.md

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![PyPI version](https://img.shields.io/pypi/v/yabplot.svg)](https://pypi.org/project/yabplot/)
66
[![Docs](https://github.com/teanijarv/yabplot/actions/workflows/docs.yml/badge.svg)](https://teanijarv.github.io/yabplot/)
77
[![Tests](https://github.com/teanijarv/yabplot/actions/workflows/tests.yml/badge.svg)](https://github.com/teanijarv/yabplot/actions/workflows/tests.yml)
8-
<!-- [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.XXXXXX.svg)](https://doi.org/10.5281/zenodo.XXXXXX) -->
8+
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.18237144.svg)](https://doi.org/10.5281/zenodo.18237144)
99

1010
**yabplot** is a Python library for creating beautiful, publication-quality 3D brain visualizations. it supports plotting cortical regions, subcortical structures, and white matter bundles.
1111

@@ -71,4 +71,4 @@ yab.plot_tracts(data=data, atlas='xtract_tiny', figsize=(600, 300),
7171

7272
## acknowledgements
7373

74-
yabplot relies on the extensive work of the neuroimaging community. if you use these atlases in your work, please cite the original authors.
74+
yabplot relies on the extensive work of the neuroimaging community. if you use these atlases in your work, please cite the original authors. if you use this package for any scientific work, please cite the DOI (see more info on [Zenodo](https://doi.org/10.5281/zenodo.18237144)).

docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![PyPI version](https://img.shields.io/pypi/v/yabplot.svg)](https://pypi.org/project/yabplot/)
66
[![Docs](https://github.com/teanijarv/yabplot/actions/workflows/docs.yml/badge.svg)](https://teanijarv.github.io/yabplot/)
77
[![Tests](https://github.com/teanijarv/yabplot/actions/workflows/tests.yml/badge.svg)](https://github.com/teanijarv/yabplot/actions/workflows/tests.yml)
8-
<!-- [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.XXXXXX.svg)](https://doi.org/10.5281/zenodo.XXXXXX) -->
8+
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.18237144.svg)](https://doi.org/10.5281/zenodo.18237144)
99

1010
**yabplot** is a Python library for creating beautiful, publication-quality 3D brain visualizations. it supports plotting cortical regions, subcortical structures, and white matter bundles.
1111

@@ -71,4 +71,4 @@ yab.plot_tracts(data=data, atlas='xtract_tiny', figsize=(600, 300),
7171

7272
## acknowledgements
7373

74-
yabplot relies on the extensive work of the neuroimaging community. if you use these atlases in your work, please cite the original authors.
74+
yabplot relies on the extensive work of the neuroimaging community. if you use these atlases in your work, please cite the original authors. if you use this package for any scientific work, please cite the DOI (see more info on [Zenodo](https://doi.org/10.5281/zenodo.18237144)).

pyproject.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "yabplot"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
description = "yet another brain plot"
55
readme = "README.md"
66
requires-python = ">=3.10"
@@ -23,3 +23,10 @@ dependencies = [
2323
"mkdocs-material",
2424
"mkdocstrings[python]",
2525
]
26+
27+
[tool.setuptools.packages.find]
28+
where = ["."]
29+
include = ["yabplot*"]
30+
31+
[tool.setuptools.package-data]
32+
"yabplot" = ["*.txt", "*.json"]

yabplot/data/__init__.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,26 @@
44

55
import os
66
import glob
7-
import shutil
7+
from pathlib import Path
88
import pooch
9-
from importlib.resources import files
109

1110
from ..utils import parse_lut
1211

13-
__all__ = ['get_available_resources']
12+
__all__ = ['get_available_resources', 'get_atlas_regions']
1413

1514
# define cache location
16-
# e.g., ~/.cache/yabplot
1715
CACHE_DIR = pooch.os_cache("yabplot")
1816

1917
# setup registry
20-
_REGISTRY_PATH = files('yabplot.data').joinpath('registry.txt')
21-
_FETCHER = pooch.create(
18+
HERE = Path(__file__).parent
19+
REGISTRY_FILE = HERE / "registry.txt"
20+
21+
GOODBOY = pooch.create(
2222
path=CACHE_DIR,
23-
base_url="",
23+
base_url="",
2424
registry=None,
2525
)
26-
27-
if _REGISTRY_PATH.is_file():
28-
_FETCHER.load_registry(_REGISTRY_PATH)
26+
GOODBOY.load_registry(REGISTRY_FILE)
2927

3028

3129
def get_available_resources(category=None):
@@ -39,7 +37,7 @@ def get_available_resources(category=None):
3937
for that specific category.
4038
If None, returns a dictionary containing all categories and their options.
4139
"""
42-
if not _FETCHER.registry:
40+
if not GOODBOY.registry:
4341
return [] if category else {}
4442

4543
# helper to clean names: e.g., "cortical-aparc.zip" -> ("cortical", "aparc")
@@ -52,15 +50,15 @@ def _parse_key(key):
5250
# mode 1: specific category
5351
if category:
5452
available = []
55-
for key in _FETCHER.registry.keys():
53+
for key in GOODBOY.registry.keys():
5654
prefix, name = _parse_key(key)
5755
if prefix == category:
5856
available.append(name)
5957
return sorted(available)
6058

6159
# mode 2: all categories
6260
all_resources = {}
63-
for key in _FETCHER.registry.keys():
61+
for key in GOODBOY.registry.keys():
6462
prefix, name = _parse_key(key)
6563
if prefix and name:
6664
if prefix not in all_resources:
@@ -147,7 +145,7 @@ def _fetch_and_unpack(resource_key):
147145
and returns the extraction path.
148146
"""
149147
extract_dir_name = resource_key.replace(".zip", "")
150-
extract_path = os.path.join(_FETCHER.path, extract_dir_name)
148+
extract_path = os.path.join(GOODBOY.path, extract_dir_name)
151149

152150
# optimization: check if unpacked folder already exists
153151
# if yes, skip pooch check entirely to avoid re-downloading
@@ -156,17 +154,17 @@ def _fetch_and_unpack(resource_key):
156154

157155
# fetch and unzip
158156
try:
159-
_FETCHER.fetch(
157+
GOODBOY.fetch(
160158
resource_key,
161159
processor=pooch.Unzip(extract_dir=extract_dir_name)
162160
)
163161
except ValueError:
164162
# if key not in registry
165-
available = list(_FETCHER.registry.keys())
163+
available = list(GOODBOY.registry.keys())
166164
raise ValueError(f"Resource '{resource_key}' not found in registry.")
167165

168166
# cleanup: delete the source zip to save space
169-
zip_path = os.path.join(_FETCHER.path, resource_key)
167+
zip_path = os.path.join(GOODBOY.path, resource_key)
170168
if os.path.exists(zip_path):
171169
os.remove(zip_path)
172170

@@ -187,7 +185,7 @@ def _resolve_resource_path(name, category, custom_path=None):
187185
resource_key = f"{category}-{name}.zip"
188186

189187
# validate before fetching
190-
if resource_key not in _FETCHER.registry:
188+
if resource_key not in GOODBOY.registry:
191189
available = get_available_resources(category)
192190
human_cat = {
193191
'cortical': 'Cortical parcellations (vertices)',

0 commit comments

Comments
 (0)