koichi12 commited on
Commit
89bcfcb
·
verified ·
1 Parent(s): 197b963

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .venv/lib/python3.11/site-packages/dill/tests/__init__.py +22 -0
  2. .venv/lib/python3.11/site-packages/dill/tests/__pycache__/test_moduledict.cpython-311.pyc +0 -0
  3. .venv/lib/python3.11/site-packages/dill/tests/test_abc.py +169 -0
  4. .venv/lib/python3.11/site-packages/dill/tests/test_dataclasses.py +35 -0
  5. .venv/lib/python3.11/site-packages/dill/tests/test_dictviews.py +39 -0
  6. .venv/lib/python3.11/site-packages/dill/tests/test_functions.py +141 -0
  7. .venv/lib/python3.11/site-packages/dill/tests/test_recursive.py +177 -0
  8. .venv/lib/python3.11/site-packages/dill/tests/test_restricted.py +27 -0
  9. .venv/lib/python3.11/site-packages/dill/tests/test_selected.py +126 -0
  10. .venv/lib/python3.11/site-packages/dill/tests/test_threads.py +46 -0
  11. .venv/lib/python3.11/site-packages/virtualenv/__pycache__/__init__.cpython-311.pyc +0 -0
  12. .venv/lib/python3.11/site-packages/virtualenv/__pycache__/__main__.cpython-311.pyc +0 -0
  13. .venv/lib/python3.11/site-packages/virtualenv/__pycache__/info.cpython-311.pyc +0 -0
  14. .venv/lib/python3.11/site-packages/virtualenv/__pycache__/report.cpython-311.pyc +0 -0
  15. .venv/lib/python3.11/site-packages/virtualenv/__pycache__/version.cpython-311.pyc +0 -0
  16. .venv/lib/python3.11/site-packages/virtualenv/activation/__init__.py +19 -0
  17. .venv/lib/python3.11/site-packages/virtualenv/activation/__pycache__/__init__.cpython-311.pyc +0 -0
  18. .venv/lib/python3.11/site-packages/virtualenv/activation/__pycache__/activator.cpython-311.pyc +0 -0
  19. .venv/lib/python3.11/site-packages/virtualenv/activation/__pycache__/via_template.cpython-311.pyc +0 -0
  20. .venv/lib/python3.11/site-packages/virtualenv/activation/activator.py +50 -0
  21. .venv/lib/python3.11/site-packages/virtualenv/activation/bash/__init__.py +18 -0
  22. .venv/lib/python3.11/site-packages/virtualenv/activation/bash/__pycache__/__init__.cpython-311.pyc +0 -0
  23. .venv/lib/python3.11/site-packages/virtualenv/activation/bash/activate.sh +87 -0
  24. .venv/lib/python3.11/site-packages/virtualenv/activation/batch/__init__.py +30 -0
  25. .venv/lib/python3.11/site-packages/virtualenv/activation/batch/__pycache__/__init__.cpython-311.pyc +0 -0
  26. .venv/lib/python3.11/site-packages/virtualenv/activation/batch/activate.bat +50 -0
  27. .venv/lib/python3.11/site-packages/virtualenv/activation/batch/deactivate.bat +18 -0
  28. .venv/lib/python3.11/site-packages/virtualenv/activation/batch/pydoc.bat +1 -0
  29. .venv/lib/python3.11/site-packages/virtualenv/activation/cshell/__init__.py +17 -0
  30. .venv/lib/python3.11/site-packages/virtualenv/activation/cshell/__pycache__/__init__.cpython-311.pyc +0 -0
  31. .venv/lib/python3.11/site-packages/virtualenv/activation/cshell/activate.csh +55 -0
  32. .venv/lib/python3.11/site-packages/virtualenv/activation/fish/__init__.py +13 -0
  33. .venv/lib/python3.11/site-packages/virtualenv/activation/fish/__pycache__/__init__.cpython-311.pyc +0 -0
  34. .venv/lib/python3.11/site-packages/virtualenv/activation/fish/activate.fish +103 -0
  35. .venv/lib/python3.11/site-packages/virtualenv/activation/nushell/__init__.py +40 -0
  36. .venv/lib/python3.11/site-packages/virtualenv/activation/nushell/__pycache__/__init__.cpython-311.pyc +0 -0
  37. .venv/lib/python3.11/site-packages/virtualenv/activation/nushell/activate.nu +96 -0
  38. .venv/lib/python3.11/site-packages/virtualenv/activation/powershell/__init__.py +25 -0
  39. .venv/lib/python3.11/site-packages/virtualenv/activation/powershell/__pycache__/__init__.cpython-311.pyc +0 -0
  40. .venv/lib/python3.11/site-packages/virtualenv/activation/powershell/activate.ps1 +61 -0
  41. .venv/lib/python3.11/site-packages/virtualenv/activation/python/__init__.py +32 -0
  42. .venv/lib/python3.11/site-packages/virtualenv/activation/python/__pycache__/__init__.cpython-311.pyc +0 -0
  43. .venv/lib/python3.11/site-packages/virtualenv/activation/python/__pycache__/activate_this.cpython-311.pyc +0 -0
  44. .venv/lib/python3.11/site-packages/virtualenv/activation/python/activate_this.py +38 -0
  45. .venv/lib/python3.11/site-packages/virtualenv/activation/via_template.py +87 -0
  46. .venv/lib/python3.11/site-packages/virtualenv/app_data/__init__.py +58 -0
  47. .venv/lib/python3.11/site-packages/virtualenv/app_data/__pycache__/__init__.cpython-311.pyc +0 -0
  48. .venv/lib/python3.11/site-packages/virtualenv/app_data/__pycache__/base.cpython-311.pyc +0 -0
  49. .venv/lib/python3.11/site-packages/virtualenv/app_data/__pycache__/na.cpython-311.pyc +0 -0
  50. .venv/lib/python3.11/site-packages/virtualenv/app_data/__pycache__/read_only.cpython-311.pyc +0 -0
.venv/lib/python3.11/site-packages/dill/tests/__init__.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
4
+ # Copyright (c) 2018-2024 The Uncertainty Quantification Foundation.
5
+ # License: 3-clause BSD. The full license text is available at:
6
+ # - https://github.com/uqfoundation/dill/blob/master/LICENSE
7
+ """
8
+ to run this test suite, first build and install `dill`.
9
+
10
+ $ python -m pip install ../..
11
+
12
+
13
+ then run the tests with:
14
+
15
+ $ python -m dill.tests
16
+
17
+
18
+ or, if `nose` is installed:
19
+
20
+ $ nosetests
21
+
22
+ """
.venv/lib/python3.11/site-packages/dill/tests/__pycache__/test_moduledict.cpython-311.pyc ADDED
Binary file (2.34 kB). View file
 
