rapidframework-lib 1.0.2__py3-none-any.whl → 1.0.3__py3-none-any.whl

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.
@@ -3,6 +3,6 @@ from .frameworks import DjangoManager as DjangoManager
3
3
  from .frameworks import FastapiManager as FastapiManager
4
4
 
5
5
  from .config import Config as Config
6
- from .uv import UvManager as UvManager
6
+ from .config import AutoManager as AutoManager
7
7
 
8
8
  __version__ = '0.0.1'
rapidframework/config.py CHANGED
@@ -1,7 +1,10 @@
1
1
  from os import getcwd, listdir, path, makedirs
2
- from typing import Self
3
- from msgspec import toml
4
- import re
2
+ from typing import Self, Dict
3
+ import pkgutil
4
+ from msgspec import json, Struct, field
5
+ from subprocess import run
6
+ from importlib.metadata import distribution
7
+ from re import sub
5
8
 
6
9
 
7
10
  class Config:
@@ -12,7 +15,6 @@ class Config:
12
15
  cls._instance = super(Config, cls).__new__(cls)
13
16
  cls._instance.source_dir = getcwd()
14
17
  cls._instance.source_files = listdir()
15
- cls._instance.pyproject_file = "pyproject.toml"
16
18
  cls._instance.dirs_to_create = [
17
19
  "tests",
18
20
  "templates",
@@ -24,6 +26,8 @@ class Config:
24
26
 
25
27
  # cls._instance.pyproject_deps: list
26
28
  cls._instance.project_name = path.basename(cls._instance.source_dir)
29
+ cls.install = AutoManager().get_config_managers()
30
+ cls.pkg_manager = AutoManager().get_pkg_manager()
27
31
 
28
32
  return cls._instance
29
33
 
@@ -34,19 +38,48 @@ class Config:
34
38
  for _dir in dirs_to_create:
35
39
  makedirs(path.join(app_path, _dir), exist_ok=True)
36
40
 
37
- def create_files(cls, file_paths):
41
+ def create_files(cls, file_paths) -> None:
38
42
  for file_path in file_paths:
39
43
  with open(path.join(cls._instance.source_dir, file_path), "w"): ...
40
44
 
41
- def check_lib(cls, lib_name) -> bool:
42
- return lib_name in [
43
- re.match(r"^[a-zA-Z0-9-_]+", dep).group(0)
44
- for dep in cls._instance.pyproject_deps
45
- ]
46
-
47
- def get_dependencies(cls) -> list:
48
- with open(
49
- path.join(cls._instance.source_dir, cls._instance.pyproject_file)
50
- ) as pyproject_deps:
51
- cls._instance.pyproject_deps = toml.decode(pyproject_deps.read()).get("project").get("dependencies")
52
- return cls._instance.pyproject_deps
45
+
46
+ class AutoManager:
47
+ _instance = None
48
+
49
+
50
+ def __new__(cls, config_name: str = "managers.json") -> Self:
51
+ if cls._instance is None:
52
+ cls._instance = super(AutoManager, cls).__new__(cls)
53
+
54
+ class _ConfigCommands(Struct):
55
+ install: str
56
+ uninstall: str
57
+ list_: str = field(name="list")
58
+
59
+ class _ConfigFormat(Struct):
60
+ managers: Dict[str, _ConfigCommands]
61
+
62
+ cls._instance.config_name = config_name
63
+ cls._instance._ConfigFormat = _ConfigFormat
64
+ cls._instance.decoder = json.Decoder()
65
+
66
+ return cls._instance
67
+
68
+
69
+ def get_config_managers(cls) -> dict:
70
+ config = pkgutil.get_data("rapidframework", f"configs/{cls._instance.config_name}")
71
+ return json.decode(config.decode("utf-8"), type=cls._instance._ConfigFormat)
72
+
73
+
74
+ def get_pkg_manager(cls) -> str:
75
+ try:
76
+ return sub(r'\s+', '', distribution("rapidframework-lib").read_text("INSTALLER"))
77
+ except:
78
+ return "pip"
79
+
80
+
81
+ def install_libs(cls, libs: list) -> None:
82
+ print(libs)
83
+ for lib in libs:
84
+ print([cls.get_pkg_manager(), cls.get_config_managers().managers.get(cls.get_pkg_manager()), lib])
85
+ run([cls.get_pkg_manager(), cls.get_config_managers().managers.get(cls.get_pkg_manager()).install, lib])
@@ -0,0 +1,29 @@
1
+ {
2
+ "managers": {
3
+ "pip": {
4
+ "install": "install",
5
+ "uninstall": "uninstall",
6
+ "list": "freeze"
7
+ },
8
+ "conda": {
9
+ "install": "install",
10
+ "uninstall": "uninstall",
11
+ "list": "list"
12
+ },
13
+ "uv": {
14
+ "install": "add",
15
+ "uninstall": "remove",
16
+ "list": "pip list"
17
+ },
18
+ "pyenv": {
19
+ "install": "install",
20
+ "uninstall": "uninstall",
21
+ "list": "versions"
22
+ },
23
+ "poetry": {
24
+ "install": "add",
25
+ "uninstall": "remove",
26
+ "list": "show"
27
+ }
28
+ }
29
+ }
@@ -1,5 +1,5 @@
1
1
  from os import path
2
- from ..uv import UvManager
2
+ from ..config import AutoManager
3
3
  from ..config import Config
4
4
 
5
5
 
@@ -20,22 +20,16 @@ class Template:
20
20
  self.framework_name = framework_name
21
21
  self.name = kwargs.get("name")
22
22
  #
23
- self.UvManager = UvManager()
24
- self.UvManager.check_for_venv()
23
+ self.AutoManager = AutoManager()
25
24
  #
26
25
 
27
- def check(self, **kwargs) -> None:
28
- if not cfg.check_lib(self.framework_name):
29
- self.install_framework(**kwargs)
30
- else:
31
- self.setup_framework()
32
-
33
26
  def install_framework(self, **kwargs):
34
27
  version = f"=={kwargs.get('version')}" if kwargs.get('version') else ""
35
28
  libs_to_install: list = kwargs.get("libs") or []
36
29
  #
37
30
  libs_to_install.extend([f"{self.framework_name}{version}"])
38
- self.UvManager.install_libs(libs_to_install)
31
+ print("Getting libs")
32
+ self.AutoManager.install_libs(libs_to_install)
39
33
  #
40
34
  self.setup_framework()
41
35
 
rapidframework/main.py CHANGED
@@ -2,10 +2,6 @@ import argparse
2
2
  import importlib
3
3
  import os
4
4
  from pathlib import Path
5
-
6
- #
7
- from .uv import UvManager
8
-
9
5
  #
10
6
 
11
7
  FRAMEWORKS_PATH = Path(__file__).parent / "frameworks"
@@ -30,7 +26,6 @@ class Main:
30
26
  #
31
27
  self.args = self.parser.parse_args()
32
28
  #
33
- self.UvManager = UvManager()
34
29
  self.framework_manager = self._load_framework_manager()
35
30
 
36
31
  def _discover_frameworks(self):
@@ -50,13 +45,11 @@ class Main:
50
45
 
51
46
  return manager_class(name=self.args.name)
52
47
 
53
- def run(self):
54
- self.UvManager.check_for_venv()
55
- #
48
+ def run(self):
56
49
  example_id = 1 if self.args.example is None else self.args.example
57
50
  #
58
- if hasattr(self.framework_manager, "check"):
59
- self.framework_manager.check(version=self.args.version)
51
+ if hasattr(self.framework_manager, "install_framework"):
52
+ self.framework_manager.install_framework(version=self.args.version)
60
53
 
61
54
  if hasattr(self.framework_manager, "create_example"):
62
55
  self.framework_manager.create_example(self.args.name, example_id)
@@ -1,10 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rapidframework-lib
3
- Version: 1.0.2
3
+ Version: 1.0.3
4
4
  Description-Content-Type: text/markdown
5
5
  License-File: LICENSE
6
6
  Requires-Dist: msgspec
7
- Requires-Dist: uv
8
7
  Dynamic: description
9
8
  Dynamic: description-content-type
10
9
  Dynamic: license-file
@@ -14,6 +13,8 @@ Dynamic: requires-dist
14
13
 
15
14
  > **RapidFramework** is a Python library for quickly creating and setting up projects from templates.
16
15
 
16
+ ## https://pypi.org/project/rapidframework-lib/1.0.2/
17
+
17
18
  ## Installation
18
19
 
19
20
  ```bash
@@ -1,14 +1,15 @@
1
- rapidframework/__init__.py,sha256=9OF4t0CME4Fef1FErhgtD6--mFnAmnJHG5LTsZiehTY,264
2
- rapidframework/config.py,sha256=47DdNVilkt-IbQM9X1TAsrlmfmPC0yVbb2SuYH48njg,1782
3
- rapidframework/main.py,sha256=wNZBUtBFmH7W80aelkfXleId4qiS2FZZfoMgcX13bgY,2165
4
- rapidframework/uv.py,sha256=7q-W_zvq9KxB0gohArzquw54P20lIEByg5X0rI4CyRw,1002
1
+ rapidframework/__init__.py,sha256=5HJcv-kJl0RPcWiShgyMPUVPjvRH4Qb2ormsHCJ5v5Y,272
2
+ rapidframework/config.py,sha256=y1i7vJTDmywYoLSj7HQz_8m9E3eIG20z18whizgc8Z4,2905
3
+ rapidframework/main.py,sha256=evivz6o-ltpeq9P4BkLUPa6HRrdSFc5tL8PTDZ9aysM,2066
4
+ rapidframework/__pycache__/main.cpython-313.pyc,sha256=J3Y41E5fOwmGEQtwgTq-NBUl0s0VxCvDC5KUnCGvIdU,3891
5
+ rapidframework/configs/managers.json,sha256=EEBDjTVQuNXGIF_oIXuNVpXK4kTk2HsRb2aPrbmUjo4,664
5
6
  rapidframework/frameworks/__init__.py,sha256=fFmRgwuTqQ9dKCY3AgjUCWt2V2xTjSN7Y2NKkaURQAk,220
6
7
  rapidframework/frameworks/django.py,sha256=AQkMjzRLjFwd72ZYg-DZWEx702x6qForBYg3hsRBBgw,980
7
8
  rapidframework/frameworks/fastapi.py,sha256=dT0_35QEOZquBFauhTrkTnuCoh2n2B1iuKu3eSTyeKI,624
8
9
  rapidframework/frameworks/flask.py,sha256=csV5jUGmtLvESm_rma15xAQYDhMhlZmVidp8TCaNGZg,343
9
10
  rapidframework/frameworks/litestar.py,sha256=_fUtFga4l6p8oQJzN5LfA1VP1ycsfbsKqBadywbgUO4,309
10
11
  rapidframework/frameworks/starlette.py,sha256=SIV3Bd8bdSJ_apSfOFXwR-UnZ2bN9hHNBPB5opUSCZk,332
11
- rapidframework/frameworks/template.py,sha256=gg2l-6g9QqfssZTDtcEecGXiLWEY7_Kw3CGoE1qK3go,1759
12
+ rapidframework/frameworks/template.py,sha256=RUHd1BYTNbKUiZMGhvAwQBhaTElFv4TdWFIB6K-AHew,1576
12
13
  rapidframework/frameworks/tornado.py,sha256=c1dDcRTEZ0nMlMXmMtBIE4cyxhB7hdsb1681VoN8LyE,275
13
14
  rapidframework/frameworks/examples/__init__.py,sha256=ovguP4wzQEDNguczwiZnhMm4dRRVcvnzmHrfQtlRCNQ,15
14
15
  rapidframework/frameworks/examples/fastapi_example_1.py,sha256=Rhmcr1BrBHR1_xhqk4UmZiF5MDqixRbucR03T6yvBvg,261
@@ -16,9 +17,9 @@ rapidframework/frameworks/examples/flask_example_1.py,sha256=DuVlouunkJtGygqrU2B
16
17
  rapidframework/frameworks/examples/litestar_example_1.py,sha256=kcAsS3LE5g6ZYmkNtRsrLHTNSmtCUXtsgJmoOtiubnk,220
17
18
  rapidframework/frameworks/examples/starlette_example_1.py,sha256=6T9tUyXJ329qHl3ZYgNOCy5eXOX8luT2HP_FWfQ6E4Y,268
18
19
  rapidframework/frameworks/examples/tornado_example_1.py,sha256=vnOqnzcFyCFSMl_5x4pyfbYi6PL9EMQBn9Mv_6yXpZM,368
19
- rapidframework_lib-1.0.2.dist-info/licenses/LICENSE,sha256=lXsPzvyEfL6vjzMMCRYi7gpsIjpSUYUsDF-MvMHyhc0,1070
20
- rapidframework_lib-1.0.2.dist-info/METADATA,sha256=pxzn5aPkEFnEL10QLeJFASQ0p-qhG0FWpW1E7wN8z94,1200
21
- rapidframework_lib-1.0.2.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
22
- rapidframework_lib-1.0.2.dist-info/entry_points.txt,sha256=UaOaGJ-BDCxtmNoPp-u_TnXXLbnXtrB13PYr5BgqmHA,72
23
- rapidframework_lib-1.0.2.dist-info/top_level.txt,sha256=7PXDkFZsYowz4aB2xVaSso4qD45jd2kHn6x3xxhMMNs,15
24
- rapidframework_lib-1.0.2.dist-info/RECORD,,
20
+ rapidframework_lib-1.0.3.dist-info/licenses/LICENSE,sha256=lXsPzvyEfL6vjzMMCRYi7gpsIjpSUYUsDF-MvMHyhc0,1070
21
+ rapidframework_lib-1.0.3.dist-info/METADATA,sha256=s6JevCDHZONfxcJdmd8f_WjIFFkv8-Jhf3qKALDL2ww,1237
22
+ rapidframework_lib-1.0.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
+ rapidframework_lib-1.0.3.dist-info/entry_points.txt,sha256=UaOaGJ-BDCxtmNoPp-u_TnXXLbnXtrB13PYr5BgqmHA,72
24
+ rapidframework_lib-1.0.3.dist-info/top_level.txt,sha256=7PXDkFZsYowz4aB2xVaSso4qD45jd2kHn6x3xxhMMNs,15
25
+ rapidframework_lib-1.0.3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (79.0.1)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
rapidframework/uv.py DELETED
@@ -1,41 +0,0 @@
1
- from subprocess import run
2
- from .config import Config
3
-
4
- cfg = Config()
5
-
6
-
7
- class UvManager:
8
- def __init__(self):
9
- self.source_dir = cfg.source_dir
10
- self.source_files = cfg.source_files
11
-
12
- def check_for_venv(self):
13
- if cfg.pyproject_file not in self.source_files:
14
- self.init_uv()
15
- else:
16
- self.sync_uv()
17
-
18
- cfg.get_dependencies()
19
-
20
- def install_uv(self):
21
- try:
22
- run(["pip", "install", "uv"])
23
- run(["uv", "init"])
24
- except Exception as error:
25
- raise Exception(f"Unexpected Error during installing uv: {error}")
26
-
27
- def sync_uv(self):
28
- try:
29
- run(["uv", "sync"])
30
- except ModuleNotFoundError:
31
- self.install_uv()
32
-
33
- def init_uv(self):
34
- try:
35
- run(["uv", "init"])
36
- except ModuleNotFoundError:
37
- self.install_uv()
38
-
39
- def install_libs(self, libs: list):
40
- for lib in libs:
41
- run(["uv", "add", lib])