virtualenv-asdf 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.
- virtualenv_asdf-0.1.0/LICENSE +22 -0
- virtualenv_asdf-0.1.0/PKG-INFO +81 -0
- virtualenv_asdf-0.1.0/README.md +53 -0
- virtualenv_asdf-0.1.0/pyproject.toml +72 -0
- virtualenv_asdf-0.1.0/setup.py +38 -0
- virtualenv_asdf-0.1.0/src/_virtualenv_asdf/__init__.py +1 -0
- virtualenv_asdf-0.1.0/src/_virtualenv_asdf/discovery.py +59 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Scott Sharkey <ssharkey@lanshark.com>
|
|
4
|
+
Copyright (c) 2021, 2022 un.def <me@undef.im>
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: virtualenv-asdf
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A virtualenv Python discovery plugin using asdf
|
|
5
|
+
Home-page: https://github.com/lanshark/virtualenv-asdf
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: virtualenv,asdf
|
|
8
|
+
Author: Scott Sharkey
|
|
9
|
+
Author-email: ssharkey@lanshark.com
|
|
10
|
+
Requires-Python: >=3.7,<4.0
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
21
|
+
Classifier: Topic :: Software Development :: Testing
|
|
22
|
+
Classifier: Topic :: Utilities
|
|
23
|
+
Requires-Dist: asdf-inspect (>=0.1,<0.2)
|
|
24
|
+
Requires-Dist: virtualenv
|
|
25
|
+
Project-URL: Repository, https://github.com/lanshark/virtualenv-asdf
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# virtualenv-asdf
|
|
29
|
+
|
|
30
|
+
A [virtualenv][virtualenv] Python discovery plugin using [asdf][asdf]
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
```shell
|
|
35
|
+
pip install virtualenv-asdf
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Usage
|
|
39
|
+
|
|
40
|
+
The Python discovery mechanism can be specified by:
|
|
41
|
+
|
|
42
|
+
* the CLI option `--discovery`:
|
|
43
|
+
```shell
|
|
44
|
+
virtualenv --discovery asdf -p 3.10 testenv
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
* the environment variable `VIRTUALENV_DISCOVERY`:
|
|
48
|
+
```shell
|
|
49
|
+
export VIRTUALENV_DISCOVERY=asdf
|
|
50
|
+
virtualenv -p 3.10 testenv
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
* the [config][virtualenv-docs-config-file] option `discovery`:
|
|
54
|
+
```ini
|
|
55
|
+
[virtualenv]
|
|
56
|
+
discovery = asdf
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
```shell
|
|
60
|
+
virtualenv asdf -p 3.10 testenv
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The Python version can be expressed using either 2 or 3 version segments:
|
|
64
|
+
|
|
65
|
+
* `-p 3.9`
|
|
66
|
+
* `-p 3.9.3`
|
|
67
|
+
|
|
68
|
+
In the former case, the latest version found will be used.
|
|
69
|
+
|
|
70
|
+
## Limitations
|
|
71
|
+
|
|
72
|
+
Only CPython is supported at the moment.
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
NOTE: this package derived from [virtualenv-pyenv][virtualenv-pyenv] by un.def
|
|
76
|
+
|
|
77
|
+
[virtualenv]: https://virtualenv.pypa.io/
|
|
78
|
+
[asdf]: https://github.com/asdf-vm/asdf
|
|
79
|
+
[virtualenv-docs-config-file]: https://virtualenv.pypa.io/en/latest/cli_interface.html#configuration-file
|
|
80
|
+
[virtualenv-pyenv]: https://github.com:/un-def/virtualenv-pyenv
|
|
81
|
+
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# virtualenv-asdf
|
|
2
|
+
|
|
3
|
+
A [virtualenv][virtualenv] Python discovery plugin using [asdf][asdf]
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```shell
|
|
8
|
+
pip install virtualenv-asdf
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
The Python discovery mechanism can be specified by:
|
|
14
|
+
|
|
15
|
+
* the CLI option `--discovery`:
|
|
16
|
+
```shell
|
|
17
|
+
virtualenv --discovery asdf -p 3.10 testenv
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
* the environment variable `VIRTUALENV_DISCOVERY`:
|
|
21
|
+
```shell
|
|
22
|
+
export VIRTUALENV_DISCOVERY=asdf
|
|
23
|
+
virtualenv -p 3.10 testenv
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
* the [config][virtualenv-docs-config-file] option `discovery`:
|
|
27
|
+
```ini
|
|
28
|
+
[virtualenv]
|
|
29
|
+
discovery = asdf
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
```shell
|
|
33
|
+
virtualenv asdf -p 3.10 testenv
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
The Python version can be expressed using either 2 or 3 version segments:
|
|
37
|
+
|
|
38
|
+
* `-p 3.9`
|
|
39
|
+
* `-p 3.9.3`
|
|
40
|
+
|
|
41
|
+
In the former case, the latest version found will be used.
|
|
42
|
+
|
|
43
|
+
## Limitations
|
|
44
|
+
|
|
45
|
+
Only CPython is supported at the moment.
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
NOTE: this package derived from [virtualenv-pyenv][virtualenv-pyenv] by un.def
|
|
49
|
+
|
|
50
|
+
[virtualenv]: https://virtualenv.pypa.io/
|
|
51
|
+
[asdf]: https://github.com/asdf-vm/asdf
|
|
52
|
+
[virtualenv-docs-config-file]: https://virtualenv.pypa.io/en/latest/cli_interface.html#configuration-file
|
|
53
|
+
[virtualenv-pyenv]: https://github.com:/un-def/virtualenv-pyenv
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ['poetry-core']
|
|
3
|
+
build-backend = 'poetry.core.masonry.api'
|
|
4
|
+
|
|
5
|
+
[tool.poetry]
|
|
6
|
+
name = 'virtualenv-asdf'
|
|
7
|
+
version = '0.1.0'
|
|
8
|
+
description = 'A virtualenv Python discovery plugin using asdf'
|
|
9
|
+
license = 'MIT'
|
|
10
|
+
authors = ['Scott Sharkey <ssharkey@lanshark.com>']
|
|
11
|
+
readme = 'README.md'
|
|
12
|
+
homepage = 'https://github.com/lanshark/virtualenv-asdf'
|
|
13
|
+
repository = 'https://github.com/lanshark/virtualenv-asdf'
|
|
14
|
+
keywords = ['virtualenv', 'asdf']
|
|
15
|
+
classifiers = [
|
|
16
|
+
'Development Status :: 4 - Beta',
|
|
17
|
+
'Intended Audience :: Developers',
|
|
18
|
+
'Topic :: Software Development :: Libraries',
|
|
19
|
+
'Topic :: Software Development :: Testing',
|
|
20
|
+
'Topic :: Utilities',
|
|
21
|
+
]
|
|
22
|
+
packages = [{include = '_virtualenv_asdf', from = 'src'}]
|
|
23
|
+
|
|
24
|
+
[tool.poetry.plugins.'virtualenv.discovery']
|
|
25
|
+
asdf = '_virtualenv_asdf.discovery:ASDF'
|
|
26
|
+
|
|
27
|
+
[tool.poetry.dependencies]
|
|
28
|
+
python = '^3.7'
|
|
29
|
+
virtualenv = '*'
|
|
30
|
+
asdf-inspect = '~0.1'
|
|
31
|
+
|
|
32
|
+
[tool.isort]
|
|
33
|
+
lines_after_imports = 2
|
|
34
|
+
multi_line_output = 5
|
|
35
|
+
include_trailing_comma = true
|
|
36
|
+
use_parentheses = true
|
|
37
|
+
known_first_party = ['_virtualenv_asdf']
|
|
38
|
+
known_third_party = ['virtualenv', 'asdf_inspect']
|
|
39
|
+
|
|
40
|
+
[tool.pytest.ini_options]
|
|
41
|
+
minversion = '7.0'
|
|
42
|
+
testpaths = ['tests']
|
|
43
|
+
|
|
44
|
+
[tool.tox]
|
|
45
|
+
legacy_tox_ini = '''
|
|
46
|
+
[tox]
|
|
47
|
+
envlist =
|
|
48
|
+
py37
|
|
49
|
+
py38
|
|
50
|
+
py39
|
|
51
|
+
py310
|
|
52
|
+
py311
|
|
53
|
+
flake8
|
|
54
|
+
isort
|
|
55
|
+
isolated_build = true
|
|
56
|
+
|
|
57
|
+
[testenv]
|
|
58
|
+
deps =
|
|
59
|
+
pytest
|
|
60
|
+
pytest-mock
|
|
61
|
+
commands = pytest {posargs}
|
|
62
|
+
|
|
63
|
+
[testenv:flake8]
|
|
64
|
+
skip_install = true
|
|
65
|
+
deps = flake8
|
|
66
|
+
commands = flake8 {posargs}
|
|
67
|
+
|
|
68
|
+
[testenv:isort]
|
|
69
|
+
skip_install = true
|
|
70
|
+
deps = isort
|
|
71
|
+
commands = isort {posargs:. -c}
|
|
72
|
+
'''
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from setuptools import setup
|
|
3
|
+
|
|
4
|
+
package_dir = \
|
|
5
|
+
{'': 'src'}
|
|
6
|
+
|
|
7
|
+
packages = \
|
|
8
|
+
['_virtualenv_asdf']
|
|
9
|
+
|
|
10
|
+
package_data = \
|
|
11
|
+
{'': ['*']}
|
|
12
|
+
|
|
13
|
+
install_requires = \
|
|
14
|
+
['asdf-inspect>=0.1,<0.2', 'virtualenv']
|
|
15
|
+
|
|
16
|
+
entry_points = \
|
|
17
|
+
{'virtualenv.discovery': ['asdf = _virtualenv_asdf.discovery:ASDF']}
|
|
18
|
+
|
|
19
|
+
setup_kwargs = {
|
|
20
|
+
'name': 'virtualenv-asdf',
|
|
21
|
+
'version': '0.1.0',
|
|
22
|
+
'description': 'A virtualenv Python discovery plugin using asdf',
|
|
23
|
+
'long_description': '# virtualenv-asdf\n\nA [virtualenv][virtualenv] Python discovery plugin using [asdf][asdf]\n\n## Installation\n\n```shell\npip install virtualenv-asdf\n```\n\n## Usage\n\nThe Python discovery mechanism can be specified by:\n\n* the CLI option `--discovery`:\n ```shell\n virtualenv --discovery asdf -p 3.10 testenv\n ```\n\n* the environment variable `VIRTUALENV_DISCOVERY`:\n ```shell\n export VIRTUALENV_DISCOVERY=asdf\n virtualenv -p 3.10 testenv\n ```\n\n* the [config][virtualenv-docs-config-file] option `discovery`:\n ```ini\n [virtualenv]\n discovery = asdf\n ```\n\n ```shell\n virtualenv asdf -p 3.10 testenv\n ```\n\nThe Python version can be expressed using either 2 or 3 version segments:\n\n* `-p 3.9`\n* `-p 3.9.3`\n\nIn the former case, the latest version found will be used.\n\n## Limitations\n\nOnly CPython is supported at the moment.\n\n\nNOTE: this package derived from [virtualenv-pyenv][virtualenv-pyenv] by un.def\n\n[virtualenv]: https://virtualenv.pypa.io/\n[asdf]: https://github.com/asdf-vm/asdf\n[virtualenv-docs-config-file]: https://virtualenv.pypa.io/en/latest/cli_interface.html#configuration-file\n[virtualenv-pyenv]: https://github.com:/un-def/virtualenv-pyenv\n',
|
|
24
|
+
'author': 'Scott Sharkey',
|
|
25
|
+
'author_email': 'ssharkey@lanshark.com',
|
|
26
|
+
'maintainer': 'None',
|
|
27
|
+
'maintainer_email': 'None',
|
|
28
|
+
'url': 'https://github.com/lanshark/virtualenv-asdf',
|
|
29
|
+
'package_dir': package_dir,
|
|
30
|
+
'packages': packages,
|
|
31
|
+
'package_data': package_data,
|
|
32
|
+
'install_requires': install_requires,
|
|
33
|
+
'entry_points': entry_points,
|
|
34
|
+
'python_requires': '>=3.7,<4.0',
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
setup(**setup_kwargs)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '0.1.0'
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from typing import List, Optional
|
|
5
|
+
|
|
6
|
+
from asdf_inspect import find_asdf_python_executable
|
|
7
|
+
from asdf_inspect.exceptions import SpecParseError, UnsupportedImplementation
|
|
8
|
+
from virtualenv.discovery.discover import Discover
|
|
9
|
+
from virtualenv.discovery.py_info import PythonInfo
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ASDF(Discover):
|
|
13
|
+
"""asdf discovery mechanism"""
|
|
14
|
+
|
|
15
|
+
def __init__(self, options) -> None:
|
|
16
|
+
super().__init__(options)
|
|
17
|
+
self._string_specs: List[str] = options.python
|
|
18
|
+
self._app_data = options.app_data
|
|
19
|
+
|
|
20
|
+
def __str__(self) -> str:
|
|
21
|
+
if len(self._string_specs) == 1:
|
|
22
|
+
spec = self._string_specs[0]
|
|
23
|
+
else:
|
|
24
|
+
spec = self._string_specs
|
|
25
|
+
return f'{self.__class__.__name__} discover of spec={spec!r}'
|
|
26
|
+
|
|
27
|
+
@classmethod
|
|
28
|
+
def add_parser_arguments(cls, parser) -> None:
|
|
29
|
+
parser.add_argument(
|
|
30
|
+
'-p',
|
|
31
|
+
'--python',
|
|
32
|
+
metavar='py',
|
|
33
|
+
type=str,
|
|
34
|
+
action='append',
|
|
35
|
+
required=True,
|
|
36
|
+
help='interpreter based on what to create environment',
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
def run(self) -> Optional[PythonInfo]:
|
|
40
|
+
for string_spec in self._string_specs:
|
|
41
|
+
result = self._get_interpreter(string_spec)
|
|
42
|
+
if result is not None:
|
|
43
|
+
return result
|
|
44
|
+
return None
|
|
45
|
+
|
|
46
|
+
def _get_interpreter(self, string_spec: str) -> Optional[PythonInfo]:
|
|
47
|
+
logging.debug('find interpreter for spec %s', string_spec)
|
|
48
|
+
try:
|
|
49
|
+
exec_path = find_asdf_python_executable(string_spec)
|
|
50
|
+
except SpecParseError:
|
|
51
|
+
logging.error('failed to parse spec %s', string_spec)
|
|
52
|
+
return None
|
|
53
|
+
except UnsupportedImplementation:
|
|
54
|
+
logging.error('only CPython is currently supported')
|
|
55
|
+
return None
|
|
56
|
+
if exec_path is None:
|
|
57
|
+
return None
|
|
58
|
+
return PythonInfo.from_exe(
|
|
59
|
+
str(exec_path), app_data=self._app_data, env=self._env)
|