.venv/lib/python3.11/site-packages/dill/tests/test_abc.py ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
4
+ # Copyright (c) 2023-2024 The Uncertainty Quantification Foundation.
5
+ # License: 3-clause BSD. The full license text is available at:
6
+ # - https://github.com/uqfoundation/dill/blob/master/LICENSE
7
+ """
8
+ test dill's ability to pickle abstract base class objects
9
+ """
10
+ import dill
11
+ import abc
12
+ from abc import ABC
13
+ import warnings
14
+
15
+ from types import FunctionType
16
+
17
+ dill.settings['recurse'] = True
18
+
19
+ class OneTwoThree(ABC):
20
+ @abc.abstractmethod
21
+ def foo(self):
22
+ """A method"""
23
+ pass
24
+
25
+ @property
26
+ @abc.abstractmethod
27
+ def bar(self):
28
+ """Property getter"""
29
+ pass
30
+
31
+ @bar.setter
32
+ @abc.abstractmethod
33
+ def bar(self, value):
34
+ """Property setter"""
35
+ pass
36
+
37
+ @classmethod
38
+ @abc.abstractmethod
39
+ def cfoo(cls):
40
+ """Class method"""
41
+ pass
42
+
43
+ @staticmethod
44
+ @abc.abstractmethod
45
+ def sfoo():
46
+ """Static method"""
47
+ pass
48
+
49
+ class EasyAsAbc(OneTwoThree):
50
+ def __init__(self):
51
+ self._bar = None
52
+
53
+ def foo(self):
54
+ return "Instance Method FOO"
55
+
56
+ @property
57
+ def bar(self):
58
+ return self._bar
59
+
60
+ @bar.setter
61
+ def bar(self, value):
62
+ self._bar = value
63
+
64
+ @classmethod
65
+ def cfoo(cls):
66
+ return "Class Method CFOO"
67
+
68
+ @staticmethod
69
+ def sfoo():
70
+ return "Static Method SFOO"
71
+
72
+ def test_abc_non_local():
73
+ assert dill.copy(OneTwoThree) is not OneTwoThree
74
+ assert dill.copy(EasyAsAbc) is not EasyAsAbc
75
+
76
+ with warnings.catch_warnings():
77
+ warnings.simplefilter("ignore", dill.PicklingWarning)
78
+ assert dill.copy(OneTwoThree, byref=True) is OneTwoThree
79
+ assert dill.copy(EasyAsAbc, byref=True) is EasyAsAbc
80
+
81
+ instance = EasyAsAbc()
82
+ # Set a property that StockPickle can't preserve
83
+ instance.bar = lambda x: x**2
84
+ depickled = dill.copy(instance)
85
+ assert type(depickled) is type(instance) #NOTE: issue #612, test_abc_local
86
+ #NOTE: dill.copy of local (or non-local) classes should (not) be the same?
87
+ assert type(depickled.bar) is FunctionType
88
+ assert depickled.bar(3) == 9
89
+ assert depickled.sfoo() == "Static Method SFOO"
90
+ assert depickled.cfoo() == "Class Method CFOO"
91
+ assert depickled.foo() == "Instance Method FOO"
92
+
93
+ def test_abc_local():
94
+ """
95
+ Test using locally scoped ABC class
96
+ """
97
+ class LocalABC(ABC):
98
+ @abc.abstractmethod
99
+ def foo(self):
100
+ pass
101
+
102
+ def baz(self):
103
+ return repr(self)
104
+
105
+ labc = dill.copy(LocalABC)
106
+ assert labc is not LocalABC
107
+ assert type(labc) is type(LocalABC)
108
+ #NOTE: dill.copy of local (or non-local) classes should (not) be the same?
109
+ # <class '__main__.LocalABC'>
110
+ # <class '__main__.test_abc_local.<locals>.LocalABC'>
111
+
112
+ class Real(labc):
113
+ def foo(self):
114
+ return "True!"
115
+
116
+ def baz(self):
117
+ return "My " + super(Real, self).baz()
118
+
119
+ real = Real()
120
+ assert real.foo() == "True!"
121
+
122
+ try:
123
+ labc()
124
+ except TypeError as e:
125
+ # Expected error
126
+ pass
127
+ else:
128
+ print('Failed to raise type error')
129
+ assert False
130
+
131
+ labc2, pik = dill.copy((labc, Real()))
132
+ assert 'Real' == type(pik).__name__
133
+ assert '.Real' in type(pik).__qualname__
134
+ assert type(pik) is not Real
135
+ assert labc2 is not LocalABC
136
+ assert labc2 is not labc
137
+ assert isinstance(pik, labc2)
138
+ assert not isinstance(pik, labc)
139
+ assert not isinstance(pik, LocalABC)
140
+ assert pik.baz() == "My " + repr(pik)
141
+
142
+ def test_meta_local_no_cache():
143
+ """
144
+ Test calling metaclass and cache registration
145
+ """
146
+ LocalMetaABC = abc.ABCMeta('LocalMetaABC', (), {})
147
+
148
+ class ClassyClass:
149
+ pass
150
+
151
+ class KlassyClass:
152
+ pass
153
+
154
+ LocalMetaABC.register(ClassyClass)
155
+
156
+ assert not issubclass(KlassyClass, LocalMetaABC)
157
+ assert issubclass(ClassyClass, LocalMetaABC)
158
+
159
+ res = dill.dumps((LocalMetaABC, ClassyClass, KlassyClass))
160
+
161
+ lmabc, cc, kc = dill.loads(res)
162
+ assert type(lmabc) == type(LocalMetaABC)
163
+ assert not issubclass(kc, lmabc)
164
+ assert issubclass(cc, lmabc)
165
+
166
+ if __name__ == '__main__':
167
+ test_abc_non_local()
168
+ test_abc_local()
169
+ test_meta_local_no_cache()
.venv/lib/python3.11/site-packages/dill/tests/test_dataclasses.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
4
+ # Author: Anirudh Vegesana (avegesan@cs.stanford.edu)
5
+ # Copyright (c) 2022-2024 The Uncertainty Quantification Foundation.
6
+ # License: 3-clause BSD. The full license text is available at:
7
+ # - https://github.com/uqfoundation/dill/blob/master/LICENSE
8
+ """
9
+ test pickling a dataclass
10
+ """
11
+
12
+ import dill
13
+ import dataclasses
14
+
15
+ def test_dataclasses():
16
+ # Issue #500
17
+ @dataclasses.dataclass
18
+ class A:
19
+ x: int
20
+ y: str
21
+
22
+ @dataclasses.dataclass
23
+ class B:
24
+ a: A
25
+
26
+ a = A(1, "test")
27
+ before = B(a)
28
+ save = dill.dumps(before)
29
+ after = dill.loads(save)
30
+ assert before != after # classes don't match
31
+ assert before == B(A(**dataclasses.asdict(after.a)))
32
+ assert dataclasses.asdict(before) == dataclasses.asdict(after)
33
+
34
+ if __name__ == '__main__':
35
+ test_dataclasses()
.venv/lib/python3.11/site-packages/dill/tests/test_dictviews.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
4
+ # Author: Anirudh Vegesana (avegesan@cs.stanford.edu)
5
+ # Copyright (c) 2021-2024 The Uncertainty Quantification Foundation.
6
+ # License: 3-clause BSD. The full license text is available at:
7
+ # - https://github.com/uqfoundation/dill/blob/master/LICENSE
8
+
9
+ import dill
10
+ from dill._dill import OLD310, MAPPING_PROXY_TRICK, DictProxyType
11
+
12
+ def test_dictproxy():
13
+ assert dill.copy(DictProxyType({'a': 2}))
14
+
15
+ def test_dictviews():
16
+ x = {'a': 1}
17
+ assert dill.copy(x.keys())
18
+ assert dill.copy(x.values())
19
+ assert dill.copy(x.items())
20
+
21
+ def test_dictproxy_trick():
22
+ if not OLD310 and MAPPING_PROXY_TRICK:
23
+ x = {'a': 1}
24
+ all_views = (x.values(), x.items(), x.keys(), x)
25
+ seperate_views = dill.copy(all_views)
26
+ new_x = seperate_views[-1]
27
+ new_x['b'] = 2
28
+ new_x['c'] = 1
29
+ assert len(new_x) == 3 and len(x) == 1
30
+ assert len(seperate_views[0]) == 3 and len(all_views[0]) == 1
31
+ assert len(seperate_views[1]) == 3 and len(all_views[1]) == 1
32
+ assert len(seperate_views[2]) == 3 and len(all_views[2]) == 1
33
+ assert dict(all_views[1]) == x
34
+ assert dict(seperate_views[1]) == new_x
35
+
36
+ if __name__ == '__main__':
37
+ test_dictproxy()
38
+ test_dictviews()
39
+ test_dictproxy_trick()
.venv/lib/python3.11/site-packages/dill/tests/test_functions.py ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
4
+ # Copyright (c) 2019-2024 The Uncertainty Quantification Foundation.
5
+ # License: 3-clause BSD. The full license text is available at:
6
+ # - https://github.com/uqfoundation/dill/blob/master/LICENSE
7
+
8
+ import functools
9
+ import dill
10
+ import sys
11
+ dill.settings['recurse'] = True
12
+
13
+
14
+ def function_a(a):
15
+ return a
16
+
17
+
18
+ def function_b(b, b1):
19
+ return b + b1
20
+
21
+
22
+ def function_c(c, c1=1):
23
+ return c + c1
24
+
25
+
26
+ def function_d(d, d1, d2=1):
27
+ """doc string"""
28
+ return d + d1 + d2
29
+
30
+ function_d.__module__ = 'a module'
31
+
32
+
33
+ exec('''
34
+ def function_e(e, *e1, e2=1, e3=2):
35
+ return e + sum(e1) + e2 + e3''')
36
+
37
+ globalvar = 0
38
+
39
+ @functools.lru_cache(None)
40
+ def function_with_cache(x):
41
+ global globalvar
42
+ globalvar += x
43
+ return globalvar
44
+
45
+
46
+ def function_with_unassigned_variable():
47
+ if False:
48
+ value = None
49
+ return (lambda: value)
50
+
51
+
52
+ def test_issue_510():
53
+ # A very bizzare use of functions and methods that pickle doesn't get
54
+ # correctly for odd reasons.
55
+ class Foo:
56
+ def __init__(self):
57
+ def f2(self):
58
+ return self
59
+ self.f2 = f2.__get__(self)
60
+
61
+ import dill, pickletools
62
+ f = Foo()
63
+ f1 = dill.copy(f)
64
+ assert f1.f2() is f1
65
+
66
+
67
+ def test_functions():
68
+ dumped_func_a = dill.dumps(function_a)
69
+ assert dill.loads(dumped_func_a)(0) == 0
70
+
71
+ dumped_func_b = dill.dumps(function_b)
72
+ assert dill.loads(dumped_func_b)(1,2) == 3
73
+
74
+ dumped_func_c = dill.dumps(function_c)
75
+ assert dill.loads(dumped_func_c)(1) == 2
76
+ assert dill.loads(dumped_func_c)(1, 2) == 3
77
+
78
+ dumped_func_d = dill.dumps(function_d)
79
+ assert dill.loads(dumped_func_d).__doc__ == function_d.__doc__
80
+ assert dill.loads(dumped_func_d).__module__ == function_d.__module__
81
+ assert dill.loads(dumped_func_d)(1, 2) == 4
82
+ assert dill.loads(dumped_func_d)(1, 2, 3) == 6
83
+ assert dill.loads(dumped_func_d)(1, 2, d2=3) == 6
84
+
85
+ function_with_cache(1)
86
+ globalvar = 0
87
+ dumped_func_cache = dill.dumps(function_with_cache)
88
+ assert function_with_cache(2) == 3
89
+ assert function_with_cache(1) == 1
90
+ assert function_with_cache(3) == 6
91
+ assert function_with_cache(2) == 3
92
+
93
+ empty_cell = function_with_unassigned_variable()
94
+ cell_copy = dill.loads(dill.dumps(empty_cell))
95
+ assert 'empty' in str(cell_copy.__closure__[0])
96
+ try:
97
+ cell_copy()
98
+ except Exception:
99
+ # this is good
100
+ pass
101
+ else:
102
+ raise AssertionError('cell_copy() did not read an empty cell')
103
+
104
+ exec('''
105
+ dumped_func_e = dill.dumps(function_e)
106
+ assert dill.loads(dumped_func_e)(1, 2) == 6
107
+ assert dill.loads(dumped_func_e)(1, 2, 3) == 9
108
+ assert dill.loads(dumped_func_e)(1, 2, e2=3) == 8
109
+ assert dill.loads(dumped_func_e)(1, 2, e2=3, e3=4) == 10
110
+ assert dill.loads(dumped_func_e)(1, 2, 3, e2=4) == 12
111
+ assert dill.loads(dumped_func_e)(1, 2, 3, e2=4, e3=5) == 15''')
112
+
113
+ def test_code_object():
114
+ import warnings
115
+ from dill._dill import ALL_CODE_PARAMS, CODE_PARAMS, CODE_VERSION, _create_code
116
+ code = function_c.__code__
117
+ warnings.filterwarnings('ignore', category=DeprecationWarning) # issue 597
118
+ LNOTAB = getattr(code, 'co_lnotab', b'')
119
+ if warnings.filters: del warnings.filters[0]
120
+ fields = {f: getattr(code, 'co_'+f) for f in CODE_PARAMS}
121
+ fields.setdefault('posonlyargcount', 0) # python >= 3.8
122
+ fields.setdefault('lnotab', LNOTAB) # python <= 3.9
123
+ fields.setdefault('linetable', b'') # python >= 3.10
124
+ fields.setdefault('qualname', fields['name']) # python >= 3.11
125
+ fields.setdefault('exceptiontable', b'') # python >= 3.11
126
+ fields.setdefault('endlinetable', None) # python == 3.11a
127
+ fields.setdefault('columntable', None) # python == 3.11a
128
+
129
+ for version, _, params in ALL_CODE_PARAMS:
130
+ args = tuple(fields[p] for p in params.split())
131
+ try:
132
+ _create_code(*args)
133
+ if version >= (3,10):
134
+ _create_code(fields['lnotab'], *args)
135
+ except Exception as error:
136
+ raise Exception("failed to construct code object with format version {}".format(version)) from error
137
+
138
+ if __name__ == '__main__':
139
+ test_functions()
140
+ test_issue_510()
141
+ test_code_object()
.venv/lib/python3.11/site-packages/dill/tests/test_recursive.py ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
4
+ # Copyright (c) 2019-2024 The Uncertainty Quantification Foundation.
5
+ # License: 3-clause BSD. The full license text is available at:
6
+ # - https://github.com/uqfoundation/dill/blob/master/LICENSE
7
+
8
+ import dill
9
+ from functools import partial
10
+ import warnings
11
+
12
+
13
+ def copy(obj, byref=False, recurse=False):
14
+ if byref:
15
+ try:
16
+ return dill.copy(obj, byref=byref, recurse=recurse)
17
+ except Exception:
18
+ pass
19
+ else:
20
+ raise AssertionError('Copy of %s with byref=True should have given a warning!' % (obj,))
21
+
22
+ warnings.simplefilter('ignore')
23
+ val = dill.copy(obj, byref=byref, recurse=recurse)
24
+ warnings.simplefilter('error')
25
+ return val
26
+ else:
27
+ return dill.copy(obj, byref=byref, recurse=recurse)
28
+
29
+
30
+ class obj1(object):
31
+ def __init__(self):
32
+ super(obj1, self).__init__()
33
+
34
+ class obj2(object):
35
+ def __init__(self):
36
+ super(obj2, self).__init__()
37
+
38
+ class obj3(object):
39
+ super_ = super
40
+ def __init__(self):
41
+ obj3.super_(obj3, self).__init__()
42
+
43
+
44
+ def test_super():
45
+ assert copy(obj1(), byref=True)
46
+ assert copy(obj1(), byref=True, recurse=True)
47
+ assert copy(obj1(), recurse=True)
48
+ assert copy(obj1())
49
+
50
+ assert copy(obj2(), byref=True)
51
+ assert copy(obj2(), byref=True, recurse=True)
52
+ assert copy(obj2(), recurse=True)
53
+ assert copy(obj2())
54
+
55
+ assert copy(obj3(), byref=True)
56
+ assert copy(obj3(), byref=True, recurse=True)
57
+ assert copy(obj3(), recurse=True)
58
+ assert copy(obj3())
59
+
60
+
61
+ def get_trigger(model):
62
+ pass
63
+
64
+ class Machine(object):
65
+ def __init__(self):
66
+ self.child = Model()
67
+ self.trigger = partial(get_trigger, self)
68
+ self.child.trigger = partial(get_trigger, self.child)
69
+
70
+ class Model(object):
71
+ pass
72
+
73
+
74
+
75
+ def test_partial():
76
+ assert copy(Machine(), byref=True)
77
+ assert copy(Machine(), byref=True, recurse=True)
78
+ assert copy(Machine(), recurse=True)
79
+ assert copy(Machine())
80
+
81
+
82
+ class Machine2(object):
83
+ def __init__(self):
84
+ self.go = partial(self.member, self)
85
+ def member(self, model):
86
+ pass
87
+
88
+
89
+ class SubMachine(Machine2):
90
+ def __init__(self):
91
+ super(SubMachine, self).__init__()
92
+
93
+
94
+ def test_partials():
95
+ assert copy(SubMachine(), byref=True)
96
+ assert copy(SubMachine(), byref=True, recurse=True)
97
+ assert copy(SubMachine(), recurse=True)
98
+ assert copy(SubMachine())
99
+
100
+
101
+ class obj4(object):
102
+ def __init__(self):
103
+ super(obj4, self).__init__()
104
+ a = self
105
+ class obj5(object):
106
+ def __init__(self):
107
+ super(obj5, self).__init__()
108
+ self.a = a
109
+ self.b = obj5()
110
+
111
+
112
+ def test_circular_reference():
113
+ assert copy(obj4())
114
+ obj4_copy = dill.loads(dill.dumps(obj4()))
115
+ assert type(obj4_copy) is type(obj4_copy).__init__.__closure__[0].cell_contents
116
+ assert type(obj4_copy.b) is type(obj4_copy.b).__init__.__closure__[0].cell_contents
117
+
118
+
119
+ def f():
120
+ def g():
121
+ return g
122
+ return g
123
+
124
+
125
+ def test_function_cells():
126
+ assert copy(f())
127
+
128
+
129
+ def fib(n):
130
+ assert n >= 0
131
+ if n <= 1:
132
+ return n
133
+ else:
134
+ return fib(n-1) + fib(n-2)
135
+
136
+
137
+ def test_recursive_function():
138
+ global fib
139
+ fib2 = copy(fib, recurse=True)
140
+ fib3 = copy(fib)
141
+ fib4 = fib
142
+ del fib
143
+ assert fib2(5) == 5
144
+ for _fib in (fib3, fib4):
145
+ try:
146
+ _fib(5)
147
+ except Exception:
148
+ # This is expected to fail because fib no longer exists
149
+ pass
150
+ else:
151
+ raise AssertionError("Function fib shouldn't have been found")
152
+ fib = fib4
153
+
154
+
155
+ def collection_function_recursion():
156
+ d = {}
157
+ def g():
158
+ return d
159
+ d['g'] = g
160
+ return g
161
+
162
+
163
+ def test_collection_function_recursion():
164
+ g = copy(collection_function_recursion())
165
+ assert g()['g'] is g
166
+
167
+
168
+ if __name__ == '__main__':
169
+ with warnings.catch_warnings():
170
+ warnings.simplefilter('error')
171
+ test_super()
172
+ test_partial()
173
+ test_partials()
174
+ test_circular_reference()
175
+ test_function_cells()
176
+ test_recursive_function()
177
+ test_collection_function_recursion()
.venv/lib/python3.11/site-packages/dill/tests/test_restricted.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # Author: Kirill Makhonin (@kirillmakhonin)
4
+ # Copyright (c) 2008-2016 California Institute of Technology.
5
+ # Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
6
+ # License: 3-clause BSD. The full license text is available at:
7
+ # - https://github.com/uqfoundation/dill/blob/master/LICENSE
8
+
9
+ import dill
10
+
11
+ class RestrictedType:
12
+ def __bool__(*args, **kwargs):
13
+ raise Exception('Restricted function')
14
+
15
+ __eq__ = __lt__ = __le__ = __ne__ = __gt__ = __ge__ = __hash__ = __bool__
16
+
17
+ glob_obj = RestrictedType()
18
+
19
+ def restricted_func():
20
+ a = glob_obj
21
+
22
+ def test_function_with_restricted_object():
23
+ deserialized = dill.loads(dill.dumps(restricted_func, recurse=True))
24
+
25
+
26
+ if __name__ == '__main__':
27
+ test_function_with_restricted_object()
.venv/lib/python3.11/site-packages/dill/tests/test_selected.py ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
4
+ # Copyright (c) 2008-2016 California Institute of Technology.
5
+ # Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
6
+ # License: 3-clause BSD. The full license text is available at:
7
+ # - https://github.com/uqfoundation/dill/blob/master/LICENSE
8
+ """
9
+ testing some selected object types
10
+ """
11
+
12
+ import dill
13
+ dill.settings['recurse'] = True
14
+
15
+ verbose = False
16
+
17
+ def test_dict_contents():
18
+ c = type.__dict__
19
+ for i,j in c.items():
20
+ #try:
21
+ ok = dill.pickles(j)
22
+ #except Exception:
23
+ # print ("FAIL: %s with %s" % (i, dill.detect.errors(j)))
24
+ if verbose: print ("%s: %s, %s" % (ok, type(j), j))
25
+ assert ok
26
+ if verbose: print ("")
27
+
28
+ def _g(x): yield x;
29
+
30
+ def _f():
31
+ try: raise
32
+ except Exception:
33
+ from sys import exc_info
34
+ e, er, tb = exc_info()
35
+ return er, tb
36
+
37
+ class _d(object):
38
+ def _method(self):
39
+ pass
40
+
41
+ from dill import objects
42
+ from dill import load_types
43
+ load_types(pickleable=True,unpickleable=False)
44
+ _newclass = objects['ClassObjectType']
45
+ # some clean-up #FIXME: should happen internal to dill
46
+ objects['TemporaryFileType'].close()
47
+ objects['TextWrapperType'].close()
48
+ if 'BufferedRandomType' in objects:
49
+ objects['BufferedRandomType'].close()
50
+ objects['BufferedReaderType'].close()
51
+ objects['BufferedWriterType'].close()
52
+ objects['FileType'].close()
53
+ del objects
54
+
55
+ # getset_descriptor for new-style classes (fails on '_method', if not __main__)
56
+ def test_class_descriptors():
57
+ d = _d.__dict__
58
+ for i in d.values():
59
+ ok = dill.pickles(i)
60
+ if verbose: print ("%s: %s, %s" % (ok, type(i), i))
61
+ assert ok
62
+ if verbose: print ("")
63
+ od = _newclass.__dict__
64
+ for i in od.values():
65
+ ok = dill.pickles(i)
66
+ if verbose: print ("%s: %s, %s" % (ok, type(i), i))
67
+ assert ok
68
+ if verbose: print ("")
69
+
70
+ # (__main__) class instance for new-style classes
71
+ def test_class():
72
+ o = _d()
73
+ oo = _newclass()
74
+ ok = dill.pickles(o)
75
+ if verbose: print ("%s: %s, %s" % (ok, type(o), o))
76
+ assert ok
77
+ ok = dill.pickles(oo)
78
+ if verbose: print ("%s: %s, %s" % (ok, type(oo), oo))
79
+ assert ok
80
+ if verbose: print ("")
81
+
82
+ # frames, generators, and tracebacks (all depend on frame)
83
+ def test_frame_related():
84
+ g = _g(1)
85
+ f = g.gi_frame
86
+ e,t = _f()
87
+ _is = lambda ok: ok
88
+ ok = dill.pickles(f)
89
+ if verbose: print ("%s: %s, %s" % (ok, type(f), f))
90
+ assert not ok
91
+ ok = dill.pickles(g)
92
+ if verbose: print ("%s: %s, %s" % (ok, type(g), g))
93
+ assert _is(not ok) #XXX: dill fails
94
+ ok = dill.pickles(t)
95
+ if verbose: print ("%s: %s, %s" % (ok, type(t), t))
96
+ assert not ok #XXX: dill fails
97
+ ok = dill.pickles(e)
98
+ if verbose: print ("%s: %s, %s" % (ok, type(e), e))
99
+ assert ok
100
+ if verbose: print ("")
101
+
102
+ def test_typing():
103
+ import typing
104
+ x = typing.Any
105
+ assert x == dill.copy(x)
106
+ x = typing.Dict[int, str]
107
+ assert x == dill.copy(x)
108
+ x = typing.List[int]
109
+ assert x == dill.copy(x)
110
+ x = typing.Tuple[int, str]
111
+ assert x == dill.copy(x)
112
+ x = typing.Tuple[int]
113
+ assert x == dill.copy(x)
114
+ x = typing.Tuple[()]
115
+ assert x == dill.copy(x)
116
+ x = typing.Tuple[()].copy_with(())
117
+ assert x == dill.copy(x)
118
+ return
119
+
120
+
121
+ if __name__ == '__main__':
122
+ test_frame_related()
123
+ test_dict_contents()
124
+ test_class()
125
+ test_class_descriptors()
126
+ test_typing()
.venv/lib/python3.11/site-packages/dill/tests/test_threads.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
4
+ # Copyright (c) 2024 The Uncertainty Quantification Foundation.
5
+ # License: 3-clause BSD. The full license text is available at:
6
+ # - https://github.com/uqfoundation/dill/blob/master/LICENSE
7
+
8
+ import dill
9
+ dill.settings['recurse'] = True
10
+
11
+
12
+ def test_new_thread():
13
+ import threading
14
+ t = threading.Thread()
15
+ t_ = dill.copy(t)
16
+ assert t.is_alive() == t_.is_alive()
17
+ for i in ['daemon','name','ident','native_id']:
18
+ if hasattr(t, i):
19
+ assert getattr(t, i) == getattr(t_, i)
20
+
21
+ def test_run_thread():
22
+ import threading
23
+ t = threading.Thread()
24
+ t.start()
25
+ t_ = dill.copy(t)
26
+ assert t.is_alive() == t_.is_alive()
27
+ for i in ['daemon','name','ident','native_id']:
28
+ if hasattr(t, i):
29
+ assert getattr(t, i) == getattr(t_, i)
30
+
31
+ def test_join_thread():
32
+ import threading
33
+ t = threading.Thread()
34
+ t.start()
35
+ t.join()
36
+ t_ = dill.copy(t)
37
+ assert t.is_alive() == t_.is_alive()
38
+ for i in ['daemon','name','ident','native_id']:
39
+ if hasattr(t, i):
40
+ assert getattr(t, i) == getattr(t_, i)
41
+
42
+
43
+ if __name__ == '__main__':
44
+ test_new_thread()
45
+ test_run_thread()
46
+ test_join_thread()
.venv/lib/python3.11/site-packages/virtualenv/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (439 Bytes). View file
 
.venv/lib/python3.11/site-packages/virtualenv/__pycache__/__main__.cpython-311.pyc ADDED
Binary file (5.58 kB). View file
 
.venv/lib/python3.11/site-packages/virtualenv/__pycache__/info.cpython-311.pyc ADDED
Binary file (3.6 kB). View file
 
.venv/lib/python3.11/site-packages/virtualenv/__pycache__/report.cpython-311.pyc ADDED
Binary file (2.51 kB). View file
 
.venv/lib/python3.11/site-packages/virtualenv/__pycache__/version.cpython-311.pyc ADDED
Binary file (642 Bytes). View file
 
.venv/lib/python3.11/site-packages/virtualenv/activation/__init__.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from .bash import BashActivator
4
+ from .batch import BatchActivator
5
+ from .cshell import CShellActivator
6
+ from .fish import FishActivator
7
+ from .nushell import NushellActivator
8
+ from .powershell import PowerShellActivator
9
+ from .python import PythonActivator
10
+
11
+ __all__ = [
12
+ "BashActivator",
13
+ "BatchActivator",
14
+ "CShellActivator",
15
+ "FishActivator",
16
+ "NushellActivator",
17
+ "PowerShellActivator",
18
+ "PythonActivator",
19
+ ]
.venv/lib/python3.11/site-packages/virtualenv/activation/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (762 Bytes). View file
 
.venv/lib/python3.11/site-packages/virtualenv/activation/__pycache__/activator.cpython-311.pyc ADDED
Binary file (2.47 kB). View file
 
.venv/lib/python3.11/site-packages/virtualenv/activation/__pycache__/via_template.cpython-311.pyc ADDED
Binary file (4.85 kB). View file
 
.venv/lib/python3.11/site-packages/virtualenv/activation/activator.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ from abc import ABC, abstractmethod
5
+
6
+
7
+ class Activator(ABC):
8
+ """Generates activate script for the virtual environment."""
9
+
10
+ def __init__(self, options) -> None:
11
+ """
12
+ Create a new activator generator.
13
+
14
+ :param options: the parsed options as defined within :meth:`add_parser_arguments`
15
+ """
16
+ self.flag_prompt = os.path.basename(os.getcwd()) if options.prompt == "." else options.prompt
17
+
18
+ @classmethod
19
+ def supports(cls, interpreter): # noqa: ARG003
20
+ """
21
+ Check if the activation script is supported in the given interpreter.
22
+
23
+ :param interpreter: the interpreter we need to support
24
+ :return: ``True`` if supported, ``False`` otherwise
25
+ """
26
+ return True
27
+
28
+ @classmethod # noqa: B027
29
+ def add_parser_arguments(cls, parser, interpreter):
30
+ """
31
+ Add CLI arguments for this activation script.
32
+
33
+ :param parser: the CLI parser
34
+ :param interpreter: the interpreter this virtual environment is based of
35
+ """
36
+
37
+ @abstractmethod
38
+ def generate(self, creator):
39
+ """
40
+ Generate activate script for the given creator.
41
+
42
+ :param creator: the creator (based of :class:`virtualenv.create.creator.Creator`) we used to create this \
43
+ virtual environment
44
+ """
45
+ raise NotImplementedError
46
+
47
+
48
+ __all__ = [
49
+ "Activator",
50
+ ]
.venv/lib/python3.11/site-packages/virtualenv/activation/bash/__init__.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from pathlib import Path
4
+
5
+ from virtualenv.activation.via_template import ViaTemplateActivator
6
+
7
+
8
+ class BashActivator(ViaTemplateActivator):
9
+ def templates(self):
10
+ yield "activate.sh"
11
+
12
+ def as_name(self, template):
13
+ return Path(template).stem
14
+
15
+
16
+ __all__ = [
17
+ "BashActivator",
18
+ ]
.venv/lib/python3.11/site-packages/virtualenv/activation/bash/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (1.05 kB). View file
 
.venv/lib/python3.11/site-packages/virtualenv/activation/bash/activate.sh ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file must be used with "source bin/activate" *from bash*
2
+ # you cannot run it directly
3
+
4
+
5
+ if [ "${BASH_SOURCE-}" = "$0" ]; then
6
+ echo "You must source this script: \$ source $0" >&2
7
+ exit 33
8
+ fi
9
+
10
+ deactivate () {
11
+ unset -f pydoc >/dev/null 2>&1 || true
12
+
13
+ # reset old environment variables
14
+ # ! [ -z ${VAR+_} ] returns true if VAR is declared at all
15
+ if ! [ -z "${_OLD_VIRTUAL_PATH:+_}" ] ; then
16
+ PATH="$_OLD_VIRTUAL_PATH"
17
+ export PATH
18
+ unset _OLD_VIRTUAL_PATH
19
+ fi
20
+ if ! [ -z "${_OLD_VIRTUAL_PYTHONHOME+_}" ] ; then
21
+ PYTHONHOME="$_OLD_VIRTUAL_PYTHONHOME"
22
+ export PYTHONHOME
23
+ unset _OLD_VIRTUAL_PYTHONHOME
24
+ fi
25
+
26
+ # The hash command must be called to get it to forget past
27
+ # commands. Without forgetting past commands the $PATH changes
28
+ # we made may not be respected
29
+ hash -r 2>/dev/null
30
+
31
+ if ! [ -z "${_OLD_VIRTUAL_PS1+_}" ] ; then
32
+ PS1="$_OLD_VIRTUAL_PS1"
33
+ export PS1
34
+ unset _OLD_VIRTUAL_PS1
35
+ fi
36
+
37
+ unset VIRTUAL_ENV
38
+ unset VIRTUAL_ENV_PROMPT
39
+ if [ ! "${1-}" = "nondestructive" ] ; then
40
+ # Self destruct!
41
+ unset -f deactivate
42
+ fi
43
+ }
44
+
45
+ # unset irrelevant variables
46
+ deactivate nondestructive
47
+
48
+ VIRTUAL_ENV=__VIRTUAL_ENV__
49
+ if ([ "$OSTYPE" = "cygwin" ] || [ "$OSTYPE" = "msys" ]) && $(command -v cygpath &> /dev/null) ; then
50
+ VIRTUAL_ENV=$(cygpath -u "$VIRTUAL_ENV")
51
+ fi
52
+ export VIRTUAL_ENV
53
+
54
+ _OLD_VIRTUAL_PATH="$PATH"
55
+ PATH="$VIRTUAL_ENV/"__BIN_NAME__":$PATH"
56
+ export PATH
57
+
58
+ if [ "x"__VIRTUAL_PROMPT__ != x ] ; then
59
+ VIRTUAL_ENV_PROMPT=__VIRTUAL_PROMPT__
60
+ else
61
+ VIRTUAL_ENV_PROMPT=$(basename "$VIRTUAL_ENV")
62
+ fi
63
+ export VIRTUAL_ENV_PROMPT
64
+
65
+ # unset PYTHONHOME if set
66
+ if ! [ -z "${PYTHONHOME+_}" ] ; then
67
+ _OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME"
68
+ unset PYTHONHOME
69
+ fi
70
+
71
+ if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" ] ; then
72
+ _OLD_VIRTUAL_PS1="${PS1-}"
73
+ PS1="(${VIRTUAL_ENV_PROMPT}) ${PS1-}"
74
+ export PS1
75
+ fi
76
+
77
+ # Make sure to unalias pydoc if it's already there
78
+ alias pydoc 2>/dev/null >/dev/null && unalias pydoc || true
79
+
80
+ pydoc () {
81
+ python -m pydoc "$@"
82
+ }
83
+
84
+ # The hash command must be called to get it to forget past
85
+ # commands. Without forgetting past commands the $PATH changes
86
+ # we made may not be respected
87
+ hash -r 2>/dev/null || true
.venv/lib/python3.11/site-packages/virtualenv/activation/batch/__init__.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import os
4
+
5
+ from virtualenv.activation.via_template import ViaTemplateActivator
6
+
7
+
8
+ class BatchActivator(ViaTemplateActivator):
9
+ @classmethod
10
+ def supports(cls, interpreter):
11
+ return interpreter.os == "nt"
12
+
13
+ def templates(self):
14
+ yield "activate.bat"
15
+ yield "deactivate.bat"
16
+ yield "pydoc.bat"
17
+
18
+ @staticmethod
19
+ def quote(string):
20
+ return string
21
+
22
+ def instantiate_template(self, replacements, template, creator):
23
+ # ensure the text has all newlines as \r\n - required by batch
24
+ base = super().instantiate_template(replacements, template, creator)
25
+ return base.replace(os.linesep, "\n").replace("\n", os.linesep)
26
+
27
+
28
+ __all__ = [
29
+ "BatchActivator",
30
+ ]
.venv/lib/python3.11/site-packages/virtualenv/activation/batch/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (1.87 kB). View file
 
.venv/lib/python3.11/site-packages/virtualenv/activation/batch/activate.bat ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @REM This file is UTF-8 encoded, so we need to update the current code page while executing it
2
+ @for /f "tokens=2 delims=:." %%a in ('"%SystemRoot%\System32\chcp.com"') do @set _OLD_CODEPAGE=%%a
3
+
4
+ @if defined _OLD_CODEPAGE (
5
+ "%SystemRoot%\System32\chcp.com" 65001 > nul
6
+ )
7
+
8
+ @set "VIRTUAL_ENV=__VIRTUAL_ENV__"
9
+
10
+ @set "VIRTUAL_ENV_PROMPT=__VIRTUAL_PROMPT__"
11
+ @if NOT DEFINED VIRTUAL_ENV_PROMPT (
12
+ @for %%d in ("%VIRTUAL_ENV%") do @set "VIRTUAL_ENV_PROMPT=%%~nxd"
13
+ )
14
+
15
+ @if defined _OLD_VIRTUAL_PROMPT (
16
+ @set "PROMPT=%_OLD_VIRTUAL_PROMPT%"
17
+ ) else (
18
+ @if not defined PROMPT (
19
+ @set "PROMPT=$P$G"
20
+ )
21
+ @if not defined VIRTUAL_ENV_DISABLE_PROMPT (
22
+ @set "_OLD_VIRTUAL_PROMPT=%PROMPT%"
23
+ )
24
+ )
25
+ @if not defined VIRTUAL_ENV_DISABLE_PROMPT (
26
+ @set "PROMPT=(%VIRTUAL_ENV_PROMPT%) %PROMPT%"
27
+ )
28
+
29
+ @REM Don't use () to avoid problems with them in %PATH%
30
+ @if defined _OLD_VIRTUAL_PYTHONHOME @goto ENDIFVHOME
31
+ @set "_OLD_VIRTUAL_PYTHONHOME=%PYTHONHOME%"
32
+ :ENDIFVHOME
33
+
34
+ @set PYTHONHOME=
35
+
36
+ @REM if defined _OLD_VIRTUAL_PATH (
37
+ @if not defined _OLD_VIRTUAL_PATH @goto ENDIFVPATH1
38
+ @set "PATH=%_OLD_VIRTUAL_PATH%"
39
+ :ENDIFVPATH1
40
+ @REM ) else (
41
+ @if defined _OLD_VIRTUAL_PATH @goto ENDIFVPATH2
42
+ @set "_OLD_VIRTUAL_PATH=%PATH%"
43
+ :ENDIFVPATH2
44
+
45
+ @set "PATH=%VIRTUAL_ENV%\__BIN_NAME__;%PATH%"
46
+
47
+ @if defined _OLD_CODEPAGE (
48
+ "%SystemRoot%\System32\chcp.com" %_OLD_CODEPAGE% > nul
49
+ @set _OLD_CODEPAGE=
50
+ )
.venv/lib/python3.11/site-packages/virtualenv/activation/batch/deactivate.bat ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @set VIRTUAL_ENV=
2
+ @set VIRTUAL_ENV_PROMPT=
3
+
4
+ @REM Don't use () to avoid problems with them in %PATH%
5
+ @if not defined _OLD_VIRTUAL_PROMPT @goto ENDIFVPROMPT
6
+ @set "PROMPT=%_OLD_VIRTUAL_PROMPT%"
7
+ @set _OLD_VIRTUAL_PROMPT=
8
+ :ENDIFVPROMPT
9
+
10
+ @if not defined _OLD_VIRTUAL_PYTHONHOME @goto ENDIFVHOME
11
+ @set "PYTHONHOME=%_OLD_VIRTUAL_PYTHONHOME%"
12
+ @set _OLD_VIRTUAL_PYTHONHOME=
13
+ :ENDIFVHOME
14
+
15
+ @if not defined _OLD_VIRTUAL_PATH @goto ENDIFVPATH
16
+ @set "PATH=%_OLD_VIRTUAL_PATH%"
17
+ @set _OLD_VIRTUAL_PATH=
18
+ :ENDIFVPATH
.venv/lib/python3.11/site-packages/virtualenv/activation/batch/pydoc.bat ADDED
@@ -0,0 +1 @@
 
 
1
+ python.exe -m pydoc %*
.venv/lib/python3.11/site-packages/virtualenv/activation/cshell/__init__.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from virtualenv.activation.via_template import ViaTemplateActivator
4
+
5
+
6
+ class CShellActivator(ViaTemplateActivator):
7
+ @classmethod
8
+ def supports(cls, interpreter):
9
+ return interpreter.os != "nt"
10
+
11
+ def templates(self):
12
+ yield "activate.csh"
13
+
14
+
15
+ __all__ = [
16
+ "CShellActivator",
17
+ ]
.venv/lib/python3.11/site-packages/virtualenv/activation/cshell/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (1.03 kB). View file
 
.venv/lib/python3.11/site-packages/virtualenv/activation/cshell/activate.csh ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file must be used with "source bin/activate.csh" *from csh*.
2
+ # You cannot run it directly.
3
+ # Created by Davide Di Blasi <davidedb@gmail.com>.
4
+
5
+ set newline='\
6
+ '
7
+
8
+ alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH:q" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT:q" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; unsetenv VIRTUAL_ENV_PROMPT; test "\!:*" != "nondestructive" && unalias deactivate && unalias pydoc'
9
+
10
+ # Unset irrelevant variables.
11
+ deactivate nondestructive
12
+
13
+ setenv VIRTUAL_ENV __VIRTUAL_ENV__
14
+
15
+ set _OLD_VIRTUAL_PATH="$PATH:q"
16
+ setenv PATH "$VIRTUAL_ENV:q/"__BIN_NAME__":$PATH:q"
17
+
18
+
19
+
20
+ if (__VIRTUAL_PROMPT__ != "") then
21
+ setenv VIRTUAL_ENV_PROMPT __VIRTUAL_PROMPT__
22
+ else
23
+ setenv VIRTUAL_ENV_PROMPT "$VIRTUAL_ENV:t:q"
24
+ endif
25
+
26
+ if ( $?VIRTUAL_ENV_DISABLE_PROMPT ) then
27
+ if ( $VIRTUAL_ENV_DISABLE_PROMPT == "" ) then
28
+ set do_prompt = "1"
29
+ else
30
+ set do_prompt = "0"
31
+ endif
32
+ else
33
+ set do_prompt = "1"
34
+ endif
35
+
36
+ if ( $do_prompt == "1" ) then
37
+ # Could be in a non-interactive environment,
38
+ # in which case, $prompt is undefined and we wouldn't
39
+ # care about the prompt anyway.
40
+ if ( $?prompt ) then
41
+ set _OLD_VIRTUAL_PROMPT="$prompt:q"
42
+ if ( "$prompt:q" =~ *"$newline:q"* ) then
43
+ :
44
+ else
45
+ set prompt = '('"$VIRTUAL_ENV_PROMPT:q"') '"$prompt:q"
46
+ endif
47
+ endif
48
+ endif
49
+
50
+ unset env_name
51
+ unset do_prompt
52
+
53
+ alias pydoc python -m pydoc
54
+
55
+ rehash
.venv/lib/python3.11/site-packages/virtualenv/activation/fish/__init__.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from virtualenv.activation.via_template import ViaTemplateActivator
4
+
5
+
6
+ class FishActivator(ViaTemplateActivator):
7
+ def templates(self):
8
+ yield "activate.fish"
9
+
10
+
11
+ __all__ = [
12
+ "FishActivator",
13
+ ]
.venv/lib/python3.11/site-packages/virtualenv/activation/fish/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (801 Bytes). View file
 
.venv/lib/python3.11/site-packages/virtualenv/activation/fish/activate.fish ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file must be used using `source bin/activate.fish` *within a running fish ( http://fishshell.com ) session*.
2
+ # Do not run it directly.
3
+
4
+ function _bashify_path -d "Converts a fish path to something bash can recognize"
5
+ set fishy_path $argv
6
+ set bashy_path $fishy_path[1]
7
+ for path_part in $fishy_path[2..-1]
8
+ set bashy_path "$bashy_path:$path_part"
9
+ end
10
+ echo $bashy_path
11
+ end
12
+
13
+ function _fishify_path -d "Converts a bash path to something fish can recognize"
14
+ echo $argv | tr ':' '\n'
15
+ end
16
+
17
+ function deactivate -d 'Exit virtualenv mode and return to the normal environment.'
18
+ # reset old environment variables
19
+ if test -n "$_OLD_VIRTUAL_PATH"
20
+ # https://github.com/fish-shell/fish-shell/issues/436 altered PATH handling
21
+ if test (echo $FISH_VERSION | head -c 1) -lt 3
22
+ set -gx PATH (_fishify_path "$_OLD_VIRTUAL_PATH")
23
+ else
24
+ set -gx PATH $_OLD_VIRTUAL_PATH
25
+ end
26
+ set -e _OLD_VIRTUAL_PATH
27
+ end
28
+
29
+ if test -n "$_OLD_VIRTUAL_PYTHONHOME"
30
+ set -gx PYTHONHOME "$_OLD_VIRTUAL_PYTHONHOME"
31
+ set -e _OLD_VIRTUAL_PYTHONHOME
32
+ end
33
+
34
+ if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
35
+ and functions -q _old_fish_prompt
36
+ # Set an empty local `$fish_function_path` to allow the removal of `fish_prompt` using `functions -e`.
37
+ set -l fish_function_path
38
+
39
+ # Erase virtualenv's `fish_prompt` and restore the original.
40
+ functions -e fish_prompt
41
+ functions -c _old_fish_prompt fish_prompt
42
+ functions -e _old_fish_prompt
43
+ set -e _OLD_FISH_PROMPT_OVERRIDE
44
+ end
45
+
46
+ set -e VIRTUAL_ENV
47
+ set -e VIRTUAL_ENV_PROMPT
48
+
49
+ if test "$argv[1]" != 'nondestructive'
50
+ # Self-destruct!
51
+ functions -e pydoc
52
+ functions -e deactivate
53
+ functions -e _bashify_path
54
+ functions -e _fishify_path
55
+ end
56
+ end
57
+
58
+ # Unset irrelevant variables.
59
+ deactivate nondestructive
60
+
61
+ set -gx VIRTUAL_ENV __VIRTUAL_ENV__
62
+
63
+ # https://github.com/fish-shell/fish-shell/issues/436 altered PATH handling
64
+ if test (echo $FISH_VERSION | head -c 1) -lt 3
65
+ set -gx _OLD_VIRTUAL_PATH (_bashify_path $PATH)
66
+ else
67
+ set -gx _OLD_VIRTUAL_PATH $PATH
68
+ end
69
+ set -gx PATH "$VIRTUAL_ENV"'/'__BIN_NAME__ $PATH
70
+
71
+ # Prompt override provided?
72
+ # If not, just use the environment name.
73
+ if test -n __VIRTUAL_PROMPT__
74
+ set -gx VIRTUAL_ENV_PROMPT __VIRTUAL_PROMPT__
75
+ else
76
+ set -gx VIRTUAL_ENV_PROMPT (basename "$VIRTUAL_ENV")
77
+ end
78
+
79
+ # Unset `$PYTHONHOME` if set.
80
+ if set -q PYTHONHOME
81
+ set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
82
+ set -e PYTHONHOME
83
+ end
84
+
85
+ function pydoc
86
+ python -m pydoc $argv
87
+ end
88
+
89
+ if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
90
+ # Copy the current `fish_prompt` function as `_old_fish_prompt`.
91
+ functions -c fish_prompt _old_fish_prompt
92
+
93
+ function fish_prompt
94
+ # Run the user's prompt first; it might depend on (pipe)status.
95
+ set -l prompt (_old_fish_prompt)
96
+
97
+ printf '(%s) ' $VIRTUAL_ENV_PROMPT
98
+
99
+ string join -- \n $prompt # handle multi-line prompts
100
+ end
101
+
102
+ set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
103
+ end
.venv/lib/python3.11/site-packages/virtualenv/activation/nushell/__init__.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from virtualenv.activation.via_template import ViaTemplateActivator
4
+
5
+
6
+ class NushellActivator(ViaTemplateActivator):
7
+ def templates(self):
8
+ yield "activate.nu"
9
+
10
+ @staticmethod
11
+ def quote(string):
12
+ """
13
+ Nushell supports raw strings like: r###'this is a string'###.
14
+
15
+ This method finds the maximum continuous sharps in the string and then
16
+ quote it with an extra sharp.
17
+ """
18
+ max_sharps = 0
19
+ current_sharps = 0
20
+ for char in string:
21
+ if char == "#":
22
+ current_sharps += 1
23
+ max_sharps = max(current_sharps, max_sharps)
24
+ else:
25
+ current_sharps = 0
26
+ wrapping = "#" * (max_sharps + 1)
27
+ return f"r{wrapping}'{string}'{wrapping}"
28
+
29
+ def replacements(self, creator, dest_folder): # noqa: ARG002
30
+ return {
31
+ "__VIRTUAL_PROMPT__": "" if self.flag_prompt is None else self.flag_prompt,
32
+ "__VIRTUAL_ENV__": str(creator.dest),
33
+ "__VIRTUAL_NAME__": creator.env_name,
34
+ "__BIN_NAME__": str(creator.bin_dir.relative_to(creator.dest)),
35
+ }
36
+
37
+
38
+ __all__ = [
39
+ "NushellActivator",
40
+ ]
.venv/lib/python3.11/site-packages/virtualenv/activation/nushell/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (2.02 kB). View file
 
.venv/lib/python3.11/site-packages/virtualenv/activation/nushell/activate.nu ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # virtualenv activation module
2
+ # Activate with `overlay use activate.nu`
3
+ # Deactivate with `deactivate`, as usual
4
+ #
5
+ # To customize the overlay name, you can call `overlay use activate.nu as foo`,
6
+ # but then simply `deactivate` won't work because it is just an alias to hide
7
+ # the "activate" overlay. You'd need to call `overlay hide foo` manually.
8
+
9
+ export-env {
10
+ def is-string [x] {
11
+ ($x | describe) == 'string'
12
+ }
13
+
14
+ def has-env [...names] {
15
+ $names | each {|n|
16
+ $n in $env
17
+ } | all {|i| $i == true}
18
+ }
19
+
20
+ # Emulates a `test -z`, but better as it handles e.g 'false'
21
+ def is-env-true [name: string] {
22
+ if (has-env $name) {
23
+ # Try to parse 'true', '0', '1', and fail if not convertible
24
+ let parsed = (do -i { $env | get $name | into bool })
25
+ if ($parsed | describe) == 'bool' {
26
+ $parsed
27
+ } else {
28
+ not ($env | get -i $name | is-empty)
29
+ }
30
+ } else {
31
+ false
32
+ }
33
+ }
34
+
35
+ let virtual_env = __VIRTUAL_ENV__
36
+ let bin = __BIN_NAME__
37
+
38
+ let is_windows = ($nu.os-info.family) == 'windows'
39
+ let path_name = (if (has-env 'Path') {
40
+ 'Path'
41
+ } else {
42
+ 'PATH'
43
+ }
44
+ )
45
+
46
+ let venv_path = ([$virtual_env $bin] | path join)
47
+ let new_path = ($env | get $path_name | prepend $venv_path)
48
+
49
+ # If there is no default prompt, then use the env name instead
50
+ let virtual_env_prompt = (if (__VIRTUAL_PROMPT__ | is-empty) {
51
+ ($virtual_env | path basename)
52
+ } else {
53
+ __VIRTUAL_PROMPT__
54
+ })
55
+
56
+ let new_env = {
57
+ $path_name : $new_path
58
+ VIRTUAL_ENV : $virtual_env
59
+ VIRTUAL_ENV_PROMPT : $virtual_env_prompt
60
+ }
61
+
62
+ let new_env = (if (is-env-true 'VIRTUAL_ENV_DISABLE_PROMPT') {
63
+ $new_env
64
+ } else {
65
+ # Creating the new prompt for the session
66
+ let virtual_prefix = $'(char lparen)($virtual_env_prompt)(char rparen) '
67
+
68
+ # Back up the old prompt builder
69
+ let old_prompt_command = (if (has-env 'PROMPT_COMMAND') {
70
+ $env.PROMPT_COMMAND
71
+ } else {
72
+ ''
73
+ })
74
+
75
+ let new_prompt = (if (has-env 'PROMPT_COMMAND') {
76
+ if 'closure' in ($old_prompt_command | describe) {
77
+ {|| $'($virtual_prefix)(do $old_prompt_command)' }
78
+ } else {
79
+ {|| $'($virtual_prefix)($old_prompt_command)' }
80
+ }
81
+ } else {
82
+ {|| $'($virtual_prefix)' }
83
+ })
84
+
85
+ $new_env | merge {
86
+ PROMPT_COMMAND : $new_prompt
87
+ VIRTUAL_PREFIX : $virtual_prefix
88
+ }
89
+ })
90
+
91
+ # Environment variables that will be loaded as the virtual env
92
+ load-env $new_env
93
+ }
94
+
95
+ export alias pydoc = python -m pydoc
96
+ export alias deactivate = overlay hide activate
.venv/lib/python3.11/site-packages/virtualenv/activation/powershell/__init__.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from virtualenv.activation.via_template import ViaTemplateActivator
4
+
5
+
6
+ class PowerShellActivator(ViaTemplateActivator):
7
+ def templates(self):
8
+ yield "activate.ps1"
9
+
10
+ @staticmethod
11
+ def quote(string):
12
+ """
13
+ This should satisfy PowerShell quoting rules [1], unless the quoted
14
+ string is passed directly to Windows native commands [2].
15
+
16
+ [1]: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_quoting_rules
17
+ [2]: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_parsing#passing-arguments-that-contain-quote-characters
18
+ """ # noqa: D205
19
+ string = string.replace("'", "''")
20
+ return f"'{string}'"
21
+
22
+
23
+ __all__ = [
24
+ "PowerShellActivator",
25
+ ]
.venv/lib/python3.11/site-packages/virtualenv/activation/powershell/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (1.53 kB). View file
 
.venv/lib/python3.11/site-packages/virtualenv/activation/powershell/activate.ps1 ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ $script:THIS_PATH = $myinvocation.mycommand.path
2
+ $script:BASE_DIR = Split-Path (Resolve-Path "$THIS_PATH/..") -Parent
3
+
4
+ function global:deactivate([switch] $NonDestructive) {
5
+ if (Test-Path variable:_OLD_VIRTUAL_PATH) {
6
+ $env:PATH = $variable:_OLD_VIRTUAL_PATH
7
+ Remove-Variable "_OLD_VIRTUAL_PATH" -Scope global
8
+ }
9
+
10
+ if (Test-Path function:_old_virtual_prompt) {
11
+ $function:prompt = $function:_old_virtual_prompt
12
+ Remove-Item function:\_old_virtual_prompt
13
+ }
14
+
15
+ if ($env:VIRTUAL_ENV) {
16
+ Remove-Item env:VIRTUAL_ENV -ErrorAction SilentlyContinue
17
+ }
18
+
19
+ if ($env:VIRTUAL_ENV_PROMPT) {
20
+ Remove-Item env:VIRTUAL_ENV_PROMPT -ErrorAction SilentlyContinue
21
+ }
22
+
23
+ if (!$NonDestructive) {
24
+ # Self destruct!
25
+ Remove-Item function:deactivate
26
+ Remove-Item function:pydoc
27
+ }
28
+ }
29
+
30
+ function global:pydoc {
31
+ python -m pydoc $args
32
+ }
33
+
34
+ # unset irrelevant variables
35
+ deactivate -nondestructive
36
+
37
+ $VIRTUAL_ENV = $BASE_DIR
38
+ $env:VIRTUAL_ENV = $VIRTUAL_ENV
39
+
40
+ if (__VIRTUAL_PROMPT__ -ne "") {
41
+ $env:VIRTUAL_ENV_PROMPT = __VIRTUAL_PROMPT__
42
+ }
43
+ else {
44
+ $env:VIRTUAL_ENV_PROMPT = $( Split-Path $env:VIRTUAL_ENV -Leaf )
45
+ }
46
+
47
+ New-Variable -Scope global -Name _OLD_VIRTUAL_PATH -Value $env:PATH
48
+
49
+ $env:PATH = "$env:VIRTUAL_ENV/" + __BIN_NAME__ + __PATH_SEP__ + $env:PATH
50
+ if (!$env:VIRTUAL_ENV_DISABLE_PROMPT) {
51
+ function global:_old_virtual_prompt {
52
+ ""
53
+ }
54
+ $function:_old_virtual_prompt = $function:prompt
55
+
56
+ function global:prompt {
57
+ # Add the custom prefix to the existing prompt
58
+ $previous_prompt_value = & $function:_old_virtual_prompt
59
+ ("(" + $env:VIRTUAL_ENV_PROMPT + ") " + $previous_prompt_value)
60
+ }
61
+ }
.venv/lib/python3.11/site-packages/virtualenv/activation/python/__init__.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ from collections import OrderedDict
5
+
6
+ from virtualenv.activation.via_template import ViaTemplateActivator
7
+
8
+
9
+ class PythonActivator(ViaTemplateActivator):
10
+ def templates(self):
11
+ yield "activate_this.py"
12
+
13
+ @staticmethod
14
+ def quote(string):
15
+ return repr(string)
16
+
17
+ def replacements(self, creator, dest_folder):
18
+ replacements = super().replacements(creator, dest_folder)
19
+ lib_folders = OrderedDict((os.path.relpath(str(i), str(dest_folder)), None) for i in creator.libs)
20
+ lib_folders = os.pathsep.join(lib_folders.keys())
21
+ replacements.update(
22
+ {
23
+ "__LIB_FOLDERS__": lib_folders,
24
+ "__DECODE_PATH__": "",
25
+ },
26
+ )
27
+ return replacements
28
+
29
+
30
+ __all__ = [
31
+ "PythonActivator",
32
+ ]
.venv/lib/python3.11/site-packages/virtualenv/activation/python/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (2.25 kB). View file
 
.venv/lib/python3.11/site-packages/virtualenv/activation/python/__pycache__/activate_this.cpython-311.pyc ADDED
Binary file (2.25 kB). View file
 
.venv/lib/python3.11/site-packages/virtualenv/activation/python/activate_this.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Activate virtualenv for current interpreter:
3
+
4
+ import runpy
5
+ runpy.run_path(this_file)
6
+
7
+ This can be used when you must use an existing Python interpreter, not the virtualenv bin/python.
8
+ """ # noqa: D415
9
+
10
+ from __future__ import annotations
11
+
12
+ import os
13
+ import site
14
+ import sys
15
+
16
+ try:
17
+ abs_file = os.path.abspath(__file__)
18
+ except NameError as exc:
19
+ msg = "You must use import runpy; runpy.run_path(this_file)"
20
+ raise AssertionError(msg) from exc
21
+
22
+ bin_dir = os.path.dirname(abs_file)
23
+ base = bin_dir[: -len(__BIN_NAME__) - 1] # strip away the bin part from the __file__, plus the path separator
24
+
25
+ # prepend bin to PATH (this file is inside the bin directory)
26
+ os.environ["PATH"] = os.pathsep.join([bin_dir, *os.environ.get("PATH", "").split(os.pathsep)])
27
+ os.environ["VIRTUAL_ENV"] = base # virtual env is right above bin directory
28
+ os.environ["VIRTUAL_ENV_PROMPT"] = __VIRTUAL_PROMPT__ or os.path.basename(base)
29
+
30
+ # add the virtual environments libraries to the host python import mechanism
31
+ prev_length = len(sys.path)
32
+ for lib in __LIB_FOLDERS__.split(os.pathsep):
33
+ path = os.path.realpath(os.path.join(bin_dir, lib))
34
+ site.addsitedir(path.decode("utf-8") if __DECODE_PATH__ else path)
35
+ sys.path[:] = sys.path[prev_length:] + sys.path[0:prev_length]
36
+
37
+ sys.real_prefix = sys.prefix
38
+ sys.prefix = base
.venv/lib/python3.11/site-packages/virtualenv/activation/via_template.py ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ import shlex
5
+ import sys
6
+ from abc import ABC, abstractmethod
7
+
8
+ from .activator import Activator
9
+
10
+ if sys.version_info >= (3, 10):
11
+ from importlib.resources import files
12
+
13
+ def read_binary(module_name: str, filename: str) -> bytes:
14
+ return (files(module_name) / filename).read_bytes()
15
+
16
+ else:
17
+ from importlib.resources import read_binary
18
+
19
+
20
+ class ViaTemplateActivator(Activator, ABC):
21
+ @abstractmethod
22
+ def templates(self):
23
+ raise NotImplementedError
24
+
25
+ @staticmethod
26
+ def quote(string):
27
+ """
28
+ Quote strings in the activation script.
29
+
30
+ :param string: the string to quote
31
+ :return: quoted string that works in the activation script
32
+ """
33
+ return shlex.quote(string)
34
+
35
+ def generate(self, creator):
36
+ dest_folder = creator.bin_dir
37
+ replacements = self.replacements(creator, dest_folder)
38
+ generated = self._generate(replacements, self.templates(), dest_folder, creator)
39
+ if self.flag_prompt is not None:
40
+ creator.pyenv_cfg["prompt"] = self.flag_prompt
41
+ return generated
42
+
43
+ def replacements(self, creator, dest_folder): # noqa: ARG002
44
+ return {
45
+ "__VIRTUAL_PROMPT__": "" if self.flag_prompt is None else self.flag_prompt,
46
+ "__VIRTUAL_ENV__": str(creator.dest),
47
+ "__VIRTUAL_NAME__": creator.env_name,
48
+ "__BIN_NAME__": str(creator.bin_dir.relative_to(creator.dest)),
49
+ "__PATH_SEP__": os.pathsep,
50
+ }
51
+
52
+ def _generate(self, replacements, templates, to_folder, creator):
53
+ generated = []
54
+ for template in templates:
55
+ text = self.instantiate_template(replacements, template, creator)
56
+ dest = to_folder / self.as_name(template)
57
+ # remove the file if it already exists - this prevents permission
58
+ # errors when the dest is not writable
59
+ if dest.exists():
60
+ dest.unlink()
61
+ # Powershell assumes Windows 1252 encoding when reading files without BOM
62
+ encoding = "utf-8-sig" if str(template).endswith(".ps1") else "utf-8"
63
+ # use write_bytes to avoid platform specific line normalization (\n -> \r\n)
64
+ dest.write_bytes(text.encode(encoding))
65
+ generated.append(dest)
66
+ return generated
67
+
68
+ def as_name(self, template):
69
+ return template
70
+
71
+ def instantiate_template(self, replacements, template, creator):
72
+ # read content as binary to avoid platform specific line normalization (\n -> \r\n)
73
+ binary = read_binary(self.__module__, template)
74
+ text = binary.decode("utf-8", errors="strict")
75
+ for key, value in replacements.items():
76
+ value_uni = self._repr_unicode(creator, value)
77
+ text = text.replace(key, self.quote(value_uni))
78
+ return text
79
+
80
+ @staticmethod
81
+ def _repr_unicode(creator, value): # noqa: ARG004
82
+ return value # by default, we just let it be unicode
83
+
84
+
85
+ __all__ = [
86
+ "ViaTemplateActivator",
87
+ ]
.venv/lib/python3.11/site-packages/virtualenv/app_data/__init__.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Application data stored by virtualenv."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import logging
6
+ import os
7
+
8
+ from platformdirs import user_data_dir
9
+
10
+ from .na import AppDataDisabled
11
+ from .read_only import ReadOnlyAppData
12
+ from .via_disk_folder import AppDataDiskFolder
13
+ from .via_tempdir import TempAppData
14
+
15
+ LOGGER = logging.getLogger(__name__)
16
+
17
+
18
+ def _default_app_data_dir(env):
19
+ key = "VIRTUALENV_OVERRIDE_APP_DATA"
20
+ if key in env:
21
+ return env[key]
22
+ return user_data_dir(appname="virtualenv", appauthor="pypa")
23
+
24
+
25
+ def make_app_data(folder, **kwargs):
26
+ is_read_only = kwargs.pop("read_only")
27
+ env = kwargs.pop("env")
28
+ if kwargs: # py3+ kwonly
29
+ msg = "unexpected keywords: {}"
30
+ raise TypeError(msg)
31
+
32
+ if folder is None:
33
+ folder = _default_app_data_dir(env)
34
+ folder = os.path.abspath(folder)
35
+
36
+ if is_read_only:
37
+ return ReadOnlyAppData(folder)
38
+
39
+ if not os.path.isdir(folder):
40
+ try:
41
+ os.makedirs(folder)
42
+ LOGGER.debug("created app data folder %s", folder)
43
+ except OSError as exception:
44
+ LOGGER.info("could not create app data folder %s due to %r", folder, exception)
45
+
46
+ if os.access(folder, os.W_OK):
47
+ return AppDataDiskFolder(folder)
48
+ LOGGER.debug("app data folder %s has no write access", folder)
49
+ return TempAppData()
50
+
51
+
52
+ __all__ = (
53
+ "AppDataDisabled",
54
+ "AppDataDiskFolder",
55
+ "ReadOnlyAppData",
56
+ "TempAppData",
57
+ "make_app_data",
58
+ )
.venv/lib/python3.11/site-packages/virtualenv/app_data/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (2.59 kB). View file
 
.venv/lib/python3.11/site-packages/virtualenv/app_data/__pycache__/base.cpython-311.pyc ADDED
Binary file (4.58 kB). View file
 
.venv/lib/python3.11/site-packages/virtualenv/app_data/__pycache__/na.cpython-311.pyc ADDED
Binary file (3.65 kB). View file
 
.venv/lib/python3.11/site-packages/virtualenv/app_data/__pycache__/read_only.cpython-311.pyc ADDED
Binary file (2.75 kB). View file