fpathlib 0.1.3__tar.gz → 0.1.4.dev12__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. {fpathlib-0.1.3/src/fpathlib.egg-info → fpathlib-0.1.4.dev12}/PKG-INFO +1 -1
  2. fpathlib-0.1.4.dev12/conda-recipe/meta.yaml +39 -0
  3. fpathlib-0.1.4.dev12/scripts/conda.sh +50 -0
  4. fpathlib-0.1.4.dev12/scripts/deploy.sh +13 -0
  5. fpathlib-0.1.4.dev12/scripts/pypi.sh +35 -0
  6. fpathlib-0.1.4.dev12/scripts/tag.sh +56 -0
  7. {fpathlib-0.1.3 → fpathlib-0.1.4.dev12}/src/fpathlib/_version.py +3 -3
  8. {fpathlib-0.1.3 → fpathlib-0.1.4.dev12}/src/fpathlib/expand.py +2 -1
  9. {fpathlib-0.1.3 → fpathlib-0.1.4.dev12}/src/fpathlib/ext/polars.py +32 -0
  10. {fpathlib-0.1.3 → fpathlib-0.1.4.dev12}/src/fpathlib/fpath.py +33 -1
  11. {fpathlib-0.1.3 → fpathlib-0.1.4.dev12/src/fpathlib.egg-info}/PKG-INFO +1 -1
  12. {fpathlib-0.1.3 → fpathlib-0.1.4.dev12}/src/fpathlib.egg-info/SOURCES.txt +2 -0
  13. {fpathlib-0.1.3 → fpathlib-0.1.4.dev12}/src/fpathlib.egg-info/scm_file_list.json +2 -0
  14. fpathlib-0.1.4.dev12/src/fpathlib.egg-info/scm_version.json +8 -0
  15. fpathlib-0.1.3/scripts/deploy.sh +0 -3
  16. fpathlib-0.1.3/scripts/pypi.sh +0 -20
  17. fpathlib-0.1.3/scripts/tag.sh +0 -33
  18. fpathlib-0.1.3/src/fpathlib.egg-info/scm_version.json +0 -8
  19. {fpathlib-0.1.3 → fpathlib-0.1.4.dev12}/.gitignore +0 -0
  20. {fpathlib-0.1.3 → fpathlib-0.1.4.dev12}/LICENSE +0 -0
  21. {fpathlib-0.1.3 → fpathlib-0.1.4.dev12}/MANIFEST.in +0 -0
  22. {fpathlib-0.1.3 → fpathlib-0.1.4.dev12}/README.md +0 -0
  23. {fpathlib-0.1.3 → fpathlib-0.1.4.dev12}/TODO.txt +0 -0
  24. {fpathlib-0.1.3 → fpathlib-0.1.4.dev12}/docs/Makefile +0 -0
  25. {fpathlib-0.1.3 → fpathlib-0.1.4.dev12}/docs/make.bat +0 -0
  26. {fpathlib-0.1.3 → fpathlib-0.1.4.dev12}/docs/source/api.rst +0 -0
  27. {fpathlib-0.1.3 → fpathlib-0.1.4.dev12}/docs/source/conf.py +0 -0
  28. {fpathlib-0.1.3 → fpathlib-0.1.4.dev12}/docs/source/index.rst +0 -0
  29. {fpathlib-0.1.3 → fpathlib-0.1.4.dev12}/pyproject.toml +0 -0
  30. {fpathlib-0.1.3 → fpathlib-0.1.4.dev12}/scripts/docs.sh +0 -0
  31. {fpathlib-0.1.3 → fpathlib-0.1.4.dev12}/setup.cfg +0 -0
  32. {fpathlib-0.1.3 → fpathlib-0.1.4.dev12}/src/fpathlib/__init__.py +0 -0
  33. {fpathlib-0.1.3 → fpathlib-0.1.4.dev12}/src/fpathlib/ext/__init__.py +0 -0
  34. {fpathlib-0.1.3 → fpathlib-0.1.4.dev12}/src/fpathlib/path.py +0 -0
  35. {fpathlib-0.1.3 → fpathlib-0.1.4.dev12}/src/fpathlib/utils.py +0 -0
  36. {fpathlib-0.1.3 → fpathlib-0.1.4.dev12}/src/fpathlib.egg-info/dependency_links.txt +0 -0
  37. {fpathlib-0.1.3 → fpathlib-0.1.4.dev12}/src/fpathlib.egg-info/requires.txt +0 -0
  38. {fpathlib-0.1.3 → fpathlib-0.1.4.dev12}/src/fpathlib.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fpathlib
