kovy 0.1.0__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.
- kovy-0.1.0/PKG-INFO +56 -0
- kovy-0.1.0/README.md +46 -0
- kovy-0.1.0/pyproject.toml +25 -0
- kovy-0.1.0/src/kovy/help_panel.py +65 -0
- kovy-0.1.0/src/kovy/main.py +162 -0
- kovy-0.1.0/src/kovy/project.py +50 -0
- kovy-0.1.0/src/kovy/structure.py +83 -0
- kovy-0.1.0/src/kovy/utils.py +147 -0
- kovy-0.1.0/tests/test.py +0 -0
kovy-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: kovy
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Rust Cargo-like project manager for Python
|
|
5
|
+
Project-URL: Homepage, https://github.com/Kopihue/kovy/
|
|
6
|
+
Author-email: Kopihue <kopihuegit@gmail.com>
|
|
7
|
+
Requires-Python: >=3.14
|
|
8
|
+
Requires-Dist: paintmystring
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
|
|
11
|
+
# Cargopy š
|
|
12
|
+
|
|
13
|
+
**Cargopy** es una herramienta ligera inspirada en **cargo** de Rust para gestionar proyectos de Python de manera rÔpida y eficiente, desde la creación hasta la ejecución de scripts y manejo de paquetes.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## š ļø Uso
|
|
18
|
+
|
|
19
|
+
### Opciones disponibles
|
|
20
|
+
|
|
21
|
+
| Opción | Descripción |
|
|
22
|
+
|--------|-------------|
|
|
23
|
+
| `new <nombre>` | Crea un nuevo proyecto con el nombre indicado. |
|
|
24
|
+
| `cd` | Muestra la ruta raĆz de tu proyecto. |
|
|
25
|
+
| `venv` | Inicializa un entorno virtual en tu proyecto. |
|
|
26
|
+
| `run <script>` | Ejecuta el script indicado (solo si existe). |
|
|
27
|
+
| `install <paquete>` | Instala el paquete de Python especificado. |
|
|
28
|
+
| `upgrade <paquete>` | Actualiza el paquete especificado. |
|
|
29
|
+
| `uninstall <paquete>` | Desinstala el paquete especificado. |
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## ā” Ejemplos
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Crear un proyecto llamado "mi_proyecto"
|
|
37
|
+
cargopy new mi_proyecto
|
|
38
|
+
|
|
39
|
+
# Inicializar entorno virtual
|
|
40
|
+
cargopy venv
|
|
41
|
+
|
|
42
|
+
# Instalar requests
|
|
43
|
+
cargopy install requests
|
|
44
|
+
|
|
45
|
+
# Ejecutar script principal
|
|
46
|
+
cargopy run main.py
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
š” Notas
|
|
50
|
+
|
|
51
|
+
- AsegĆŗrate de tener Python instalado en tu sistema.
|
|
52
|
+
- run solo ejecutarĆ” scripts que existan dentro de tu proyecto.
|
|
53
|
+
- Maneja tus paquetes directamente desde Cargopy para mantener tu proyecto limpio y organizado.
|
|
54
|
+
|
|
55
|
+
Ā”Disfruta usando Cargopy! š
|
|
56
|
+
|
kovy-0.1.0/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Cargopy š
|
|
2
|
+
|
|
3
|
+
**Cargopy** es una herramienta ligera inspirada en **cargo** de Rust para gestionar proyectos de Python de manera rÔpida y eficiente, desde la creación hasta la ejecución de scripts y manejo de paquetes.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## š ļø Uso
|
|
8
|
+
|
|
9
|
+
### Opciones disponibles
|
|
10
|
+
|
|
11
|
+
| Opción | Descripción |
|
|
12
|
+
|--------|-------------|
|
|
13
|
+
| `new <nombre>` | Crea un nuevo proyecto con el nombre indicado. |
|
|
14
|
+
| `cd` | Muestra la ruta raĆz de tu proyecto. |
|
|
15
|
+
| `venv` | Inicializa un entorno virtual en tu proyecto. |
|
|
16
|
+
| `run <script>` | Ejecuta el script indicado (solo si existe). |
|
|
17
|
+
| `install <paquete>` | Instala el paquete de Python especificado. |
|
|
18
|
+
| `upgrade <paquete>` | Actualiza el paquete especificado. |
|
|
19
|
+
| `uninstall <paquete>` | Desinstala el paquete especificado. |
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## ā” Ejemplos
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# Crear un proyecto llamado "mi_proyecto"
|
|
27
|
+
cargopy new mi_proyecto
|
|
28
|
+
|
|
29
|
+
# Inicializar entorno virtual
|
|
30
|
+
cargopy venv
|
|
31
|
+
|
|
32
|
+
# Instalar requests
|
|
33
|
+
cargopy install requests
|
|
34
|
+
|
|
35
|
+
# Ejecutar script principal
|
|
36
|
+
cargopy run main.py
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
š” Notas
|
|
40
|
+
|
|
41
|
+
- AsegĆŗrate de tener Python instalado en tu sistema.
|
|
42
|
+
- run solo ejecutarĆ” scripts que existan dentro de tu proyecto.
|
|
43
|
+
- Maneja tus paquetes directamente desde Cargopy para mantener tu proyecto limpio y organizado.
|
|
44
|
+
|
|
45
|
+
Ā”Disfruta usando Cargopy! š
|
|
46
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "kovy"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Rust Cargo-like project manager for Python"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">= 3.14"
|
|
7
|
+
authors = [
|
|
8
|
+
{ name = "Kopihue", email = "kopihuegit@gmail.com" }
|
|
9
|
+
]
|
|
10
|
+
dependencies = [
|
|
11
|
+
"PaintMyString",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
[project.scripts]
|
|
15
|
+
kovy = "kovy.main:main"
|
|
16
|
+
|
|
17
|
+
[project.urls]
|
|
18
|
+
Homepage = "https://github.com/Kopihue/kovy/"
|
|
19
|
+
|
|
20
|
+
[build-system]
|
|
21
|
+
requires = ["hatchling"]
|
|
22
|
+
build-backend = "hatchling.build"
|
|
23
|
+
|
|
24
|
+
[tool.hatch.build.targets.wheel]
|
|
25
|
+
packages = ["src/kovy"]
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import time
|
|
3
|
+
from paintmystring.paint import paint
|
|
4
|
+
|
|
5
|
+
def clear(lazy: float):
|
|
6
|
+
time.sleep(lazy)
|
|
7
|
+
os.system("clear")
|
|
8
|
+
|
|
9
|
+
def help_panel():
|
|
10
|
+
clear(0)
|
|
11
|
+
|
|
12
|
+
paint(
|
|
13
|
+
paint("*"),
|
|
14
|
+
paint("Help panel deployed").bright_yellow().bold(),
|
|
15
|
+
paint("*"),
|
|
16
|
+
).show()
|
|
17
|
+
|
|
18
|
+
paint("*" * 23).show()
|
|
19
|
+
print()
|
|
20
|
+
|
|
21
|
+
paint(
|
|
22
|
+
paint("Usage:"),
|
|
23
|
+
paint("cargopy").bright_red().bold(),
|
|
24
|
+
paint("<option>").bright_green().bold(),
|
|
25
|
+
paint("<parameter>").bright_blue().bold(),
|
|
26
|
+
).show()
|
|
27
|
+
print()
|
|
28
|
+
|
|
29
|
+
paint("Options: ").bright_green().bold().show()
|
|
30
|
+
paint(
|
|
31
|
+
paint("\tnew <parameter> ->").bright_magenta(),
|
|
32
|
+
paint("Creates a new project named as <parameter>").bold()
|
|
33
|
+
).show()
|
|
34
|
+
|
|
35
|
+
paint(
|
|
36
|
+
paint("\tcd ->").bright_magenta(),
|
|
37
|
+
paint("Prints the path of the root of your project").bold()
|
|
38
|
+
).show()
|
|
39
|
+
|
|
40
|
+
paint(
|
|
41
|
+
paint("\tvenv ->").bright_magenta(),
|
|
42
|
+
paint("Initializes a virtual env in your project").bold()
|
|
43
|
+
).show()
|
|
44
|
+
|
|
45
|
+
paint(
|
|
46
|
+
paint("\trun <parameter> ->").bright_magenta(),
|
|
47
|
+
paint("Runs the script named <parameter> just if it exists").bold()
|
|
48
|
+
).show()
|
|
49
|
+
|
|
50
|
+
paint(
|
|
51
|
+
paint("\tinstall <parameter> ->").bright_magenta(),
|
|
52
|
+
paint("Installs the package named <parameter>").bold()
|
|
53
|
+
).show()
|
|
54
|
+
|
|
55
|
+
paint(
|
|
56
|
+
paint("\tupgrade <parameter> ->").bright_magenta(),
|
|
57
|
+
paint("Upgrades the package named <parameter>").bold()
|
|
58
|
+
).show()
|
|
59
|
+
|
|
60
|
+
paint(
|
|
61
|
+
paint("\tuninstall <parameter> ->").bright_magenta(),
|
|
62
|
+
paint("Uninstalls the package named <parameter>").bold()
|
|
63
|
+
).show()
|
|
64
|
+
|
|
65
|
+
print()
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
from paintmystring.paint import paint
|
|
2
|
+
from .help_panel import help_panel
|
|
3
|
+
from .structure import Structure
|
|
4
|
+
from .utils import Utils
|
|
5
|
+
import sys
|
|
6
|
+
|
|
7
|
+
def main():
|
|
8
|
+
args = sys.argv[1:]
|
|
9
|
+
|
|
10
|
+
new = False
|
|
11
|
+
dir_name = None
|
|
12
|
+
|
|
13
|
+
cd = False
|
|
14
|
+
|
|
15
|
+
venv = False
|
|
16
|
+
|
|
17
|
+
run = False
|
|
18
|
+
file_name = None
|
|
19
|
+
file_args = None
|
|
20
|
+
|
|
21
|
+
pip = None
|
|
22
|
+
package = None
|
|
23
|
+
install = False
|
|
24
|
+
upgrade = False
|
|
25
|
+
uninstall = False
|
|
26
|
+
listed = False
|
|
27
|
+
|
|
28
|
+
build = None
|
|
29
|
+
upload = None
|
|
30
|
+
|
|
31
|
+
while args:
|
|
32
|
+
arg = args.pop(0)
|
|
33
|
+
|
|
34
|
+
match arg:
|
|
35
|
+
case "help" | "--help":
|
|
36
|
+
help_panel()
|
|
37
|
+
|
|
38
|
+
case "new":
|
|
39
|
+
new = True
|
|
40
|
+
try:
|
|
41
|
+
dir_name = args.pop(0)
|
|
42
|
+
except IndexError:
|
|
43
|
+
paint(
|
|
44
|
+
paint("New").bright_red().bold(),
|
|
45
|
+
paint("action requires an argument...").bold(),
|
|
46
|
+
).show()
|
|
47
|
+
|
|
48
|
+
case "cd":
|
|
49
|
+
cd = True
|
|
50
|
+
|
|
51
|
+
case "venv":
|
|
52
|
+
venv = True
|
|
53
|
+
|
|
54
|
+
case "run":
|
|
55
|
+
run = True
|
|
56
|
+
try:
|
|
57
|
+
file_name = args.pop(0)
|
|
58
|
+
except IndexError:
|
|
59
|
+
paint(
|
|
60
|
+
paint("Run").bright_red().bold(),
|
|
61
|
+
paint("action requires an argument...").bold(),
|
|
62
|
+
).show()
|
|
63
|
+
|
|
64
|
+
try:
|
|
65
|
+
are_there_arguments = args.pop(0)
|
|
66
|
+
if are_there_arguments == "--":
|
|
67
|
+
pass
|
|
68
|
+
|
|
69
|
+
else:
|
|
70
|
+
raise ValueError("Invalid action")
|
|
71
|
+
except IndexError:
|
|
72
|
+
file_args = []
|
|
73
|
+
else:
|
|
74
|
+
file_args = args
|
|
75
|
+
|
|
76
|
+
case "install":
|
|
77
|
+
pip = True
|
|
78
|
+
install = True
|
|
79
|
+
try:
|
|
80
|
+
package = args.pop(0)
|
|
81
|
+
except IndexError:
|
|
82
|
+
paint(
|
|
83
|
+
paint("Install").bright_red().bold(),
|
|
84
|
+
paint("action requires an argument...").bold(),
|
|
85
|
+
).show()
|
|
86
|
+
|
|
87
|
+
case "upgrade":
|
|
88
|
+
pip = True
|
|
89
|
+
upgrade = True
|
|
90
|
+
try:
|
|
91
|
+
package = args.pop(0)
|
|
92
|
+
except IndexError:
|
|
93
|
+
paint(
|
|
94
|
+
paint("Upgrade").bright_red().bold(),
|
|
95
|
+
paint("action requires an argument...").bold(),
|
|
96
|
+
).show()
|
|
97
|
+
|
|
98
|
+
case "uninstall":
|
|
99
|
+
pip = True
|
|
100
|
+
uninstall = True
|
|
101
|
+
try:
|
|
102
|
+
package = args.pop(0)
|
|
103
|
+
except IndexError:
|
|
104
|
+
paint(
|
|
105
|
+
paint("Uninstall").bright_red().bold(),
|
|
106
|
+
paint("action requires an argument...").bold(),
|
|
107
|
+
).show()
|
|
108
|
+
|
|
109
|
+
case "list":
|
|
110
|
+
pip = True
|
|
111
|
+
listed = True
|
|
112
|
+
package = "list"
|
|
113
|
+
|
|
114
|
+
case _:
|
|
115
|
+
paint("Unknown option...").bold().red().show()
|
|
116
|
+
paint(
|
|
117
|
+
paint("Try:").bright_cyan().bold(),
|
|
118
|
+
paint("help").bright_yellow(),
|
|
119
|
+
).show()
|
|
120
|
+
|
|
121
|
+
if new or cd:
|
|
122
|
+
struct = Structure()
|
|
123
|
+
|
|
124
|
+
if new:
|
|
125
|
+
if dir_name is None:
|
|
126
|
+
sys.exit(1)
|
|
127
|
+
|
|
128
|
+
struct.new(dir_name)
|
|
129
|
+
|
|
130
|
+
elif cd:
|
|
131
|
+
print(struct.cd())
|
|
132
|
+
|
|
133
|
+
if venv or run or pip:
|
|
134
|
+
project_utils = Utils()
|
|
135
|
+
|
|
136
|
+
if venv:
|
|
137
|
+
project_utils.venv()
|
|
138
|
+
|
|
139
|
+
elif run:
|
|
140
|
+
if file_name is None:
|
|
141
|
+
sys.exit(1)
|
|
142
|
+
|
|
143
|
+
project_utils.run(file_name, file_args)
|
|
144
|
+
|
|
145
|
+
elif pip:
|
|
146
|
+
if package is None:
|
|
147
|
+
sys.exit(1)
|
|
148
|
+
|
|
149
|
+
if install:
|
|
150
|
+
project_utils.pip("install", package)
|
|
151
|
+
|
|
152
|
+
elif upgrade:
|
|
153
|
+
project_utils.pip("upgrade", package)
|
|
154
|
+
|
|
155
|
+
elif uninstall:
|
|
156
|
+
project_utils.pip("uninstall", package)
|
|
157
|
+
|
|
158
|
+
elif listed:
|
|
159
|
+
project_utils.pip("list")
|
|
160
|
+
|
|
161
|
+
if __name__ == "__main__":
|
|
162
|
+
main()
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
class Project:
|
|
5
|
+
@staticmethod
|
|
6
|
+
def get_project_root() -> Path | None:
|
|
7
|
+
pwd = Path.cwd()
|
|
8
|
+
|
|
9
|
+
while True:
|
|
10
|
+
if pwd == pwd.parent:
|
|
11
|
+
return None
|
|
12
|
+
|
|
13
|
+
if (pwd / "pyproject.toml").exists():
|
|
14
|
+
return pwd
|
|
15
|
+
|
|
16
|
+
else:
|
|
17
|
+
pwd = pwd.parent
|
|
18
|
+
|
|
19
|
+
@staticmethod
|
|
20
|
+
def check_venv_existence() -> bool | None:
|
|
21
|
+
pwd = Project.get_project_root()
|
|
22
|
+
if pwd is None:
|
|
23
|
+
return None
|
|
24
|
+
|
|
25
|
+
if (pwd / ".venv").exists():
|
|
26
|
+
return True
|
|
27
|
+
|
|
28
|
+
else:
|
|
29
|
+
return False
|
|
30
|
+
|
|
31
|
+
@staticmethod
|
|
32
|
+
def get_isolated_python() -> Path | None:
|
|
33
|
+
root_project = Project.get_project_root()
|
|
34
|
+
|
|
35
|
+
if root_project is None:
|
|
36
|
+
return None
|
|
37
|
+
|
|
38
|
+
isolated_python = (
|
|
39
|
+
root_project
|
|
40
|
+
/ ".venv"
|
|
41
|
+
/ "bin"
|
|
42
|
+
/ "python"
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
if not isolated_python.exists():
|
|
46
|
+
print("Virtual Python doesn't exists")
|
|
47
|
+
print("Try running again \"cargopy venv\"")
|
|
48
|
+
sys.exit(1)
|
|
49
|
+
|
|
50
|
+
return isolated_python
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from .project import Project
|
|
3
|
+
from paintmystring.paint import paint
|
|
4
|
+
import sys
|
|
5
|
+
import shutil
|
|
6
|
+
import subprocess
|
|
7
|
+
|
|
8
|
+
class Structure(Project):
|
|
9
|
+
def __init__(self):
|
|
10
|
+
self.pwd = Path.cwd()
|
|
11
|
+
self.root_project = self.get_project_root()
|
|
12
|
+
|
|
13
|
+
def new(self, dir_name: str):
|
|
14
|
+
py_project = """[project]
|
|
15
|
+
name = ""
|
|
16
|
+
version = "0.1.0"
|
|
17
|
+
description = ""
|
|
18
|
+
readme = "README.md"
|
|
19
|
+
requires-python = ">= 3.14"
|
|
20
|
+
authors = [
|
|
21
|
+
{ name = "Kopihue", email = "kopihuegit@gmail.com" }
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
[project.urls]
|
|
25
|
+
Homepage = ""
|
|
26
|
+
|
|
27
|
+
[build-system]
|
|
28
|
+
requires = ["hatchling"]
|
|
29
|
+
build-backend = "hatchling.build"
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
dir_path = self.pwd / dir_name
|
|
33
|
+
|
|
34
|
+
if dir_path.exists():
|
|
35
|
+
paint("Project already exists...").bright_magenta().bold().show()
|
|
36
|
+
sys.exit(1)
|
|
37
|
+
|
|
38
|
+
try:
|
|
39
|
+
dir_path.mkdir(exist_ok=True)
|
|
40
|
+
except Exception as e:
|
|
41
|
+
paint(
|
|
42
|
+
paint("Exception").bright_red().bold(),
|
|
43
|
+
paint(e).bold(),
|
|
44
|
+
).show()
|
|
45
|
+
|
|
46
|
+
(dir_path / "README.md").touch()
|
|
47
|
+
(dir_path / "pyproject.toml").touch()
|
|
48
|
+
with open(dir_path / "pyproject.toml", "w") as f:
|
|
49
|
+
f.write(py_project)
|
|
50
|
+
|
|
51
|
+
src_dir = dir_path / "src"
|
|
52
|
+
tests_dir = dir_path / "tests"
|
|
53
|
+
src_dir.mkdir()
|
|
54
|
+
tests_dir.mkdir()
|
|
55
|
+
|
|
56
|
+
package_dir = src_dir / dir_name
|
|
57
|
+
package_dir.mkdir()
|
|
58
|
+
(package_dir / "__init__.py").touch()
|
|
59
|
+
|
|
60
|
+
paint(
|
|
61
|
+
paint("Created project in ->").bold(),
|
|
62
|
+
paint(dir_name).bold().bright_blue(),
|
|
63
|
+
).show()
|
|
64
|
+
if shutil.which("git") is not None:
|
|
65
|
+
subprocess.run(
|
|
66
|
+
"git init &>/dev/null",
|
|
67
|
+
cwd=dir_path,
|
|
68
|
+
shell=True,
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
else:
|
|
72
|
+
paint(
|
|
73
|
+
paint("Couldn't start git repository ->").bold(),
|
|
74
|
+
paint("git is not on your path").bright_magenta(),
|
|
75
|
+
).show()
|
|
76
|
+
|
|
77
|
+
def cd(self) -> Path:
|
|
78
|
+
if self.root_project is None:
|
|
79
|
+
paint("Not a Python project!").bright_magenta().bold().show()
|
|
80
|
+
sys.exit(1)
|
|
81
|
+
|
|
82
|
+
else:
|
|
83
|
+
return self.root_project
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from .structure import Structure
|
|
3
|
+
from .project import Project
|
|
4
|
+
from paintmystring.paint import paint
|
|
5
|
+
import subprocess
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
class Utils(Project):
|
|
9
|
+
def __init__(self):
|
|
10
|
+
self.struct = Structure()
|
|
11
|
+
|
|
12
|
+
self.pwd = Path.cwd()
|
|
13
|
+
self.root_project = self.get_project_root()
|
|
14
|
+
|
|
15
|
+
def venv(self):
|
|
16
|
+
check_venv = self.check_venv_existence()
|
|
17
|
+
if check_venv is None:
|
|
18
|
+
paint("Not a Python project!").bright_magenta().bold().show()
|
|
19
|
+
sys.exit(1)
|
|
20
|
+
|
|
21
|
+
if check_venv:
|
|
22
|
+
paint(
|
|
23
|
+
paint(".venv").bright_cyan().bold(),
|
|
24
|
+
paint("already exists!").bold(),
|
|
25
|
+
).show()
|
|
26
|
+
sys.exit(1)
|
|
27
|
+
|
|
28
|
+
else:
|
|
29
|
+
command = ["python", "-m", "venv", ".venv"]
|
|
30
|
+
result = subprocess.run(
|
|
31
|
+
command,
|
|
32
|
+
capture_output=True,
|
|
33
|
+
text=True,
|
|
34
|
+
cwd=self.root_project
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
self.pip("pip", "upgrade")
|
|
38
|
+
|
|
39
|
+
if result.returncode != 0:
|
|
40
|
+
paint("The command has failed.").bold().show()
|
|
41
|
+
print(result.stderr)
|
|
42
|
+
|
|
43
|
+
else:
|
|
44
|
+
paint(
|
|
45
|
+
paint("Succesfully created venv in ->").bold(),
|
|
46
|
+
paint(".venv").bright_cyan().bold(),
|
|
47
|
+
).show()
|
|
48
|
+
|
|
49
|
+
def run(self, file_name: str, file_args: list[str] | None):
|
|
50
|
+
check_venv = self.check_venv_existence()
|
|
51
|
+
isolated_python = self.get_isolated_python()
|
|
52
|
+
|
|
53
|
+
if file_args is None:
|
|
54
|
+
sys.exit(1)
|
|
55
|
+
|
|
56
|
+
if (
|
|
57
|
+
check_venv is None
|
|
58
|
+
or self.root_project is None
|
|
59
|
+
or isolated_python is None
|
|
60
|
+
):
|
|
61
|
+
paint("Not a Python project!").bright_magenta().bold().show()
|
|
62
|
+
sys.exit(1)
|
|
63
|
+
|
|
64
|
+
if not check_venv:
|
|
65
|
+
self.venv()
|
|
66
|
+
check_venv = True
|
|
67
|
+
|
|
68
|
+
if check_venv:
|
|
69
|
+
ignored_dirs = {".venv", "__pycache__"}
|
|
70
|
+
found_scripts = []
|
|
71
|
+
for path in self.root_project.rglob(file_name):
|
|
72
|
+
if not any(
|
|
73
|
+
ignored in path.parts
|
|
74
|
+
for ignored in ignored_dirs
|
|
75
|
+
):
|
|
76
|
+
found_scripts.append(path.resolve())
|
|
77
|
+
|
|
78
|
+
if not found_scripts:
|
|
79
|
+
paint(
|
|
80
|
+
paint("Didn't find script in ->").bold(),
|
|
81
|
+
paint(file_name).blue(),
|
|
82
|
+
).show()
|
|
83
|
+
sys.exit(1)
|
|
84
|
+
|
|
85
|
+
command = [isolated_python, found_scripts[0], *file_args]
|
|
86
|
+
subprocess.run(
|
|
87
|
+
command,
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
def pip(self, action: str, package: str | None = None):
|
|
91
|
+
check_venv = self.check_venv_existence()
|
|
92
|
+
isolated_python = self.get_isolated_python()
|
|
93
|
+
|
|
94
|
+
if check_venv is None or isolated_python is None:
|
|
95
|
+
paint("Not a Python project!").bright_magenta().bold().show()
|
|
96
|
+
sys.exit(1)
|
|
97
|
+
|
|
98
|
+
if not check_venv:
|
|
99
|
+
self.venv()
|
|
100
|
+
check_venv = True
|
|
101
|
+
|
|
102
|
+
if check_venv:
|
|
103
|
+
if action == "install" and package is not None:
|
|
104
|
+
command = [
|
|
105
|
+
isolated_python,
|
|
106
|
+
"-m",
|
|
107
|
+
"pip",
|
|
108
|
+
action,
|
|
109
|
+
package,
|
|
110
|
+
]
|
|
111
|
+
|
|
112
|
+
elif action == "upgrade" and package is not None:
|
|
113
|
+
command = [
|
|
114
|
+
isolated_python,
|
|
115
|
+
"-m",
|
|
116
|
+
"pip",
|
|
117
|
+
"install",
|
|
118
|
+
"--upgrade",
|
|
119
|
+
package,
|
|
120
|
+
]
|
|
121
|
+
|
|
122
|
+
elif action == "uninstall" and package is not None:
|
|
123
|
+
command = [
|
|
124
|
+
isolated_python,
|
|
125
|
+
"-m",
|
|
126
|
+
"pip",
|
|
127
|
+
action,
|
|
128
|
+
"-y",
|
|
129
|
+
package
|
|
130
|
+
]
|
|
131
|
+
|
|
132
|
+
elif action == "list":
|
|
133
|
+
command = [
|
|
134
|
+
isolated_python,
|
|
135
|
+
"-m",
|
|
136
|
+
"pip",
|
|
137
|
+
action,
|
|
138
|
+
]
|
|
139
|
+
|
|
140
|
+
else:
|
|
141
|
+
paint("Not a pip command!").bright_magenta().bold().show()
|
|
142
|
+
sys.exit(1)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
subprocess.run(
|
|
146
|
+
command,
|
|
147
|
+
)
|
kovy-0.1.0/tests/test.py
ADDED
|
File without changes
|