packing-packages 0.0.2__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.
- packing_packages-0.0.2/LICENSE +21 -0
- packing_packages-0.0.2/PKG-INFO +155 -0
- packing_packages-0.0.2/README.md +94 -0
- packing_packages-0.0.2/pyproject.toml +63 -0
- packing_packages-0.0.2/setup.cfg +4 -0
- packing_packages-0.0.2/src/packing_packages/__init__.py +24 -0
- packing_packages-0.0.2/src/packing_packages/__main__.py +84 -0
- packing_packages-0.0.2/src/packing_packages/constants.py +30 -0
- packing_packages-0.0.2/src/packing_packages/install/__init__.py +18 -0
- packing_packages-0.0.2/src/packing_packages/install/__main__.py +49 -0
- packing_packages-0.0.2/src/packing_packages/install/_core.py +175 -0
- packing_packages-0.0.2/src/packing_packages/logging/__init__.py +31 -0
- packing_packages-0.0.2/src/packing_packages/logging/_logging.py +208 -0
- packing_packages-0.0.2/src/packing_packages/pack/__init__.py +18 -0
- packing_packages-0.0.2/src/packing_packages/pack/__main__.py +59 -0
- packing_packages-0.0.2/src/packing_packages/pack/_core.py +248 -0
- packing_packages-0.0.2/src/packing_packages/utils/__init__.py +12 -0
- packing_packages-0.0.2/src/packing_packages/utils/_utils.py +65 -0
- packing_packages-0.0.2/src/packing_packages.egg-info/PKG-INFO +155 -0
- packing_packages-0.0.2/src/packing_packages.egg-info/SOURCES.txt +23 -0
- packing_packages-0.0.2/src/packing_packages.egg-info/dependency_links.txt +1 -0
- packing_packages-0.0.2/src/packing_packages.egg-info/entry_points.txt +2 -0
- packing_packages-0.0.2/src/packing_packages.egg-info/requires.txt +19 -0
- packing_packages-0.0.2/src/packing_packages.egg-info/top_level.txt +1 -0
- packing_packages-0.0.2/tests/test_import.py +6 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 yu9824
|
|
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,155 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: packing-packages
|
|
3
|
+
Version: 0.0.2
|
|
4
|
+
Summary: This module provides functionality to pack conda environments and their dependencies into a specified directory.
|
|
5
|
+
Author: yu9824
|
|
6
|
+
Maintainer: yu9824
|
|
7
|
+
License: MIT License
|
|
8
|
+
|
|
9
|
+
Copyright (c) 2024 yu9824
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
|
28
|
+
|
|
29
|
+
Project-URL: Homepage, https://github.com/yu9824/packing-packages
|
|
30
|
+
Project-URL: Documentation, https://yu9824.github.io/packing-packages/
|
|
31
|
+
Project-URL: PyPI, https://pypi.org/project/packing-packages/
|
|
32
|
+
Project-URL: Source, https://github.com/yu9824/packing-packages
|
|
33
|
+
Project-URL: Tracker, https://github.com/yu9824/packing-packages/issues
|
|
34
|
+
Project-URL: Changelog, https://github.com/yu9824/packing-packages/blob/main/CHANGELOG.md
|
|
35
|
+
Keywords: anaconda,conda
|
|
36
|
+
Classifier: Programming Language :: Python :: 3
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
42
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
43
|
+
Requires-Python: >=3.9
|
|
44
|
+
Description-Content-Type: text/markdown
|
|
45
|
+
License-File: LICENSE
|
|
46
|
+
Provides-Extra: test
|
|
47
|
+
Requires-Dist: pytest; extra == "test"
|
|
48
|
+
Provides-Extra: dev
|
|
49
|
+
Requires-Dist: build; extra == "dev"
|
|
50
|
+
Provides-Extra: optional
|
|
51
|
+
Requires-Dist: colorlog; extra == "optional"
|
|
52
|
+
Requires-Dist: tqdm; extra == "optional"
|
|
53
|
+
Provides-Extra: docs
|
|
54
|
+
Requires-Dist: sphinx; extra == "docs"
|
|
55
|
+
Requires-Dist: sphinx_rtd_theme; extra == "docs"
|
|
56
|
+
Requires-Dist: sphinx-markdown-tables; extra == "docs"
|
|
57
|
+
Requires-Dist: recommonmark; extra == "docs"
|
|
58
|
+
Provides-Extra: gui
|
|
59
|
+
Requires-Dist: TkEasyGUI; extra == "gui"
|
|
60
|
+
Dynamic: license-file
|
|
61
|
+
|
|
62
|
+
# PACKING-PACKAGES
|
|
63
|
+
|
|
64
|
+
[](https://github.com/yu9824/packing-packages/actions/workflows/CI.yml)
|
|
65
|
+
[](https://github.com/yu9824/packing-packages/actions/workflows/docs.yml)
|
|
66
|
+
[](https://github.com/yu9824/packing-packages/actions/workflows/release-pypi.yml)
|
|
67
|
+
|
|
68
|
+
[](https://github.com/astral-sh/ruff)
|
|
69
|
+
[](https://github.com/python/mypy)
|
|
70
|
+
|
|
71
|
+
[](https://pypi.org/project/packing-packages/)
|
|
72
|
+
[](https://pypi.org/project/packing-packages/)
|
|
73
|
+
[](https://pypi.org/project/packing-packages/)
|
|
74
|
+
[](https://pepy.tech/project/packing-packages)
|
|
75
|
+
|
|
76
|
+
<!-- [](https://anaconda.org/conda-forge/packing-packages)
|
|
77
|
+
[](https://anaconda.org/conda-forge/packing-packages) -->
|
|
78
|
+
|
|
79
|
+
This module provides functionality to pack conda environments and their dependencies into a specified directory.
|
|
80
|
+
|
|
81
|
+
You can use this package to migrate a conda environment to another offline machine with the same operating system.
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
## Install
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# Need python, setuptools, pip package
|
|
88
|
+
pip install packing-packages
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## How to use
|
|
93
|
+
|
|
94
|
+
see `--help`.
|
|
95
|
+
|
|
96
|
+
### Pack
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
packing-package pack -d .
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Install
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
packing-package install .
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Example
|
|
111
|
+
|
|
112
|
+
### Source device
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
conda activate <envname>
|
|
116
|
+
python -m pip install packing-packages
|
|
117
|
+
python -m packing_packages pack -d .
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Destination device (offline)
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
conda create -yn <envname> --offline
|
|
125
|
+
conda activate <envname>
|
|
126
|
+
conda install --use-local --offline ./conda/*
|
|
127
|
+
python -m pip install --no-deps --no-build-isolation ./pypi/*
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Notes
|
|
132
|
+
|
|
133
|
+
If you want to use pip to download from a source other than pypi.org (e.g. pytorch), the above will not completely collect. You will see packages that failed to download, so you will have to download them manually.
|
|
134
|
+
This is very complicated and we do not plan to support it.
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
# install command
|
|
138
|
+
pip install torch==2.5.1 --index-url https://download.pytorch.org/whl/cu124
|
|
139
|
+
|
|
140
|
+
# download command
|
|
141
|
+
# --no-deps: only target package
|
|
142
|
+
# -d: destination directory to download
|
|
143
|
+
pip download torch==2.5.1 --index-url https://download.pytorch.org/whl/cu124 --no-deps -d .
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Some older packages may not install with `pip install`. In this case, you may succeed by installing only the failed packages with the `--use-pep517` option.
|
|
147
|
+
Please perform this manually.
|
|
148
|
+
|
|
149
|
+
There are two methods of installation: one is to use the standard functions of conda and pip, and the second is to use the `paciking-package install` command, which wraps them. The advantages of each are summarized in the table below.
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
| Commands | Advantages | Disadvantages |
|
|
153
|
+
| --------------------------------- | ----------------------------------------------- | --------------------------------- |
|
|
154
|
+
| `conda install` or `pip install` | Fast | Stop immediately when cause error |
|
|
155
|
+
| `packing-package install` | Skip when error occurs and tell you the package | Slow |
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# PACKING-PACKAGES
|
|
2
|
+
|
|
3
|
+
[](https://github.com/yu9824/packing-packages/actions/workflows/CI.yml)
|
|
4
|
+
[](https://github.com/yu9824/packing-packages/actions/workflows/docs.yml)
|
|
5
|
+
[](https://github.com/yu9824/packing-packages/actions/workflows/release-pypi.yml)
|
|
6
|
+
|
|
7
|
+
[](https://github.com/astral-sh/ruff)
|
|
8
|
+
[](https://github.com/python/mypy)
|
|
9
|
+
|
|
10
|
+
[](https://pypi.org/project/packing-packages/)
|
|
11
|
+
[](https://pypi.org/project/packing-packages/)
|
|
12
|
+
[](https://pypi.org/project/packing-packages/)
|
|
13
|
+
[](https://pepy.tech/project/packing-packages)
|
|
14
|
+
|
|
15
|
+
<!-- [](https://anaconda.org/conda-forge/packing-packages)
|
|
16
|
+
[](https://anaconda.org/conda-forge/packing-packages) -->
|
|
17
|
+
|
|
18
|
+
This module provides functionality to pack conda environments and their dependencies into a specified directory.
|
|
19
|
+
|
|
20
|
+
You can use this package to migrate a conda environment to another offline machine with the same operating system.
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## Install
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# Need python, setuptools, pip package
|
|
27
|
+
pip install packing-packages
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## How to use
|
|
32
|
+
|
|
33
|
+
see `--help`.
|
|
34
|
+
|
|
35
|
+
### Pack
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
packing-package pack -d .
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Install
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
packing-package install .
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Example
|
|
50
|
+
|
|
51
|
+
### Source device
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
conda activate <envname>
|
|
55
|
+
python -m pip install packing-packages
|
|
56
|
+
python -m packing_packages pack -d .
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Destination device (offline)
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
conda create -yn <envname> --offline
|
|
64
|
+
conda activate <envname>
|
|
65
|
+
conda install --use-local --offline ./conda/*
|
|
66
|
+
python -m pip install --no-deps --no-build-isolation ./pypi/*
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Notes
|
|
71
|
+
|
|
72
|
+
If you want to use pip to download from a source other than pypi.org (e.g. pytorch), the above will not completely collect. You will see packages that failed to download, so you will have to download them manually.
|
|
73
|
+
This is very complicated and we do not plan to support it.
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# install command
|
|
77
|
+
pip install torch==2.5.1 --index-url https://download.pytorch.org/whl/cu124
|
|
78
|
+
|
|
79
|
+
# download command
|
|
80
|
+
# --no-deps: only target package
|
|
81
|
+
# -d: destination directory to download
|
|
82
|
+
pip download torch==2.5.1 --index-url https://download.pytorch.org/whl/cu124 --no-deps -d .
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Some older packages may not install with `pip install`. In this case, you may succeed by installing only the failed packages with the `--use-pep517` option.
|
|
86
|
+
Please perform this manually.
|
|
87
|
+
|
|
88
|
+
There are two methods of installation: one is to use the standard functions of conda and pip, and the second is to use the `paciking-package install` command, which wraps them. The advantages of each are summarized in the table below.
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
| Commands | Advantages | Disadvantages |
|
|
92
|
+
| --------------------------------- | ----------------------------------------------- | --------------------------------- |
|
|
93
|
+
| `conda install` or `pip install` | Fast | Stop immediately when cause error |
|
|
94
|
+
| `packing-package install` | Skip when error occurs and tell you the package | Slow |
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# https://packaging.python.org/ja/latest/guides/writing-pyproject-toml/
|
|
2
|
+
[build-system]
|
|
3
|
+
requires = ["setuptools"]
|
|
4
|
+
build-backend = "setuptools.build_meta"
|
|
5
|
+
|
|
6
|
+
[project]
|
|
7
|
+
name = "packing-packages"
|
|
8
|
+
dynamic = ["version"]
|
|
9
|
+
dependencies = []
|
|
10
|
+
requires-python = ">= 3.9"
|
|
11
|
+
authors = [{ name = "yu9824" }]
|
|
12
|
+
maintainers = [{ name = "yu9824" }]
|
|
13
|
+
description = "This module provides functionality to pack conda environments and their dependencies into a specified directory."
|
|
14
|
+
readme = { file = "README.md", content-type = "text/markdown" }
|
|
15
|
+
license = { file = "LICENSE" }
|
|
16
|
+
keywords = ["anaconda", "conda"]
|
|
17
|
+
# https://pypi.org/classifiers/
|
|
18
|
+
classifiers = [
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.9",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Programming Language :: Python :: 3.13",
|
|
25
|
+
"License :: OSI Approved :: MIT License",
|
|
26
|
+
] # https://pypi.org/classifiers/
|
|
27
|
+
|
|
28
|
+
[project.optional-dependencies]
|
|
29
|
+
test = ["pytest"]
|
|
30
|
+
dev = ["build"]
|
|
31
|
+
optional = ["colorlog", "tqdm"]
|
|
32
|
+
docs = ["sphinx", "sphinx_rtd_theme", "sphinx-markdown-tables", "recommonmark"]
|
|
33
|
+
gui = ["TkEasyGUI"]
|
|
34
|
+
|
|
35
|
+
[project.urls]
|
|
36
|
+
Homepage = "https://github.com/yu9824/packing-packages"
|
|
37
|
+
Documentation = "https://yu9824.github.io/packing-packages/"
|
|
38
|
+
PyPI = "https://pypi.org/project/packing-packages/"
|
|
39
|
+
Source = "https://github.com/yu9824/packing-packages"
|
|
40
|
+
Tracker = "https://github.com/yu9824/packing-packages/issues"
|
|
41
|
+
Changelog = "https://github.com/yu9824/packing-packages/blob/main/CHANGELOG.md"
|
|
42
|
+
|
|
43
|
+
[project.scripts]
|
|
44
|
+
packing-packages = "packing_packages.__main__:entrypoint"
|
|
45
|
+
|
|
46
|
+
# [project.gui-scripts]
|
|
47
|
+
# packing-packages-gui = "packing_packages:main_gui"
|
|
48
|
+
|
|
49
|
+
[tool.setuptools]
|
|
50
|
+
package-dir = { "" = "src" }
|
|
51
|
+
|
|
52
|
+
[tool.setuptools.dynamic]
|
|
53
|
+
version = { attr = "packing_packages.__version__" }
|
|
54
|
+
|
|
55
|
+
[tool.setuptools.packages.find]
|
|
56
|
+
where = ["src/"]
|
|
57
|
+
|
|
58
|
+
[tool.ruff]
|
|
59
|
+
line-length = 79
|
|
60
|
+
indent-width = 4
|
|
61
|
+
|
|
62
|
+
[tool.ruff.lint]
|
|
63
|
+
unfixable = ["F401"]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""Packing Packages
|
|
2
|
+
|
|
3
|
+
Packing packages for distribution and installation.
|
|
4
|
+
This module provides functionality to pack conda environments and their
|
|
5
|
+
dependencies into a specified directory.
|
|
6
|
+
|
|
7
|
+
.. code-block:: bash
|
|
8
|
+
|
|
9
|
+
$ python -m packing_packages pack --help
|
|
10
|
+
$ python -m packing_packages install --help
|
|
11
|
+
|
|
12
|
+
or
|
|
13
|
+
|
|
14
|
+
$ packing-packages pack --help
|
|
15
|
+
$ packing-packages install --help
|
|
16
|
+
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
__version__ = "0.0.2"
|
|
20
|
+
__license__ = "MIT"
|
|
21
|
+
__author__ = "yu9824"
|
|
22
|
+
__copyright__ = "Copyright © 2025 yu9824"
|
|
23
|
+
|
|
24
|
+
# __all__ = ()
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import sys
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
5
|
+
if sys.version_info >= (3, 9):
|
|
6
|
+
from collections.abc import Sequence
|
|
7
|
+
else:
|
|
8
|
+
from typing import Sequence
|
|
9
|
+
|
|
10
|
+
from packing_packages import __version__
|
|
11
|
+
from packing_packages.install.__main__ import install
|
|
12
|
+
from packing_packages.pack.__main__ import pack
|
|
13
|
+
|
|
14
|
+
__all__ = ("main",)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def main(cli_args: Sequence[str], prog: Optional[str] = None) -> None:
|
|
18
|
+
parser = argparse.ArgumentParser(prog=prog, description="")
|
|
19
|
+
parser.add_argument(
|
|
20
|
+
"-v",
|
|
21
|
+
"--version",
|
|
22
|
+
action="version",
|
|
23
|
+
help="show current version",
|
|
24
|
+
version=f"%(prog)s: {__version__}",
|
|
25
|
+
)
|
|
26
|
+
subparsers = parser.add_subparsers()
|
|
27
|
+
parser_pack = subparsers.add_parser(
|
|
28
|
+
"pack",
|
|
29
|
+
help="pack conda environment",
|
|
30
|
+
)
|
|
31
|
+
parser_pack.add_argument(
|
|
32
|
+
"-e",
|
|
33
|
+
"-n",
|
|
34
|
+
"--env-name",
|
|
35
|
+
type=str,
|
|
36
|
+
default=None,
|
|
37
|
+
help="conda environment name",
|
|
38
|
+
)
|
|
39
|
+
parser_pack.add_argument(
|
|
40
|
+
"-d",
|
|
41
|
+
"--dirpath-target",
|
|
42
|
+
type=str,
|
|
43
|
+
default=".",
|
|
44
|
+
help="target directory path",
|
|
45
|
+
)
|
|
46
|
+
parser_pack.add_argument(
|
|
47
|
+
"-D",
|
|
48
|
+
"--dry-run",
|
|
49
|
+
action="store_true",
|
|
50
|
+
help="do not download files",
|
|
51
|
+
)
|
|
52
|
+
parser_pack.set_defaults(func=pack)
|
|
53
|
+
|
|
54
|
+
parser_install = subparsers.add_parser(
|
|
55
|
+
"install",
|
|
56
|
+
help="install packages in the conda environment",
|
|
57
|
+
)
|
|
58
|
+
parser_install.add_argument(
|
|
59
|
+
"-e",
|
|
60
|
+
"-n",
|
|
61
|
+
"--env-name",
|
|
62
|
+
type=str,
|
|
63
|
+
default=None,
|
|
64
|
+
help="conda environment name",
|
|
65
|
+
)
|
|
66
|
+
parser_install.add_argument(
|
|
67
|
+
type=str,
|
|
68
|
+
default=".",
|
|
69
|
+
help="directory path of packages",
|
|
70
|
+
metavar="DIRPATH_PACKAGES",
|
|
71
|
+
dest="dirpath_packages",
|
|
72
|
+
)
|
|
73
|
+
parser_install.set_defaults(func=install)
|
|
74
|
+
|
|
75
|
+
args = parser.parse_args(cli_args)
|
|
76
|
+
args.func(args)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def entrypoint() -> None:
|
|
80
|
+
main(sys.argv[1:])
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
if __name__ == "__main__":
|
|
84
|
+
main(sys.argv[1:], prog="packing-packages")
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""This module contains constants used throughout the packing_packages package.
|
|
2
|
+
|
|
3
|
+
It includes constants for file extensions, encoding, and other configuration values.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from typing import Literal
|
|
7
|
+
|
|
8
|
+
EXTENSIONS_CONDA: tuple[Literal["tar.bz2"], Literal["conda"]] = (
|
|
9
|
+
"tar.bz2",
|
|
10
|
+
"conda",
|
|
11
|
+
)
|
|
12
|
+
"""Extensions for conda packages.
|
|
13
|
+
|
|
14
|
+
These are the extensions used by conda packages.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
EXTENSIONS_PYPI: tuple[Literal["whl"], Literal["tar.gz"]] = (
|
|
18
|
+
"whl",
|
|
19
|
+
"tar.gz",
|
|
20
|
+
)
|
|
21
|
+
"""Extensions for PyPI packages.
|
|
22
|
+
|
|
23
|
+
These are the extensions used by PyPI packages.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
ENCODING: Literal["utf-8"] = "utf-8"
|
|
27
|
+
"""Encoding for file operations.
|
|
28
|
+
This is the encoding used for file operations in the project.
|
|
29
|
+
It is set to 'utf-8' to ensure compatibility with most text files.
|
|
30
|
+
"""
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""Install packages for the packing_packages project.
|
|
2
|
+
|
|
3
|
+
This module provides a function to install packages from a specified
|
|
4
|
+
directory into a conda environment.
|
|
5
|
+
|
|
6
|
+
.. code-block:: bash
|
|
7
|
+
|
|
8
|
+
$ python -m packing_packages install --help
|
|
9
|
+
|
|
10
|
+
or
|
|
11
|
+
|
|
12
|
+
$ packing-packages install --help
|
|
13
|
+
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from ._core import install_packages
|
|
17
|
+
|
|
18
|
+
__all__ = ("install_packages",)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import os
|
|
3
|
+
from collections.abc import Sequence
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import Optional
|
|
6
|
+
|
|
7
|
+
from packing_packages.install._core import install_packages
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def install(args: argparse.Namespace) -> None:
|
|
11
|
+
"""Install packages in the conda environment."""
|
|
12
|
+
if args.env_name is None:
|
|
13
|
+
env_name = os.environ["CONDA_DEFAULT_ENV"]
|
|
14
|
+
else:
|
|
15
|
+
env_name = args.env_name
|
|
16
|
+
|
|
17
|
+
dirpath_packages = Path(args.dirpath_packages).resolve()
|
|
18
|
+
if not dirpath_packages.is_dir():
|
|
19
|
+
raise FileNotFoundError(dirpath_packages)
|
|
20
|
+
|
|
21
|
+
install_packages(
|
|
22
|
+
dirpath_packages=dirpath_packages,
|
|
23
|
+
env_name=env_name,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def main(cli_args: Sequence[str], prog: Optional[str] = None) -> None:
|
|
28
|
+
"""Main function to parse arguments and call the install function."""
|
|
29
|
+
parser = argparse.ArgumentParser(
|
|
30
|
+
prog=prog, description="Install packages in the conda environment"
|
|
31
|
+
)
|
|
32
|
+
parser.add_argument(
|
|
33
|
+
"dirpath-packages",
|
|
34
|
+
type=str,
|
|
35
|
+
default=".",
|
|
36
|
+
help="directory path of packages",
|
|
37
|
+
metavar="DIRPATH_PACKAGES",
|
|
38
|
+
)
|
|
39
|
+
parser.add_argument(
|
|
40
|
+
"-e",
|
|
41
|
+
"-n",
|
|
42
|
+
"--env-name",
|
|
43
|
+
type=str,
|
|
44
|
+
default=None,
|
|
45
|
+
help="conda environment name",
|
|
46
|
+
)
|
|
47
|
+
parser.set_defaults(func=install)
|
|
48
|
+
args = parser.parse_args(cli_args)
|
|
49
|
+
args.func(args)
|