venvr 0.1__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.
venvr/__init__.py ADDED
@@ -0,0 +1,7 @@
1
+ from .agent import Agent
2
+ from .runner import Runner
3
+ from .builder import Builder
4
+ from .manager import Manager
5
+ from .venvr import run, getman, getagent, setvstore
6
+
7
+ __version__ = "0.1"
venvr/agent.py ADDED
@@ -0,0 +1,41 @@
1
+ from os.path import isdir, join as pjoin
2
+ from fyg import Config
3
+ from fyg.util import Named
4
+ from .runner import Runner
5
+ from .builder import Builder
6
+
7
+ class Agent(Named):
8
+ def __init__(self, name, vstore, deps=[]):
9
+ self.name = name
10
+ self.vstore = vstore
11
+ self.deps = deps
12
+ self.setup()
13
+
14
+ def run(self, funcname, *args, **kwargs):
15
+ self.log("run", funcname, args, kwargs)
16
+ return self.runner.run(funcname, *args, **kwargs)
17
+
18
+ def register(self, func):
19
+ name = self.builder.register(func)
20
+ self.log("register", name)
21
+ return name
22
+
23
+ def setup(self):
24
+ self.log("setup")
25
+ self.setpaths()
26
+ self.runner = Runner(self.name, self.path)
27
+ self.builder = Builder(self.name, self.path, self.deps)
28
+ isdir(self.path.base) or self.builder.build()
29
+
30
+ def setpaths(self):
31
+ base = pjoin(self.vstore, self.name)
32
+ self.log("setpaths", base)
33
+ venv = pjoin(base, "venv")
34
+ binp = pjoin(venv, "bin")
35
+ self.path = Config({
36
+ "base": base,
37
+ "venv": venv,
38
+ "pip": pjoin(binp, "pip"),
39
+ "py": pjoin(binp, "python"),
40
+ "run": {}
41
+ })
venvr/builder.py ADDED
@@ -0,0 +1,38 @@
1
+ import os, inspect
2
+ from .util import Basic, RTMP
3
+
4
+ class Builder(Basic):
5
+ def __init__(self, name, path, deps=[]):
6
+ self.name = name
7
+ self.path = path
8
+ self.dependencies = deps
9
+
10
+ def build(self):
11
+ self.log("build")
12
+ self.dir()
13
+ self.env()
14
+ self.deps()
15
+
16
+ def dir(self):
17
+ self.log("dir", self.path.base)
18
+ os.makedirs(self.path.base)
19
+
20
+ def env(self):
21
+ vp = self.path.venv
22
+ self.log("env", vp)
23
+ self.out("python3 -m venv %s"%(vp,))
24
+
25
+ def deps(self):
26
+ self.log("deps", *self.dependencies)
27
+ for dep in self.dependencies:
28
+ self.out("%s install %s"%(self.path.pip, dep))
29
+
30
+ def register(self, func):
31
+ fsrc = inspect.getsource(func)
32
+ name = fsrc.split(" ", 1).pop(1).split("(", 1).pop(0)
33
+ rp = self.based("%s.py"%(name,))
34
+ self.path.run.update(name, rp)
35
+ self.log("register", name, rp)
36
+ with open(rp, "w") as f:
37
+ f.write(RTMP%(fsrc, name))
38
+ return name
venvr/manager.py ADDED
@@ -0,0 +1,15 @@
1
+ from fyg.util import Loggy
2
+ from .agent import Agent
3
+
4
+ class Manager(Loggy):
5
+ def __init__(self, vstore):
6
+ self.vstore = vstore
7
+ self.venvrs = {} # detect?
8
+
9
+ def subsig(self):
10
+ return self.vstore
11
+
12
+ def agent(self, name, deps=[]):
13
+ if name not in self.venvrs:
14
+ self.venvrs[name] = Agent(name, self.vstore, deps)
15
+ return self.venvrs[name]
venvr/runner.py ADDED
@@ -0,0 +1,12 @@
1
+ from .util import Basic
2
+
3
+ class Runner(Basic):
4
+ def __init__(self, name, path):
5
+ self.name = name
6
+ self.path = path
7
+
8
+ def run(self, func, *args, **kwargs):
9
+ rp = self.path.run[func]
10
+ self.log("run", rp, *args, **kwargs)
11
+ return self.out("%s %s %s"%(self.path.py, rp,
12
+ " ".join(['"%s"'%(a,) for a in args])))
venvr/util.py ADDED
@@ -0,0 +1,21 @@
1
+ import os
2
+ from fyg.util import Named
3
+ from subprocess import getoutput
4
+
5
+ RTMP = """from optparse import OptionParser
6
+ parser = OptionParser("run.py [arg1] [arg2] ...")
7
+ args = parser.parse_args()[1]
8
+
9
+ %s
10
+ %s(*args)
11
+ """
12
+
13
+ class Basic(Named):
14
+ def out(self, cmd):
15
+ self.log("out", cmd)
16
+ out = getoutput(cmd)
17
+ self.log(out)
18
+ return out
19
+
20
+ def based(self, fname):
21
+ return os.path.join(self.path.base, fname)
venvr/venvr.py ADDED
@@ -0,0 +1,22 @@
1
+ from .manager import Manager
2
+
3
+ vstore = "venvrs"
4
+ manny = None
5
+
6
+ def setvstore(vs):
7
+ global vstore
8
+ vstore = vs
9
+ print("set vstore to", vs)
10
+
11
+ def getman():
12
+ global manny
13
+ if not manny:
14
+ manny = Manager(vstore)
15
+ return manny
16
+
17
+ def getagent(name, deps=[]):
18
+ return getman().agent(name, deps)
19
+
20
+ def run(envname, deps, func, *args, **kwargs):
21
+ agent = getagent(envname, deps)
22
+ return agent.run(agent.register(func), *args, **kwargs)
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 bubbleboy14
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,18 @@
1
+ Metadata-Version: 2.1
2
+ Name: venvr
3
+ Version: 0.1
4
+ Summary: Virtual ENVironment manageR
5
+ Author: Mario Balibrera
6
+ Author-email: mario.balibrera@gmail.com
7
+ License: MIT License
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Environment :: Console
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python
14
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
15
+ License-File: LICENSE
16
+ Requires-Dist: fyg >=0.1.6
17
+
18
+ classes and functions for interacting with virtual environments
@@ -0,0 +1,12 @@
1
+ venvr/__init__.py,sha256=VMH99SFxMbgl7fl_y19WCF5jHw0fiHuthwxE3a6tLxY,182
2
+ venvr/agent.py,sha256=bVeJX3bouweAng2_Godi8ithMWVTNVITKesUp1vQXRc,1025
3
+ venvr/builder.py,sha256=T23n9luXejIjA_eIGSZ54DdJ8jBNfh-uRSZlNhOJSws,866
4
+ venvr/manager.py,sha256=TP26-gs0yyMA_lky5MfzhWC6meUbUhfgiWngfBcMCQk,341
5
+ venvr/runner.py,sha256=hIsJhiTPiSS7dCG4u-bcaFymRCP4dpQ3Cj_2RyB1OW0,313
6
+ venvr/util.py,sha256=BhGTHBu_PysTHxKpb3NWQ06dFSbwiQGvQ1-nIzELAGo,400
7
+ venvr/venvr.py,sha256=FeMjVvGKzF6SlJO3d1OgBVb_QvZEJcwSCRldyk3-CBo,423
8
+ venvr-0.1.dist-info/LICENSE,sha256=TCGFq2RZnPZed3cKBhfq8EIxNzHcwJWJsBW8p9y1dDk,1068
9
+ venvr-0.1.dist-info/METADATA,sha256=9iw47W2p0cjQCeTNmnyUoAZQH8OZIz4D89npDhCl-9I,620
10
+ venvr-0.1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
11
+ venvr-0.1.dist-info/top_level.txt,sha256=s6ZJmeHqZxA6uB3xztzJOCJM0lJ3uJ--Xp26tiEBuZM,6
12
+ venvr-0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.42.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ venvr