makora 0.0.0.dev1__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.
@@ -0,0 +1,15 @@
1
+ Metadata-Version: 2.4
2
+ Name: makora
3
+ Version: 0.0.0.dev1
4
+ Home-page:
5
+ Download-URL:
6
+ Author:
7
+ Author-email:
8
+ Requires-Python: >=3.10.0
9
+ Description-Content-Type: text/markdown
10
+ Dynamic: description
11
+ Dynamic: description-content-type
12
+ Dynamic: requires-python
13
+
14
+ # Basic package template
15
+
@@ -0,0 +1,2 @@
1
+ # Basic package template
2
+
@@ -0,0 +1,53 @@
1
+ from .utils import (
2
+ static_property,
3
+ add_module_properties,
4
+ )
5
+
6
+
7
+ def _get_version() -> str:
8
+ from . import version
9
+
10
+ return version.version
11
+
12
+
13
+ def _get_has_repo() -> bool:
14
+ from . import version
15
+
16
+ return version.has_repo
17
+
18
+
19
+ def _get_repo() -> str:
20
+ from . import version
21
+
22
+ return version.repo
23
+
24
+
25
+ def _get_commit() -> str:
26
+ from . import version
27
+
28
+ return version.commit
29
+
30
+
31
+ __version__: str
32
+ __has_repo__: bool
33
+ __repo__: str
34
+ __commit__: str
35
+
36
+
37
+ __all__ = [
38
+ "__version__",
39
+ "__has_repo__",
40
+ "__repo__",
41
+ "__commit__",
42
+ ]
43
+
44
+
45
+ add_module_properties(
46
+ __name__,
47
+ {
48
+ "__version__": static_property(staticmethod(_get_version)),
49
+ "__has_repo__": static_property(staticmethod(_get_has_repo)),
50
+ "__repo__": static_property(staticmethod(_get_repo)),
51
+ "__commit__": static_property(staticmethod(_get_commit)),
52
+ },
53
+ )
@@ -0,0 +1,4 @@
1
+ version = '0.0.0dev1'
2
+ repo = 'git@github.com:makodevai/makora.git'
3
+ commit = '75f0a326d4cdb4935fd5cfc10bc4e4f80b9306ef'
4
+ has_repo = True
File without changes
@@ -0,0 +1,86 @@
1
+ import sys
2
+ import types
3
+ from typing import Any, Callable, Iterable
4
+
5
+
6
+ class static_property(property):
7
+ def __init__(
8
+ self,
9
+ fget: Callable[[], Any] | None = None,
10
+ fset: Callable[[Any], None] | None = None,
11
+ fdel: Callable[[], None] | None = None,
12
+ doc: str | None = None,
13
+ ) -> None:
14
+ if fget is not None and not isinstance(fget, staticmethod):
15
+ fget = staticmethod(fget)
16
+ if fset is not None and not isinstance(fset, staticmethod):
17
+ fset = staticmethod(fset)
18
+ if fdel is not None and not isinstance(fdel, staticmethod):
19
+ fdel = staticmethod(fdel)
20
+ super().__init__(fget, fset, fdel, doc) # type: ignore
21
+
22
+ def __get__(self, inst: Any, cls: type | None = None) -> Any:
23
+ if inst is None:
24
+ return self
25
+ if self.fget is None:
26
+ raise AttributeError("unreadable attribute")
27
+ return self.fget.__get__(inst, cls)() # pylint: disable=no-member
28
+
29
+ def __set__(self, inst: Any, val: Any) -> None:
30
+ if self.fset is None:
31
+ raise AttributeError("can't set attribute")
32
+
33
+ # pylint: disable=no-member
34
+ return self.fset.__get__(inst)(val) # type: ignore
35
+
36
+ def __delete__(self, inst: Any) -> None:
37
+ if self.fdel is None:
38
+ raise AttributeError("can't delete attribute")
39
+ # pylint: disable=no-member
40
+ return self.fdel.__get__(inst)() # type: ignore
41
+
42
+
43
+ class LazyModuleType(types.ModuleType):
44
+ def __init__(self, name: str) -> None:
45
+ super().__init__(name)
46
+
47
+ def __getattribute__(self, name: str) -> Any:
48
+ _props = super().__getattribute__("_props")
49
+ if name in _props:
50
+ return object.__getattribute__(self, name)
51
+ else:
52
+ return types.ModuleType.__getattribute__(self, name)
53
+
54
+ def __dir__(self) -> Iterable[str]:
55
+ ret = super().__dir__()
56
+ ret.extend(self._props) # type: ignore
57
+ return ret
58
+
59
+
60
+ def add_module_properties(module_name: str, properties: dict[str, Any]) -> None:
61
+ module = sys.modules[module_name]
62
+ replace = False
63
+ if isinstance(module, LazyModuleType):
64
+ hacked_type = type(module)
65
+ else:
66
+ hacked_type = type(
67
+ "LazyModuleType__{}".format(module_name.replace(".", "_")),
68
+ (LazyModuleType,),
69
+ {"_props": set()},
70
+ )
71
+ replace = True
72
+
73
+ for name, prop in properties.items():
74
+ if not isinstance(prop, property):
75
+ prop = property(prop)
76
+ setattr(hacked_type, name, prop)
77
+ hacked_type._props.add(name) # type: ignore
78
+
79
+ if replace:
80
+ new_module = hacked_type(module_name)
81
+ spec = getattr(module, "__spec__", None)
82
+ module.__class__ = new_module.__class__
83
+ module.__name__ = new_module.__name__
84
+ module.__dict__.update(new_module.__dict__)
85
+ module.__spec__ = spec
86
+
@@ -0,0 +1,59 @@
1
+ from typing import Any
2
+
3
+ version = "0.0.0dev1"
4
+ repo = "unknown"
5
+ commit = "unknown"
6
+ has_repo = False
7
+
8
+ try:
9
+ import git
10
+ from pathlib import Path
11
+
12
+ try:
13
+ r = git.Repo(Path(__file__).parents[1])
14
+ has_repo = True
15
+
16
+ if not r.remotes:
17
+ repo = "local"
18
+ else:
19
+ repo = r.remotes.origin.url
20
+
21
+ commit = r.head.commit.hexsha # cSpell: disable-line
22
+ status = []
23
+ if r.is_dirty():
24
+ status.append("dirty")
25
+ if r.untracked_files:
26
+ status.append(f"+{len(r.untracked_files)} untracked")
27
+ if status:
28
+ commit += f" ({','.join(status)})"
29
+ except git.InvalidGitRepositoryError:
30
+ raise ImportError()
31
+ except ImportError:
32
+ pass
33
+
34
+ try:
35
+ import importlib.util
36
+ from pathlib import Path
37
+
38
+ _dist_info_file = Path(__file__).parent.joinpath("_dist_info.py")
39
+ if _dist_info_file.exists():
40
+ _spec = importlib.util.spec_from_file_location("_dist_info", _dist_info_file)
41
+ assert _spec is not None
42
+ _dist_info = importlib.util.module_from_spec(_spec)
43
+ assert _dist_info is not None
44
+ assert _spec.loader is not None
45
+ _spec.loader.exec_module(_dist_info)
46
+ assert not has_repo, "_dist_info should not exist when repo is in place"
47
+ assert version == _dist_info.version
48
+ repo = _dist_info.repo
49
+ commit = _dist_info.commit
50
+ except (ImportError, SystemError):
51
+ pass
52
+
53
+
54
+ def info() -> dict[str, Any]:
55
+ g = globals()
56
+ return {k: g[k] for k in __all__}
57
+
58
+
59
+ __all__ = ["version", "repo", "commit", "has_repo"]
@@ -0,0 +1,15 @@
1
+ Metadata-Version: 2.4
2
+ Name: makora
3
+ Version: 0.0.0.dev1
4
+ Home-page:
5
+ Download-URL:
6
+ Author:
7
+ Author-email:
8
+ Requires-Python: >=3.10.0
9
+ Description-Content-Type: text/markdown
10
+ Dynamic: description
11
+ Dynamic: description-content-type
12
+ Dynamic: requires-python
13
+
14
+ # Basic package template
15
+
@@ -0,0 +1,16 @@
1
+ README.md
2
+ pyproject.toml
3
+ setup.py
4
+ ./makora/__init__.py
5
+ ./makora/_dist_info.py
6
+ ./makora/py.typed
7
+ ./makora/utils.py
8
+ ./makora/version.py
9
+ makora/__init__.py
10
+ makora/py.typed
11
+ makora/utils.py
12
+ makora/version.py
13
+ makora.egg-info/PKG-INFO
14
+ makora.egg-info/SOURCES.txt
15
+ makora.egg-info/dependency_links.txt
16
+ makora.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ makora
@@ -0,0 +1,3 @@
1
+ [build-system]
2
+ requires = ["setuptools", "wheel", "GitPython"]
3
+ build-backend = "setuptools.build_meta"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,91 @@
1
+ #!/usr/bin/env python
2
+
3
+ from setuptools import setup, find_packages
4
+ from setuptools.command.build_py import build_py
5
+ from setuptools.command.sdist import sdist
6
+
7
+ import importlib.util
8
+ from pathlib import Path
9
+
10
+ root_dir = Path(__file__).parent
11
+
12
+ package_name = "makora"
13
+ description = ""
14
+ author = ""
15
+ author_email = ""
16
+ url = f""
17
+ download_url = f""
18
+ data_files = {}
19
+
20
+ version_file = Path(__file__).parent.joinpath(package_name, "version.py")
21
+ spec = importlib.util.spec_from_file_location(
22
+ "{}.version".format(package_name), version_file
23
+ )
24
+ package_version = importlib.util.module_from_spec(spec)
25
+ spec.loader.exec_module(package_version)
26
+
27
+ long_desc = None
28
+ long_desc_type = None
29
+ readme_md = Path(__file__).parent.joinpath("README.md")
30
+ if readme_md.exists():
31
+ data_files.setdefault("", []).append(readme_md.name)
32
+ with readme_md.open("r") as f:
33
+ long_desc = f.read()
34
+ long_desc_type = "text/markdown"
35
+
36
+ license = Path(__file__).parent.joinpath("LICENSE")
37
+ if license.exists():
38
+ data_files.setdefault("", []).append(license.name)
39
+
40
+ data_files[package_name] = ["py.typed"]
41
+
42
+
43
+ class dist_info_mixin:
44
+ def run(self):
45
+ _dist_file = version_file.parent.joinpath("_dist_info.py")
46
+ _dist_file.write_text(
47
+ "\n".join(
48
+ map(
49
+ lambda attr_name: attr_name
50
+ + " = "
51
+ + repr(getattr(package_version, attr_name)),
52
+ package_version.__all__,
53
+ )
54
+ )
55
+ + "\n"
56
+ )
57
+ try:
58
+ ret = super().run()
59
+ finally:
60
+ _dist_file.unlink()
61
+ return ret
62
+
63
+
64
+ class custom_sdist(dist_info_mixin, sdist):
65
+ pass
66
+
67
+
68
+ class custom_wheel(dist_info_mixin, build_py):
69
+ pass
70
+
71
+
72
+ setup(
73
+ name=package_name,
74
+ version=package_version.version,
75
+ description=description,
76
+ author=author,
77
+ author_email=author_email,
78
+ url=url,
79
+ download_url=download_url,
80
+ long_description=long_desc or "",
81
+ long_description_content_type=long_desc_type or "",
82
+ python_requires=">=3.10.0",
83
+ install_requires=[
84
+ ],
85
+ extras_require={
86
+ },
87
+ packages=find_packages(where=".", include=[package_name, package_name + ".*"]),
88
+ package_dir={"": "."},
89
+ package_data=data_files,
90
+ cmdclass={"sdist": custom_sdist, "build_py": custom_wheel},
91
+ )