3
- Version: 0.1.3
3
+ Version: 0.1.4.dev12
4
4
  Summary: A package to combine paths with metadata
5
5
  Author-email: "C. Lockhart" <clockha2@gmu.edu>
6
6
  Requires-Python: >=3.12
@@ -0,0 +1,39 @@
1
+ {% set name = "fpathlib" %}
2
+ {% set version = "0.1.3" %}
3
+
4
+ package:
5
+ name: {{ name|lower }}
6
+ version: {{ version }}
7
+
8
+ source:
9
+ url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/fpathlib-{{ version }}.tar.gz
10
+ sha256: 059dbf937c6e965ef33f15aa214b2f354550d5dfa26b9030357954cce8c51874
11
+
12
+ build:
13
+ noarch: python
14
+ number: 0
15
+ script: {{ PYTHON }} -m pip install . -vv --no-deps --no-build-isolation
16
+
17
+ requirements:
18
+ host:
19
+ - python >=3.12
20
+ - pip
21
+ - setuptools >=68
22
+ - setuptools_scm
23
+ - wheel
24
+ run:
25
+ - python >=3.12
26
+ - parse
27
+
28
+ test:
29
+ imports:
30
+ - fpathlib
31
+
32
+ about:
33
+ summary: A package to combine paths with metadata
34
+ license: MIT
35
+ home: https://github.com/LockhartLab/fpathlib
36
+
37
+ extra:
38
+ recipe-maintainers:
39
+ - clockhart
@@ -0,0 +1,50 @@
1
+ # Builds and uploads the conda package for the version pypi.sh just
2
+ # published, to the lockhartlab org on anaconda.org. Must run AFTER
3
+ # pypi.sh, since it reads the sdist checksum back from PyPI's JSON API
4
+ # (retrying briefly -- new uploads take a few seconds to index).
5
+ #
6
+ # Requires a local micromamba env named "fpathlib-build" with conda-build
7
+ # and anaconda-client installed, and an active `anaconda login --at
8
+ # anaconda.org` session for an account with upload rights to lockhartlab:
9
+ # micromamba create -n fpathlib-build -c conda-forge conda-build anaconda-client
10
+ # micromamba run -n fpathlib-build anaconda login --at anaconda.org
11
+
12
+ version=$(git describe --tags --abbrev=0)
13
+
14
+ sha256=""
15
+ for i in 1 2 3 4 5
16
+ do
17
+ sha256=$(curl -s "https://pypi.org/pypi/fpathlib/$version/json" | python3 -c "
18
+ import json, sys
19
+ try:
20
+ d = json.load(sys.stdin)
21
+ for f in d['urls']:
22
+ if f['filename'].endswith('.tar.gz'):
23
+ print(f['digests']['sha256'])
24
+ break
25
+ except Exception:
26
+ pass
27
+ ")
28
+ if [ -n "$sha256" ]
29
+ then
30
+ break
31
+ fi
32
+ sleep 5
33
+ done
34
+
35
+ if [ -z "$sha256" ]
36
+ then
37
+ echo "could not fetch sdist sha256 from PyPI for $version yet, skipping conda build -- rerun scripts/conda.sh once PyPI has indexed the release"
38
+ return
39
+ fi
40
+
41
+ sed -i '' -E "s/\{% set version = \"[^\"]+\" %\}/{% set version = \"$version\" %}/" conda-recipe/meta.yaml
42
+ sed -i '' -E "s/sha256: .+/sha256: $sha256/" conda-recipe/meta.yaml
43
+
44
+ rm -rf /tmp/conda-build-out
45
+ micromamba run -n fpathlib-build conda-build conda-recipe -c conda-forge --output-folder /tmp/conda-build-out
46
+ micromamba run -n fpathlib-build anaconda upload "/tmp/conda-build-out/noarch/fpathlib-$version-py_0.conda" --user lockhartlab
47
+
48
+ git add conda-recipe/meta.yaml
49
+ git commit -m "conda-recipe: bump to $version"
50
+ git push origin main
@@ -0,0 +1,13 @@
1
+ # Full release: build docs, bump+push the patch tag, build and upload to
2
+ # PyPI, then build and upload to conda (lockhartlab org). Order matters --
3
+ # tag.sh must run before pypi.sh so that HEAD is exactly on the new tag
4
+ # (clean release, no .devN) when pypi.sh builds, and conda.sh must run
5
+ # after pypi.sh since it packages what was just published to PyPI.
6
+ # For an interim dev release without cutting a tag, run
7
+ # `source scripts/pypi.sh dev` directly instead of this script.
8
+ set -e
9
+
10
+ source scripts/docs.sh
11
+ source scripts/tag.sh "patch"
12
+ source scripts/pypi.sh
13
+ source scripts/conda.sh
@@ -0,0 +1,35 @@
1
+ # Builds and (usually) uploads to PyPI. setuptools_scm derives the version
2
+ # purely from git: exactly on a tag with a clean tree -> "X.Y.Z"; ahead of
3
+ # the last tag, or a dirty tree -> "X.Y.Z.devN". Run this on its own (e.g.
4
+ # `source scripts/pypi.sh dev`) to intentionally publish an interim dev
5
+ # build while iterating; deploy.sh runs tag.sh first so that by the time
6
+ # this script runs, HEAD should be exactly on the new tag and produce a
7
+ # clean release -- if it doesn't, something upstream is wrong (see below).
8
+ allow_dev=0
9
+ if [ "$1" = "dev" ]
10
+ then
11
+ allow_dev=1
12
+ fi
13
+
14
+ # Stale dist/ or egg-info from a previous failed run can leak into `twine
15
+ # upload dist/*` (multiple versions at once) or shadow a fresh build.
16
+ rm -rf dist src/fpathlib.egg-info
17
+
18
+ python3 -m build
19
+
20
+ # Belt-and-suspenders check: rather than trust git state ahead of time (the
21
+ # 0.1.3/0.1.2 tag-collision incident slipped past a git-describe check even
22
+ # though the build itself came out as a .devN), inspect what actually got
23
+ # built. This is the real signal of whether the release is clean.
24
+ dev_artifacts=$(ls dist/ | grep -c '\.dev[0-9]')
25
+ if [ $allow_dev -eq 0 ] && [ "$dev_artifacts" != "0" ]
26
+ then
27
+ echo "built version is a dev version (tag doesn't point at a clean, distinct commit -- check 'git describe --tags --long' and 'git status'), not uploading to pypi"
28
+ rm -r dist
29
+ rm -r src/fpathlib.egg-info
30
+ return
31
+ fi
32
+
33
+ twine upload --verbose dist/*
34
+ rm -r dist
35
+ rm -r src/fpathlib.egg-info
@@ -0,0 +1,56 @@
1
+ # Bumps the version tag and pushes it. This MUST leave HEAD on a commit that
2
+ # is not shared with any older tag, or setuptools_scm can't tell the new tag
3
+ # apart from the old one and pypi.sh will build a .devN version instead of a
4
+ # clean release (see the 0.1.3/0.1.2 incident: both tags landed on the same
5
+ # commit because there was nothing new to commit, so setuptools_scm treated
6
+ # the checkout as ambiguous).
7
+ set -e
8
+
9
+ m=$1
10
+
11
+ tag=$(git describe --tags --abbrev=0)
12
+ parts=(${tag//./ })
13
+ if [ "$m" == "major" ]
14
+ then
15
+ parts[0]=$((parts[0]+1))
16
+ parts[1]=0
17
+ parts[2]=0
18
+ elif [ "$m" == "minor" ]
19
+ then
20
+ parts[1]=$((parts[1]+1))
21
+ parts[2]=0
22
+ elif [ "$m" == "patch" ]
23
+ then
24
+ parts[2]=$((parts[2]+1))
25
+ else
26
+ echo "must specify major, minor, or patch"
27
+ return
28
+ fi
29
+ tag="${parts[0]}.${parts[1]}.${parts[2]}"
30
+
31
+ # Fail loudly instead of leaving a stale/misplaced tag if $tag already exists
32
+ # (locally or on origin) -- creating it again would either error out partway
33
+ # through or, worse, silently retag the wrong commit.
34
+ if git rev-parse -q --verify "refs/tags/$tag" >/dev/null
35
+ then
36
+ echo "tag $tag already exists locally -- delete it first (git tag -d $tag) if you really want to redo this release"
37
+ return
38
+ fi
39
+ if git ls-remote --exit-code --tags origin "$tag" >/dev/null 2>&1
40
+ then
41
+ echo "tag $tag already exists on origin -- delete it first (git push origin :refs/tags/$tag) if you really want to redo this release"
42
+ return
43
+ fi
44
+
45
+ git add -A
46
+ # --allow-empty is required: if there's nothing to commit (working tree
47
+ # already clean), a plain `git commit` would no-op and this tag would end up
48
+ # pointing at the SAME commit as the previous tag, confusing setuptools_scm.
49
+ git commit --allow-empty -m "tag $tag"
50
+ git push origin main
51
+
52
+ git checkout main
53
+ git pull origin main
54
+
55
+ git tag $tag
56
+ git push origin $tag
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '0.1.3'
22
- __version_tuple__ = version_tuple = (0, 1, 3)
21
+ __version__ = version = '0.1.4.dev12'
22
+ __version_tuple__ = version_tuple = (0, 1, 4, 'dev12')
23
23
 
24
- __commit_id__ = commit_id = 'g02b650d92'
24
+ __commit_id__ = commit_id = 'g2ae3f3b01'
@@ -88,7 +88,8 @@ def expand_fpath_decorator(f=None, require_expandable=True, post_process=None):
88
88
 
89
89
  def is_expandable(fpath):
90
90
  """
91
- Check if expandable.
91
+ Check whether `fpath` has fpathlib's own named f-string captures (e.g.
92
+ `{name}`).
92
93
 
93
94
  Parameters
94
95
  ----------
@@ -169,6 +169,7 @@ def scan_txt(
169
169
  has_header=False,
170
170
  keep_line=False,
171
171
  usecols=None,
172
+ validate_schema=True,
172
173
  *args,
173
174
  **kwargs,
174
175
  ):
@@ -198,6 +199,17 @@ def scan_txt(
198
199
  Whether to keep the original line as a column in the output.
199
200
  usecols : :obj:`list`[:obj:`int`], optional
200
201
  Indexes of columns to keep in the output. If not provided, all columns are kept. Only applicable if `separator` is provided.
202
+ validate_schema : :obj:`bool`
203
+ When the field count is inferred from a single representative file
204
+ (the fast path for a multi-file glob/pattern), also check that no
205
+ *other* matched file has *more* fields than that sample. A file with
206
+ fewer fields than the sample already raises a clear polars error
207
+ (out-of-bounds list access); a file with more fields would otherwise
208
+ have its extra columns silently dropped instead of erroring. This
209
+ check reads every matched file's line count, which costs an extra
210
+ full pass over the data on top of the fast path -- pass False if
211
+ you've already confirmed your files are consistent and want to
212
+ skip it for speed on very large globs. (Default: True)
201
213
  *args
202
214
  Positional arguments to pass to :meth:`polars.scan_csv`.
203
215
  **kwargs
@@ -282,6 +294,26 @@ def scan_txt(
282
294
  # Initial field names, may be renamed later from header or by `new_columns`
283
295
  fields = {i: f"field_{i}" for i in range(n_fields)}
284
296
 
297
+ # n_fields came from a single sample file (see above), so a file
298
+ # with *fewer* fields than the sample will already raise a clear
299
+ # polars error below (list.get() on an out-of-bounds index). A
300
+ # file with *more* fields would not -- its extra columns would
301
+ # just be silently dropped -- so check for that explicitly if
302
+ # requested.
303
+ if validate_schema and sample_schema is not None:
304
+ max_fields = (
305
+ lf.select(_polars.col("fields").list.len().max())
306
+ .collect()
307
+ .item()
308
+ )
309
+ if max_fields is not None and max_fields > n_fields:
310
+ msg = (
311
+ f"field count mismatch: schema was inferred from a "
312
+ f"single sample file with {n_fields} fields, but at "
313
+ f"least one matched file has {max_fields} fields"
314
+ )
315
+ raise ValueError(msg)
316
+
285
317
  # Add each field as a separate column
286
318
  for i, field in fields.items():
287
319
  lf = lf.with_columns(_polars.col("fields").list.get(i).alias(field))
@@ -58,6 +58,32 @@ class FPath:
58
58
 
59
59
  parser = parse.compile(self.fpath)
60
60
 
61
+ # glob() (used below to find files) and `parse` (used above to
62
+ # extract {name} values) disagree about what a bare '*', '?', or
63
+ # '[...]' means outside a {} capture: glob treats it as a wildcard,
64
+ # but parse's format-string language only special-cases {...} and
65
+ # reads everything else -- including '*' -- as literal text to
66
+ # match. A pattern like "{a}/*" would find files fine via glob()
67
+ # but then fail to parse against that same string, since real
68
+ # filenames don't literally contain "/*" -- silently producing
69
+ # metadata=None for every match, or raising a confusing "metadata
70
+ # not found" error, with no indication that '*' was the actual
71
+ # problem. Fail fast and explain it instead. Only applies when
72
+ # there's a {} capture to begin with -- a plain glob with none is a
73
+ # separate, unaffected case (no metadata is expected from it).
74
+ if parser.named_fields:
75
+ literal_fpath = re.sub(r"\{.*?\}", "", self.fpath)
76
+ for c in "*?[":
77
+ if c in literal_fpath:
78
+ msg = (
79
+ f"glob wildcard {c!r} outside a {{}} capture is not "
80
+ f"supported in {self.fpath!r} -- 'parse' treats it "
81
+ "as a literal character, not a wildcard. Use a "
82
+ "named capture (e.g. '{a}/{b}') if you want that "
83
+ "segment captured too."
84
+ )
85
+ raise ValueError(msg)
86
+
61
87
  paths = []
62
88
  for fname in glob(re.sub(r"\{.*?\}", "*", self.fpath)):
63
89
  path = Path(fname)
@@ -153,7 +179,13 @@ class ExpandedFPath(Sequence):
153
179
 
154
180
  pl = import_optional_dependency("polars")
155
181
 
156
- data = [{"fname": str(key), **value} for key, value in self.metadata.items()]
182
+ # `value` is None whenever this ExpandedFPath was built with
183
+ # require_metadata=False and a path's metadata simply wasn't found
184
+ # (e.g. a plain glob with no named captures at all) -- treat that as
185
+ # "no metadata columns" rather than crashing on `**None`.
186
+ data = [
187
+ {"fname": str(key), **(value or {})} for key, value in self.metadata.items()
188
+ ]
157
189
  df = pl.DataFrame(data)
158
190
  if lazy:
159
191
  df = df.lazy()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fpathlib
3
- Version: 0.1.3
3
+ Version: 0.1.4.dev12
4
4
  Summary: A package to combine paths with metadata
5
5
  Author-email: "C. Lockhart" <clockha2@gmu.edu>
6
6
  Requires-Python: >=3.12
@@ -4,11 +4,13 @@ MANIFEST.in
4
4
  README.md
5
5
  TODO.txt
6
6
  pyproject.toml
7
+ conda-recipe/meta.yaml
7
8
  docs/Makefile
8
9
  docs/make.bat
9
10
  docs/source/api.rst
10
11
  docs/source/conf.py
11
12
  docs/source/index.rst
13
+ scripts/conda.sh
12
14
  scripts/deploy.sh
13
15
  scripts/docs.sh
14
16
  scripts/pypi.sh
@@ -5,12 +5,14 @@
5
5
  "MANIFEST.in",
6
6
  "README.md",
7
7
  "TODO.txt",
8
+ "conda-recipe/meta.yaml",
8
9
  "docs/Makefile",
9
10
  "docs/make.bat",
10
11
  "docs/source/api.rst",
11
12
  "docs/source/conf.py",
12
13
  "docs/source/index.rst",
13
14
  "pyproject.toml",
15
+ "scripts/conda.sh",
14
16
  "scripts/deploy.sh",
15
17
  "scripts/docs.sh",
16
18
  "scripts/pypi.sh",
@@ -0,0 +1,8 @@
1
+ {
2
+ "tag": "0.1.3",
3
+ "distance": 12,
4
+ "node": "g2ae3f3b01d310e4bf9308863ebc666476069caf8",
5
+ "dirty": false,
6
+ "branch": "main",
7
+ "node_date": "2026-09-16"
8
+ }
@@ -1,3 +0,0 @@
1
- source scripts/docs.sh
2
- source scripts/tag.sh "patch"
3
- source scripts/pypi.sh
@@ -1,20 +0,0 @@
1
- allow_dev=0
2
- if [ "$1" = "dev" ]
3
- then
4
- allow_dev=1
5
- fi
6
-
7
- python3 -m build
8
-
9
- dev_artifacts=$(ls dist/ | grep -c '\.dev[0-9]')
10
- if [ $allow_dev -eq 0 ] && [ "$dev_artifacts" != "0" ]
11
- then
12
- echo "built version is a dev version (tag likely doesn't point at a distinct commit), not uploading to pypi"
13
- rm -r dist
14
- rm -r src/fpathlib.egg-info
15
- return
16
- fi
17
-
18
- twine upload --verbose dist/*
19
- rm -r dist
20
- rm -r src/fpathlib.egg-info
@@ -1,33 +0,0 @@
1
- set -e
2
-
3
- m=$1
4
-
5
- tag=$(git describe --tags --abbrev=0)
6
- parts=(${tag//./ })
7
- if [ "$m" == "major" ]
8
- then
9
- parts[0]=$((parts[0]+1))
10
- parts[1]=0
11
- parts[2]=0
12
- elif [ "$m" == "minor" ]
13
- then
14
- parts[1]=$((parts[1]+1))
15
- parts[2]=0
16
- elif [ "$m" == "patch" ]
17
- then
18
- parts[2]=$((parts[2]+1))
19
- else
20
- echo "must specify major, minor, or patch"
21
- return
22
- fi
23
- tag="${parts[0]}.${parts[1]}.${parts[2]}"
24
-
25
- git add -A
26
- git commit --allow-empty -m "tag $tag"
27
- git push origin main
28
-
29
- git checkout main
30
- git pull origin main
31
-
32
- git tag $tag
33
- git push origin $tag
@@ -1,8 +0,0 @@
1
- {
2
- "tag": "0.1.3",
3
- "distance": 0,
4
- "node": "g02b650d9221c0a98fa837aae39d499573ad9b4ad",
5
- "dirty": false,
6
- "branch": "main",
7
- "node_date": "2026-09-15"
8
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes