PyProd 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.
Files changed (108) hide show
  1. pyprod-0.1.0/.github/workflows/test.yml +22 -0
  2. pyprod-0.1.0/.gitignore +174 -0
  3. pyprod-0.1.0/.python-version +1 -0
  4. pyprod-0.1.0/.readthedocs.yaml +20 -0
  5. pyprod-0.1.0/.vscode/settings.json +5 -0
  6. pyprod-0.1.0/.xxx/.Prodfile.py.pyprod/.gitignore +2 -0
  7. pyprod-0.1.0/.xxx/.Prodfile.py.pyprod/bin/Activate.ps1 +248 -0
  8. pyprod-0.1.0/.xxx/.Prodfile.py.pyprod/bin/activate +75 -0
  9. pyprod-0.1.0/.xxx/.Prodfile.py.pyprod/bin/activate.csh +27 -0
  10. pyprod-0.1.0/.xxx/.Prodfile.py.pyprod/bin/activate.fish +69 -0
  11. pyprod-0.1.0/.xxx/.Prodfile.py.pyprod/bin/jp.py +54 -0
  12. pyprod-0.1.0/.xxx/.Prodfile.py.pyprod/bin/pip +8 -0
  13. pyprod-0.1.0/.xxx/.Prodfile.py.pyprod/bin/pip3 +8 -0
  14. pyprod-0.1.0/.xxx/.Prodfile.py.pyprod/bin/pip3.13 +8 -0
  15. pyprod-0.1.0/.xxx/.Prodfile.py.pyprod/bin/python +1 -0
  16. pyprod-0.1.0/.xxx/.Prodfile.py.pyprod/bin/python3 +1 -0
  17. pyprod-0.1.0/.xxx/.Prodfile.py.pyprod/bin/python3.13 +1 -0
  18. pyprod-0.1.0/.xxx/.Prodfile.py.pyprod/pyvenv.cfg +5 -0
  19. pyprod-0.1.0/.xxx/Prodfile.py +11 -0
  20. pyprod-0.1.0/.xxx/data.txt +1 -0
  21. pyprod-0.1.0/.xxx/output/hello.txt +1 -0
  22. pyprod-0.1.0/LICENSE +21 -0
  23. pyprod-0.1.0/PKG-INFO +76 -0
  24. pyprod-0.1.0/README.rst +60 -0
  25. pyprod-0.1.0/docs/Makefile +20 -0
  26. pyprod-0.1.0/docs/commandline.rst +20 -0
  27. pyprod-0.1.0/docs/conf.py +35 -0
  28. pyprod-0.1.0/docs/index.rst +40 -0
  29. pyprod-0.1.0/docs/make.bat +35 -0
  30. pyprod-0.1.0/docs/prodfile.rst +307 -0
  31. pyprod-0.1.0/docs/pyprod2.png +0 -0
  32. pyprod-0.1.0/docs/quickstart.rst +78 -0
  33. pyprod-0.1.0/docs/requirements.txt +1 -0
  34. pyprod-0.1.0/pyprod.webp +0 -0
  35. pyprod-0.1.0/pyprod2.png +0 -0
  36. pyprod-0.1.0/pyproject.toml +43 -0
  37. pyprod-0.1.0/sample/build-c/.gitignore +2 -0
  38. pyprod-0.1.0/sample/build-c/Makefile +15 -0
  39. pyprod-0.1.0/sample/build-c/Prodfile.py +26 -0
  40. pyprod-0.1.0/sample/build-c/hello.c +7 -0
  41. pyprod-0.1.0/sample/build-c/hello.h +3 -0
  42. pyprod-0.1.0/sample/build-c/main.c +7 -0
  43. pyprod-0.1.0/sample/generate-doc/.PRODFILE.py.pyprod/bin/Activate.ps1 +247 -0
  44. pyprod-0.1.0/sample/generate-doc/.PRODFILE.py.pyprod/bin/activate +70 -0
  45. pyprod-0.1.0/sample/generate-doc/.PRODFILE.py.pyprod/bin/activate.csh +27 -0
  46. pyprod-0.1.0/sample/generate-doc/.PRODFILE.py.pyprod/bin/activate.fish +69 -0
  47. pyprod-0.1.0/sample/generate-doc/.PRODFILE.py.pyprod/bin/normalizer +8 -0
  48. pyprod-0.1.0/sample/generate-doc/.PRODFILE.py.pyprod/bin/pip +8 -0
  49. pyprod-0.1.0/sample/generate-doc/.PRODFILE.py.pyprod/bin/pip3 +8 -0
  50. pyprod-0.1.0/sample/generate-doc/.PRODFILE.py.pyprod/bin/pip3.12 +8 -0
  51. pyprod-0.1.0/sample/generate-doc/.PRODFILE.py.pyprod/bin/python +1 -0
  52. pyprod-0.1.0/sample/generate-doc/.PRODFILE.py.pyprod/bin/python3 +1 -0
  53. pyprod-0.1.0/sample/generate-doc/.PRODFILE.py.pyprod/bin/python3.12 +1 -0
  54. pyprod-0.1.0/sample/generate-doc/.PRODFILE.py.pyprod/pyvenv.cfg +5 -0
  55. pyprod-0.1.0/sample/generate-doc/.gitignore +2 -0
  56. pyprod-0.1.0/sample/generate-doc/Prodfile.py +30 -0
  57. pyprod-0.1.0/sample/generate-doc/a.txt +1 -0
  58. pyprod-0.1.0/sample/generate-doc/b.txt +1 -0
  59. pyprod-0.1.0/sample/generate-doc/c.txt +1 -0
  60. pyprod-0.1.0/sample/generate-doc/inc1.txt +0 -0
  61. pyprod-0.1.0/sample/generate-doc/inc2.txt +0 -0
  62. pyprod-0.1.0/sample/md-to-pdf/.Prodfile.py.pyprod/.gitignore +2 -0
  63. pyprod-0.1.0/sample/md-to-pdf/.Prodfile.py.pyprod/bin/Activate.ps1 +248 -0
  64. pyprod-0.1.0/sample/md-to-pdf/.Prodfile.py.pyprod/bin/activate +75 -0
  65. pyprod-0.1.0/sample/md-to-pdf/.Prodfile.py.pyprod/bin/activate.csh +27 -0
  66. pyprod-0.1.0/sample/md-to-pdf/.Prodfile.py.pyprod/bin/activate.fish +69 -0
  67. pyprod-0.1.0/sample/md-to-pdf/.Prodfile.py.pyprod/bin/pip +8 -0
  68. pyprod-0.1.0/sample/md-to-pdf/.Prodfile.py.pyprod/bin/pip3 +8 -0
  69. pyprod-0.1.0/sample/md-to-pdf/.Prodfile.py.pyprod/bin/pip3.13 +8 -0
  70. pyprod-0.1.0/sample/md-to-pdf/.Prodfile.py.pyprod/bin/pygmentize +8 -0
  71. pyprod-0.1.0/sample/md-to-pdf/.Prodfile.py.pyprod/bin/python +1 -0
  72. pyprod-0.1.0/sample/md-to-pdf/.Prodfile.py.pyprod/bin/python3 +1 -0
  73. pyprod-0.1.0/sample/md-to-pdf/.Prodfile.py.pyprod/bin/python3.13 +1 -0
  74. pyprod-0.1.0/sample/md-to-pdf/.Prodfile.py.pyprod/pyvenv.cfg +5 -0
  75. pyprod-0.1.0/sample/md-to-pdf/.build/doc.html +28 -0
  76. pyprod-0.1.0/sample/md-to-pdf/.gitignore +1 -0
  77. pyprod-0.1.0/sample/md-to-pdf/Prodfile.py +48 -0
  78. pyprod-0.1.0/sample/md-to-pdf/doc.md +24 -0
  79. pyprod-0.1.0/sample/md-to-pdf/doc.pdf +0 -0
  80. pyprod-0.1.0/sample/md-to-pdf/md_to_html.py +24 -0
  81. pyprod-0.1.0/sample/md-to-pdf/template.html +12 -0
  82. pyprod-0.1.0/sample/s3files/.PRODFILE.py.pyprod/.gitignore +2 -0
  83. pyprod-0.1.0/sample/s3files/.PRODFILE.py.pyprod/bin/Activate.ps1 +248 -0
  84. pyprod-0.1.0/sample/s3files/.PRODFILE.py.pyprod/bin/activate +75 -0
  85. pyprod-0.1.0/sample/s3files/.PRODFILE.py.pyprod/bin/activate.csh +27 -0
  86. pyprod-0.1.0/sample/s3files/.PRODFILE.py.pyprod/bin/activate.fish +69 -0
  87. pyprod-0.1.0/sample/s3files/.PRODFILE.py.pyprod/bin/jp.py +54 -0
  88. pyprod-0.1.0/sample/s3files/.PRODFILE.py.pyprod/bin/pip +8 -0
  89. pyprod-0.1.0/sample/s3files/.PRODFILE.py.pyprod/bin/pip3 +8 -0
  90. pyprod-0.1.0/sample/s3files/.PRODFILE.py.pyprod/bin/pip3.13 +8 -0
  91. pyprod-0.1.0/sample/s3files/.PRODFILE.py.pyprod/bin/python +1 -0
  92. pyprod-0.1.0/sample/s3files/.PRODFILE.py.pyprod/bin/python3 +1 -0
  93. pyprod-0.1.0/sample/s3files/.PRODFILE.py.pyprod/bin/python3.13 +1 -0
  94. pyprod-0.1.0/sample/s3files/.PRODFILE.py.pyprod/pyvenv.cfg +5 -0
  95. pyprod-0.1.0/sample/s3files/Prodfile.py +50 -0
  96. pyprod-0.1.0/sample/s3files/S3TEST.txt +1 -0
  97. pyprod-0.1.0/src/pyprod/__init__.py +0 -0
  98. pyprod-0.1.0/src/pyprod/__main__.py +4 -0
  99. pyprod-0.1.0/src/pyprod/main.py +118 -0
  100. pyprod-0.1.0/src/pyprod/prod.py +532 -0
  101. pyprod-0.1.0/src/pyprod/utils.py +17 -0
  102. pyprod-0.1.0/src/pyprod/venv.py +47 -0
  103. pyprod-0.1.0/tests/__init__.py +0 -0
  104. pyprod-0.1.0/tests/conftest.py +3 -0
  105. pyprod-0.1.0/tests/test_prod.py +217 -0
  106. pyprod-0.1.0/tests/test_prodfuncs.py +49 -0
  107. pyprod-0.1.0/tests/test_rule.py +110 -0
  108. pyprod-0.1.0/uv.lock +723 -0
@@ -0,0 +1,22 @@
1
+ name: Python application
2
+
3
+ on:
4
+ push:
5
+ branches: ["main"]
6
+ pull_request:
7
+ branches: ["main"]
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - name: Checkout repository
15
+ uses: actions/checkout@v4
16
+
17
+ - name: Install uv
18
+ uses: astral-sh/setup-uv@v5
19
+
20
+ - name: Run tests
21
+ run: |
22
+ uv run pytest tests
@@ -0,0 +1,174 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+
110
+ # pdm
111
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112
+ #pdm.lock
113
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114
+ # in version control.
115
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116
+ .pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121
+ __pypackages__/
122
+
123
+ # Celery stuff
124
+ celerybeat-schedule
125
+ celerybeat.pid
126
+
127
+ # SageMath parsed files
128
+ *.sage.py
129
+
130
+ # Environments
131
+ .env
132
+ .venv
133
+ env/
134
+ venv/
135
+ ENV/
136
+ env.bak/
137
+ venv.bak/
138
+
139
+ # Spyder project settings
140
+ .spyderproject
141
+ .spyproject
142
+
143
+ # Rope project settings
144
+ .ropeproject
145
+
146
+ # mkdocs documentation
147
+ /site
148
+
149
+ # mypy
150
+ .mypy_cache/
151
+ .dmypy.json
152
+ dmypy.json
153
+
154
+ # Pyre type checker
155
+ .pyre/
156
+
157
+ # pytype static type analyzer
158
+ .pytype/
159
+
160
+ # Cython debug symbols
161
+ cython_debug/
162
+
163
+ # PyCharm
164
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
167
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
168
+ #.idea/
169
+
170
+ # PyPI configuration file
171
+ .pypirc
172
+
173
+ *.o
174
+ *.exe
@@ -0,0 +1 @@
1
+ 3.13
@@ -0,0 +1,20 @@
1
+ # Read the Docs configuration file
2
+ # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3
+
4
+ # Required
5
+ version: 2
6
+
7
+ # Set the OS, Python version, and other tools you might need
8
+ build:
9
+ os: ubuntu-24.04
10
+ tools:
11
+ python: "3.13"
12
+
13
+ # Build documentation in the "docs/" directory with Sphinx
14
+ sphinx:
15
+ configuration: docs/conf.py
16
+
17
+ python:
18
+ install:
19
+ - requirements: docs/requirements.txt
20
+
@@ -0,0 +1,5 @@
1
+ {
2
+ "[yaml]": {
3
+ "editor.tabSize": 2
4
+ }
5
+ }
@@ -0,0 +1,2 @@
1
+ # Created by venv; see https://docs.python.org/3/library/venv.html
2
+ *
@@ -0,0 +1,248 @@
1
+ <#
2
+ .Synopsis
3
+ Activate a Python virtual environment for the current PowerShell session.
4
+
5
+ .Description
6
+ Pushes the python executable for a virtual environment to the front of the
7
+ $Env:PATH environment variable and sets the prompt to signify that you are
8
+ in a Python virtual environment. Makes use of the command line switches as
9
+ well as the `pyvenv.cfg` file values present in the virtual environment.
10
+
11
+ .Parameter VenvDir
12
+ Path to the directory that contains the virtual environment to activate. The
13
+ default value for this is the parent of the directory that the Activate.ps1
14
+ script is located within.
15
+
16
+ .Parameter Prompt
17
+ The prompt prefix to display when this virtual environment is activated. By
18
+ default, this prompt is the name of the virtual environment folder (VenvDir)
19
+ surrounded by parentheses and followed by a single space (ie. '(.venv) ').
20
+
21
+ .Example
22
+ Activate.ps1
23
+ Activates the Python virtual environment that contains the Activate.ps1 script.
24
+
25
+ .Example
26
+ Activate.ps1 -Verbose
27
+ Activates the Python virtual environment that contains the Activate.ps1 script,
28
+ and shows extra information about the activation as it executes.
29
+
30
+ .Example
31
+ Activate.ps1 -VenvDir C:\Users\MyUser\Common\.venv
32
+ Activates the Python virtual environment located in the specified location.
33
+
34
+ .Example
35
+ Activate.ps1 -Prompt "MyPython"
36
+ Activates the Python virtual environment that contains the Activate.ps1 script,
37
+ and prefixes the current prompt with the specified string (surrounded in
38
+ parentheses) while the virtual environment is active.
39
+
40
+ .Notes
41
+ On Windows, it may be required to enable this Activate.ps1 script by setting the
42
+ execution policy for the user. You can do this by issuing the following PowerShell
43
+ command:
44
+
45
+ PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
46
+
47
+ For more information on Execution Policies:
48
+ https://go.microsoft.com/fwlink/?LinkID=135170
49
+
50
+ #>
51
+ Param(
52
+ [Parameter(Mandatory = $false)]
53
+ [String]
54
+ $VenvDir,
55
+ [Parameter(Mandatory = $false)]
56
+ [String]
57
+ $Prompt
58
+ )
59
+
60
+ <# Function declarations --------------------------------------------------- #>
61
+
62
+ <#
63
+ .Synopsis
64
+ Remove all shell session elements added by the Activate script, including the
65
+ addition of the virtual environment's Python executable from the beginning of
66
+ the PATH variable.
67
+
68
+ .Parameter NonDestructive
69
+ If present, do not remove this function from the global namespace for the
70
+ session.
71
+
72
+ #>
73
+ function global:deactivate ([switch]$NonDestructive) {
74
+ # Revert to original values
75
+
76
+ # The prior prompt:
77
+ if (Test-Path -Path Function:_OLD_VIRTUAL_PROMPT) {
78
+ Copy-Item -Path Function:_OLD_VIRTUAL_PROMPT -Destination Function:prompt
79
+ Remove-Item -Path Function:_OLD_VIRTUAL_PROMPT
80
+ }
81
+
82
+ # The prior PYTHONHOME:
83
+ if (Test-Path -Path Env:_OLD_VIRTUAL_PYTHONHOME) {
84
+ Copy-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME -Destination Env:PYTHONHOME
85
+ Remove-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME
86
+ }
87
+
88
+ # The prior PATH:
89
+ if (Test-Path -Path Env:_OLD_VIRTUAL_PATH) {
90
+ Copy-Item -Path Env:_OLD_VIRTUAL_PATH -Destination Env:PATH
91
+ Remove-Item -Path Env:_OLD_VIRTUAL_PATH
92
+ }
93
+
94
+ # Just remove the VIRTUAL_ENV altogether:
95
+ if (Test-Path -Path Env:VIRTUAL_ENV) {
96
+ Remove-Item -Path env:VIRTUAL_ENV
97
+ }
98
+
99
+ # Just remove VIRTUAL_ENV_PROMPT altogether.
100
+ if (Test-Path -Path Env:VIRTUAL_ENV_PROMPT) {
101
+ Remove-Item -Path env:VIRTUAL_ENV_PROMPT
102
+ }
103
+
104
+ # Just remove the _PYTHON_VENV_PROMPT_PREFIX altogether:
105
+ if (Get-Variable -Name "_PYTHON_VENV_PROMPT_PREFIX" -ErrorAction SilentlyContinue) {
106
+ Remove-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Scope Global -Force
107
+ }
108
+
109
+ # Leave deactivate function in the global namespace if requested:
110
+ if (-not $NonDestructive) {
111
+ Remove-Item -Path function:deactivate
112
+ }
113
+ }
114
+
115
+ <#
116
+ .Description
117
+ Get-PyVenvConfig parses the values from the pyvenv.cfg file located in the
118
+ given folder, and returns them in a map.
119
+
120
+ For each line in the pyvenv.cfg file, if that line can be parsed into exactly
121
+ two strings separated by `=` (with any amount of whitespace surrounding the =)
122
+ then it is considered a `key = value` line. The left hand string is the key,
123
+ the right hand is the value.
124
+
125
+ If the value starts with a `'` or a `"` then the first and last character is
126
+ stripped from the value before being captured.
127
+
128
+ .Parameter ConfigDir
129
+ Path to the directory that contains the `pyvenv.cfg` file.
130
+ #>
131
+ function Get-PyVenvConfig(
132
+ [String]
133
+ $ConfigDir
134
+ ) {
135
+ Write-Verbose "Given ConfigDir=$ConfigDir, obtain values in pyvenv.cfg"
136
+
137
+ # Ensure the file exists, and issue a warning if it doesn't (but still allow the function to continue).
138
+ $pyvenvConfigPath = Join-Path -Resolve -Path $ConfigDir -ChildPath 'pyvenv.cfg' -ErrorAction Continue
139
+
140
+ # An empty map will be returned if no config file is found.
141
+ $pyvenvConfig = @{ }
142
+
143
+ if ($pyvenvConfigPath) {
144
+
145
+ Write-Verbose "File exists, parse `key = value` lines"
146
+ $pyvenvConfigContent = Get-Content -Path $pyvenvConfigPath
147
+
148
+ $pyvenvConfigContent | ForEach-Object {
149
+ $keyval = $PSItem -split "\s*=\s*", 2
150
+ if ($keyval[0] -and $keyval[1]) {
151
+ $val = $keyval[1]
152
+
153
+ # Remove extraneous quotations around a string value.
154
+ if ("'""".Contains($val.Substring(0, 1))) {
155
+ $val = $val.Substring(1, $val.Length - 2)
156
+ }
157
+
158
+ $pyvenvConfig[$keyval[0]] = $val
159
+ Write-Verbose "Adding Key: '$($keyval[0])'='$val'"
160
+ }
161
+ }
162
+ }
163
+ return $pyvenvConfig
164
+ }
165
+
166
+
167
+ <# Begin Activate script --------------------------------------------------- #>
168
+
169
+ # Determine the containing directory of this script
170
+ $VenvExecPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
171
+ $VenvExecDir = Get-Item -Path $VenvExecPath
172
+
173
+ Write-Verbose "Activation script is located in path: '$VenvExecPath'"
174
+ Write-Verbose "VenvExecDir Fullname: '$($VenvExecDir.FullName)"
175
+ Write-Verbose "VenvExecDir Name: '$($VenvExecDir.Name)"
176
+
177
+ # Set values required in priority: CmdLine, ConfigFile, Default
178
+ # First, get the location of the virtual environment, it might not be
179
+ # VenvExecDir if specified on the command line.
180
+ if ($VenvDir) {
181
+ Write-Verbose "VenvDir given as parameter, using '$VenvDir' to determine values"
182
+ }
183
+ else {
184
+ Write-Verbose "VenvDir not given as a parameter, using parent directory name as VenvDir."
185
+ $VenvDir = $VenvExecDir.Parent.FullName.TrimEnd("\\/")
186
+ Write-Verbose "VenvDir=$VenvDir"
187
+ }
188
+
189
+ # Next, read the `pyvenv.cfg` file to determine any required value such
190
+ # as `prompt`.
191
+ $pyvenvCfg = Get-PyVenvConfig -ConfigDir $VenvDir
192
+
193
+ # Next, set the prompt from the command line, or the config file, or
194
+ # just use the name of the virtual environment folder.
195
+ if ($Prompt) {
196
+ Write-Verbose "Prompt specified as argument, using '$Prompt'"
197
+ }
198
+ else {
199
+ Write-Verbose "Prompt not specified as argument to script, checking pyvenv.cfg value"
200
+ if ($pyvenvCfg -and $pyvenvCfg['prompt']) {
201
+ Write-Verbose " Setting based on value in pyvenv.cfg='$($pyvenvCfg['prompt'])'"
202
+ $Prompt = $pyvenvCfg['prompt'];
203
+ }
204
+ else {
205
+ Write-Verbose " Setting prompt based on parent's directory's name. (Is the directory name passed to venv module when creating the virtual environment)"
206
+ Write-Verbose " Got leaf-name of $VenvDir='$(Split-Path -Path $venvDir -Leaf)'"
207
+ $Prompt = Split-Path -Path $venvDir -Leaf
208
+ }
209
+ }
210
+
211
+ Write-Verbose "Prompt = '$Prompt'"
212
+ Write-Verbose "VenvDir='$VenvDir'"
213
+
214
+ # Deactivate any currently active virtual environment, but leave the
215
+ # deactivate function in place.
216
+ deactivate -nondestructive
217
+
218
+ # Now set the environment variable VIRTUAL_ENV, used by many tools to determine
219
+ # that there is an activated venv.
220
+ $env:VIRTUAL_ENV = $VenvDir
221
+
222
+ $env:VIRTUAL_ENV_PROMPT = $Prompt
223
+
224
+ if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) {
225
+
226
+ Write-Verbose "Setting prompt to '$Prompt'"
227
+
228
+ # Set the prompt to include the env name
229
+ # Make sure _OLD_VIRTUAL_PROMPT is global
230
+ function global:_OLD_VIRTUAL_PROMPT { "" }
231
+ Copy-Item -Path function:prompt -Destination function:_OLD_VIRTUAL_PROMPT
232
+ New-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Description "Python virtual environment prompt prefix" -Scope Global -Option ReadOnly -Visibility Public -Value $Prompt
233
+
234
+ function global:prompt {
235
+ Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) "
236
+ _OLD_VIRTUAL_PROMPT
237
+ }
238
+ }
239
+
240
+ # Clear PYTHONHOME
241
+ if (Test-Path -Path Env:PYTHONHOME) {
242
+ Copy-Item -Path Env:PYTHONHOME -Destination Env:_OLD_VIRTUAL_PYTHONHOME
243
+ Remove-Item -Path Env:PYTHONHOME
244
+ }
245
+
246
+ # Add the venv to the PATH
247
+ Copy-Item -Path Env:PATH -Destination Env:_OLD_VIRTUAL_PATH
248
+ $Env:PATH = "$VenvExecDir$([System.IO.Path]::PathSeparator)$Env:PATH"
@@ -0,0 +1,75 @@
1
+ # This file must be used with "source bin/activate" *from bash*
2
+ # You cannot run it directly
3
+
4
+ deactivate () {
5
+ # reset old environment variables
6
+ if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
7
+ PATH="${_OLD_VIRTUAL_PATH:-}"
8
+ export PATH
9
+ unset _OLD_VIRTUAL_PATH
10
+ fi
11
+ if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
12
+ PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
13
+ export PYTHONHOME
14
+ unset _OLD_VIRTUAL_PYTHONHOME
15
+ fi
16
+
17
+ # Call hash to forget past commands. Without forgetting
18
+ # past commands the $PATH changes we made may not be respected
19
+ hash -r 2> /dev/null
20
+
21
+ if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
22
+ PS1="${_OLD_VIRTUAL_PS1:-}"
23
+ export PS1
24
+ unset _OLD_VIRTUAL_PS1
25
+ fi
26
+
27
+ unset VIRTUAL_ENV
28
+ unset VIRTUAL_ENV_PROMPT
29
+ if [ ! "${1:-}" = "nondestructive" ] ; then
30
+ # Self destruct!
31
+ unset -f deactivate
32
+ fi
33
+ }
34
+
35
+ # unset irrelevant variables
36
+ deactivate nondestructive
37
+
38
+ # on Windows, a path can contain colons and backslashes and has to be converted:
39
+ case "$(uname)" in
40
+ CYGWIN*|MSYS*)
41
+ # transform D:\path\to\venv to /d/path/to/venv on MSYS
42
+ # and to /cygdrive/d/path/to/venv on Cygwin
43
+ VIRTUAL_ENV=$(cygpath "/Users/ishimoto/src/pyprod/.xxx/.Prodfile.py.pyprod")
44
+ export VIRTUAL_ENV
45
+ ;;
46
+ *)
47
+ # use the path as-is
48
+ export VIRTUAL_ENV="/Users/ishimoto/src/pyprod/.xxx/.Prodfile.py.pyprod"
49
+ ;;
50
+ esac
51
+
52
+ _OLD_VIRTUAL_PATH="$PATH"
53
+ PATH="$VIRTUAL_ENV/bin:$PATH"
54
+ export PATH
55
+
56
+ VIRTUAL_ENV_PROMPT=".Prodfile.py.pyprod"
57
+ export VIRTUAL_ENV_PROMPT
58
+
59
+ # unset PYTHONHOME if set
60
+ # this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
61
+ # could use `if (set -u; : $PYTHONHOME) ;` in bash
62
+ if [ -n "${PYTHONHOME:-}" ] ; then
63
+ _OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
64
+ unset PYTHONHOME
65
+ fi
66
+
67
+ if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
68
+ _OLD_VIRTUAL_PS1="${PS1:-}"
69
+ PS1="(.Prodfile.py.pyprod) ${PS1:-}"
70
+ export PS1
71
+ fi
72
+
73
+ # Call hash to forget past commands. Without forgetting
74
+ # past commands the $PATH changes we made may not be respected
75
+ hash -r 2> /dev/null
@@ -0,0 +1,27 @@
1
+ # This file must be used with "source bin/activate.csh" *from csh*.
2
+ # You cannot run it directly.
3
+
4
+ # Created by Davide Di Blasi <davidedb@gmail.com>.
5
+ # Ported to Python 3.3 venv by Andrew Svetlov <andrew.svetlov@gmail.com>
6
+
7
+ alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; unsetenv VIRTUAL_ENV_PROMPT; test "\!:*" != "nondestructive" && unalias deactivate'
8
+
9
+ # Unset irrelevant variables.
10
+ deactivate nondestructive
11
+
12
+ setenv VIRTUAL_ENV "/Users/ishimoto/src/pyprod/.xxx/.Prodfile.py.pyprod"
13
+
14
+ set _OLD_VIRTUAL_PATH="$PATH"
15
+ setenv PATH "$VIRTUAL_ENV/bin:$PATH"
16
+ setenv VIRTUAL_ENV_PROMPT ".Prodfile.py.pyprod"
17
+
18
+
19
+ set _OLD_VIRTUAL_PROMPT="$prompt"
20
+
21
+ if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then
22
+ set prompt = "(.Prodfile.py.pyprod) $prompt"
23
+ endif
24
+
25
+ alias pydoc python -m pydoc
26
+
27
+ rehash
@@ -0,0 +1,69 @@
1
+ # This file must be used with "source <venv>/bin/activate.fish" *from fish*
2
+ # (https://fishshell.com/). You cannot run it directly.
3
+
4
+ function deactivate -d "Exit virtual environment and return to normal shell environment"
5
+ # reset old environment variables
6
+ if test -n "$_OLD_VIRTUAL_PATH"
7
+ set -gx PATH $_OLD_VIRTUAL_PATH
8
+ set -e _OLD_VIRTUAL_PATH
9
+ end
10
+ if test -n "$_OLD_VIRTUAL_PYTHONHOME"
11
+ set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
12
+ set -e _OLD_VIRTUAL_PYTHONHOME
13
+ end
14
+
15
+ if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
16
+ set -e _OLD_FISH_PROMPT_OVERRIDE
17
+ # prevents error when using nested fish instances (Issue #93858)
18
+ if functions -q _old_fish_prompt
19
+ functions -e fish_prompt
20
+ functions -c _old_fish_prompt fish_prompt
21
+ functions -e _old_fish_prompt
22
+ end
23
+ end
24
+
25
+ set -e VIRTUAL_ENV
26
+ set -e VIRTUAL_ENV_PROMPT
27
+ if test "$argv[1]" != "nondestructive"
28
+ # Self-destruct!
29
+ functions -e deactivate
30
+ end
31
+ end
32
+
33
+ # Unset irrelevant variables.
34
+ deactivate nondestructive
35
+
36
+ set -gx VIRTUAL_ENV "/Users/ishimoto/src/pyprod/.xxx/.Prodfile.py.pyprod"
37
+
38
+ set -gx _OLD_VIRTUAL_PATH $PATH
39
+ set -gx PATH "$VIRTUAL_ENV/bin" $PATH
40
+ set -gx VIRTUAL_ENV_PROMPT ".Prodfile.py.pyprod"
41
+
42
+ # Unset PYTHONHOME if set.
43
+ if set -q PYTHONHOME
44
+ set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
45
+ set -e PYTHONHOME
46
+ end
47
+
48
+ if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
49
+ # fish uses a function instead of an env var to generate the prompt.
50
+
51
+ # Save the current fish_prompt function as the function _old_fish_prompt.
52
+ functions -c fish_prompt _old_fish_prompt
53
+
54
+ # With the original prompt function renamed, we can override with our own.
55
+ function fish_prompt
56
+ # Save the return status of the last command.
57
+ set -l old_status $status
58
+
59
+ # Output the venv prompt; color taken from the blue of the Python logo.
60
+ printf "%s(%s)%s " (set_color 4B8BBE) ".Prodfile.py.pyprod" (set_color normal)
61
+
62
+ # Restore the return status of the previous command.
63
+ echo "exit $old_status" | .
64
+ # Output the original/"old" prompt.
65
+ _old_fish_prompt
66
+ end
67
+
68
+ set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
69
+ end