Changed custom_lib

This commit is contained in:
2026-05-08 15:28:04 +09:00
parent 0ffb55dd99
commit 5f281ec40b
687 changed files with 337 additions and 11 deletions
@@ -0,0 +1 @@
import __editable___custom_lib_1_0_3_finder; __editable___custom_lib_1_0_3_finder.install()
@@ -0,0 +1,85 @@
from __future__ import annotations
import sys
from importlib.machinery import ModuleSpec, PathFinder
from importlib.machinery import all_suffixes as module_suffixes
from importlib.util import spec_from_file_location
from itertools import chain
from pathlib import Path
MAPPING: dict[str, str] = {'custom_lib': '\\\\Mac\\Home\\Repo\\01_python\\01_ateciot\\build_scripter\\custom_lib'}
NAMESPACES: dict[str, list[str]] = {}
PATH_PLACEHOLDER = '__editable__.custom_lib-1.0.3.finder' + ".__path_hook__"
class _EditableFinder: # MetaPathFinder
@classmethod
def find_spec(cls, fullname: str, path=None, target=None) -> ModuleSpec | None: # type: ignore
# Top-level packages and modules (we know these exist in the FS)
if fullname in MAPPING:
pkg_path = MAPPING[fullname]
return cls._find_spec(fullname, Path(pkg_path))
# Handle immediate children modules (required for namespaces to work)
# To avoid problems with case sensitivity in the file system we delegate
# to the importlib.machinery implementation.
parent, _, child = fullname.rpartition(".")
if parent and parent in MAPPING:
return PathFinder.find_spec(fullname, path=[MAPPING[parent]])
# Other levels of nesting should be handled automatically by importlib
# using the parent path.
return None
@classmethod
def _find_spec(cls, fullname: str, candidate_path: Path) -> ModuleSpec | None:
init = candidate_path / "__init__.py"
candidates = (candidate_path.with_suffix(x) for x in module_suffixes())
for candidate in chain([init], candidates):
if candidate.exists():
return spec_from_file_location(fullname, candidate)
return None
class _EditableNamespaceFinder: # PathEntryFinder
@classmethod
def _path_hook(cls, path) -> type[_EditableNamespaceFinder]:
if path == PATH_PLACEHOLDER:
return cls
raise ImportError
@classmethod
def _paths(cls, fullname: str) -> list[str]:
paths = NAMESPACES[fullname]
if not paths and fullname in MAPPING:
paths = [MAPPING[fullname]]
# Always add placeholder, for 2 reasons:
# 1. __path__ cannot be empty for the spec to be considered namespace.
# 2. In the case of nested namespaces, we need to force
# import machinery to query _EditableNamespaceFinder again.
return [*paths, PATH_PLACEHOLDER]
@classmethod
def find_spec(cls, fullname: str, target=None) -> ModuleSpec | None: # type: ignore
if fullname in NAMESPACES:
spec = ModuleSpec(fullname, None, is_package=True)
spec.submodule_search_locations = cls._paths(fullname)
return spec
return None
@classmethod
def find_module(cls, _fullname) -> None:
return None
def install():
if not any(finder == _EditableFinder for finder in sys.meta_path):
sys.meta_path.append(_EditableFinder)
if not NAMESPACES:
return
if not any(hook == _EditableNamespaceFinder._path_hook for hook in sys.path_hooks):
# PathEntryFinder is needed to create NamespaceSpec without private APIS
sys.path_hooks.append(_EditableNamespaceFinder._path_hook)
if PATH_PLACEHOLDER not in sys.path:
sys.path.append(PATH_PLACEHOLDER) # Used just to trigger the path hook
@@ -0,0 +1 @@
pip
@@ -0,0 +1,20 @@
Metadata-Version: 2.4
Name: custom_lib
Version: 1.0.3
Summary: My Custom Python Library
Requires-Python: >=3.9
Provides-Extra: image
Requires-Dist: webcolors==1.13; extra == "image"
Requires-Dist: pillow==9.4.0; extra == "image"
Requires-Dist: opencv-contrib-python==4.5.2.52; extra == "image"
Requires-Dist: numpy<2; extra == "image"
Provides-Extra: crawling
Requires-Dist: requests==2.26.0; extra == "crawling"
Requires-Dist: beautifulsoup4==4.11.2; extra == "crawling"
Provides-Extra: all
Requires-Dist: webcolors==1.13; extra == "all"
Requires-Dist: pillow==9.4.0; extra == "all"
Requires-Dist: opencv-contrib-python==4.5.2.52; extra == "all"
Requires-Dist: numpy<2; extra == "all"
Requires-Dist: requests==2.26.0; extra == "all"
Requires-Dist: beautifulsoup4==4.11.2; extra == "all"
@@ -0,0 +1,10 @@
__editable__.custom_lib-1.0.3.pth,sha256=s00wCzzrTsBn-gcSWFl27qfyteWpK08Mx6TIKcrFcy4,91
__editable___custom_lib_1_0_3_finder.py,sha256=MHgiuMJjhV74WfexJFZ_vLmEdMXDNSUonF44sLs6kSM,3427
__pycache__/__editable___custom_lib_1_0_3_finder.cpython-39.pyc,,
custom_lib-1.0.3.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
custom_lib-1.0.3.dist-info/METADATA,sha256=ZYfxXvOz4rBp8-xS6GgH6cOSutUdKvzecHVWJXxVN3A,808
custom_lib-1.0.3.dist-info/RECORD,,
custom_lib-1.0.3.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
custom_lib-1.0.3.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
custom_lib-1.0.3.dist-info/direct_url.json,sha256=8XJoiUw32oWAMs4gOnDFlVF9atcSZFwPwgkcUx4Xl4k,94
custom_lib-1.0.3.dist-info/top_level.txt,sha256=oxKhBtPOOG3E1VOiBNxk2-He2jYR96qxH_5Xix-Dijg,11
@@ -0,0 +1,5 @@
Wheel-Version: 1.0
Generator: setuptools (82.0.1)
Root-Is-Purelib: true
Tag: py3-none-any
@@ -0,0 +1 @@
{"dir_info": {"editable": true}, "url": "file:///Z:/Repo/01_python/01_ateciot/build_scripter"}
@@ -0,0 +1 @@
custom_lib
@@ -1,6 +1,6 @@
../../Scripts/pip.exe,sha256=DbKHREOZwT7tE5k3g3F9XzG3rBqU3WjJSi6cI8_Frnc,106387
../../Scripts/pip3.9.exe,sha256=DbKHREOZwT7tE5k3g3F9XzG3rBqU3WjJSi6cI8_Frnc,106387
../../Scripts/pip3.exe,sha256=DbKHREOZwT7tE5k3g3F9XzG3rBqU3WjJSi6cI8_Frnc,106387
../../Scripts/pip.exe,sha256=-mJQt9PpAleajnn7fLb131WmT1EqBaGXOj1V3PSmuNY,106387
../../Scripts/pip3.9.exe,sha256=-mJQt9PpAleajnn7fLb131WmT1EqBaGXOj1V3PSmuNY,106387
../../Scripts/pip3.exe,sha256=-mJQt9PpAleajnn7fLb131WmT1EqBaGXOj1V3PSmuNY,106387
pip-22.0.4.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
pip-22.0.4.dist-info/LICENSE.txt,sha256=Y0MApmnUmurmWxLGxIySTFGkzfPR_whtw0VtyLyqIQQ,1093
pip-22.0.4.dist-info/METADATA,sha256=bGtDzdgW1AF93Nx32ySc78yQHtHkOrRD146Dvsz85CM,4166

Some files were not shown because too many files have changed in this diff Show More