cmeel 0.41.0__tar.gz → 0.59.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.
- cmeel-0.59.0/.gitignore +2 -0
- {cmeel-0.41.0 → cmeel-0.59.0}/PKG-INFO +42 -39
- {cmeel-0.41.0 → cmeel-0.59.0}/README.md +29 -18
- cmeel-0.59.0/cmeel/__init__.py +6 -0
- {cmeel-0.41.0 → cmeel-0.59.0}/cmeel/__main__.py +20 -3
- cmeel-0.59.0/cmeel/backports.py +48 -0
- cmeel-0.59.0/cmeel/build.py +31 -0
- cmeel-0.41.0/cmeel/__init__.py → cmeel-0.59.0/cmeel/cmeel.py +2 -5
- {cmeel-0.41.0 → cmeel-0.59.0}/cmeel/config.py +44 -23
- cmeel-0.59.0/cmeel/consts.py +13 -0
- {cmeel-0.41.0 → cmeel-0.59.0}/cmeel/docker.py +21 -6
- cmeel-0.41.0/cmeel/helpers.py → cmeel-0.59.0/cmeel/env.py +1 -1
- cmeel-0.59.0/cmeel/impl.py +200 -0
- cmeel-0.59.0/cmeel/metadata.py +249 -0
- cmeel-0.59.0/cmeel/release.py +51 -0
- {cmeel-0.41.0 → cmeel-0.59.0}/cmeel/run.py +1 -0
- cmeel-0.59.0/cmeel/sdist.py +61 -0
- cmeel-0.59.0/cmeel/utils.py +231 -0
- cmeel-0.59.0/cmeel.pth +1 -0
- cmeel-0.59.0/cmeel_pth.py +20 -0
- cmeel-0.59.0/pyproject.toml +71 -0
- cmeel-0.41.0/cmeel/build.py +0 -408
- cmeel-0.41.0/cmeel/consts.py +0 -8
- cmeel-0.41.0/cmeel/pth.py +0 -12
- cmeel-0.41.0/cmeel.pth +0 -1
- cmeel-0.41.0/pyproject.toml +0 -60
- {cmeel-0.41.0 → cmeel-0.59.0}/LICENSE +0 -0
cmeel-0.59.0/.gitignore
ADDED
|
@@ -1,45 +1,39 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: cmeel
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.59.0
|
|
4
4
|
Summary: Create Wheel from CMake projects
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Author-email: guilhem.saurel@laas.fr
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
Project-URL: Changelog, https://github.com/cmake-wheel/cmeel/blob/main/CHANGELOG.md
|
|
6
|
+
Project-URL: Documentation, https://cmeel.readthedocs.io/
|
|
7
|
+
Project-URL: Homepage, https://github.com/cmake-wheel/cmeel
|
|
8
|
+
Author-email: Guilhem Saurel <guilhem.saurel@laas.fr>
|
|
9
|
+
License-Expression: BSD-2-Clause
|
|
10
|
+
License-File: LICENSE
|
|
11
11
|
Classifier: Operating System :: MacOS
|
|
12
12
|
Classifier: Operating System :: POSIX :: Linux
|
|
13
13
|
Classifier: Programming Language :: C++
|
|
14
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: Programming Language :: Python :: 3
|
|
21
15
|
Classifier: Topic :: Software Development :: Build Tools
|
|
22
16
|
Classifier: Topic :: System :: Archiving :: Packaging
|
|
23
17
|
Classifier: Topic :: System :: Software Distribution
|
|
18
|
+
Requires-Python: >=3.9
|
|
19
|
+
Requires-Dist: tomli>=2.1.0; python_full_version < '3.11'
|
|
24
20
|
Provides-Extra: build
|
|
25
|
-
Requires-Dist: cmake
|
|
26
|
-
Requires-Dist:
|
|
27
|
-
Requires-Dist: packaging
|
|
28
|
-
Requires-Dist:
|
|
29
|
-
Requires-Dist: wheel (>=0.38.4,<0.41.0) ; extra == "build"
|
|
30
|
-
Project-URL: Documentation, https://cmeel.readthedocs.io/
|
|
31
|
-
Project-URL: changelog, https://github.com/cmake-wheel/cmeel/blob/main/CHANGELOG.md
|
|
21
|
+
Requires-Dist: cmake>=3.31.2; extra == 'build'
|
|
22
|
+
Requires-Dist: git-archive-all; extra == 'build'
|
|
23
|
+
Requires-Dist: packaging>=24.2; extra == 'build'
|
|
24
|
+
Requires-Dist: wheel>=0.45.1; extra == 'build'
|
|
32
25
|
Description-Content-Type: text/markdown
|
|
33
26
|
|
|
34
|
-
# CMake Wheel
|
|
27
|
+
# CMake Wheel: cmeel
|
|
35
28
|
|
|
36
29
|
[](https://pypi.org/project/cmeel)
|
|
37
30
|
[](https://results.pre-commit.ci/latest/github/cmake-wheel/cmeel/main)
|
|
38
31
|
[](https://cmeel.readthedocs.io/en/latest/?badge=latest)
|
|
39
|
-
|
|
32
|
+
|
|
40
33
|
[](https://github.com/charliermarsh/ruff)
|
|
34
|
+
[](https://github.com/astral-sh/uv)
|
|
41
35
|
|
|
42
|
-
Wheel build backend using CMake, to package
|
|
36
|
+
Wheel build backend using CMake, to package any CMake project with pip and distribute on PyPI.
|
|
43
37
|
|
|
44
38
|
Following those relevant PEPs:
|
|
45
39
|
- [PEP 427](https://peps.python.org/pep-0427/), The Wheel Binary Package Format 1.0
|
|
@@ -47,7 +41,7 @@ Following those relevant PEPs:
|
|
|
47
41
|
- [PEP 518](https://peps.python.org/pep-0518/), Specifying Minimum Build System Requirements for Python Projects
|
|
48
42
|
- [PEP 600](https://peps.python.org/pep-0600/), Future ‘manylinux’ Platform Tags for Portable Linux Built Distributions
|
|
49
43
|
- [PEP 621](https://peps.python.org/pep-0621/), Storing project metadata in pyproject.toml
|
|
50
|
-
- [PEP 639](https://peps.python.org/pep-0639/), Improving License Clarity with Better Package Metadata
|
|
44
|
+
- [PEP 639](https://peps.python.org/pep-0639/), Improving License Clarity with Better Package Metadata
|
|
51
45
|
- [PEP 660](https://peps.python.org/pep-0660/), Editable installs for pyproject.toml based builds (wheel based)
|
|
52
46
|
|
|
53
47
|
## Chat
|
|
@@ -56,37 +50,46 @@ https://matrix.to/#/#cmake-wheel:matrix.org
|
|
|
56
50
|
|
|
57
51
|
## Basic idea
|
|
58
52
|
|
|
59
|
-
Glue between PEP 517
|
|
60
|
-
|
|
61
|
-
This Install in `${PYTHON_SITELIB}/cmeel.prefix/`:
|
|
53
|
+
Glue between PEP 517 & 660 entry points and modern CMake standard project configuration / build / test / install, and
|
|
54
|
+
install in `${PYTHON_SITELIB}/cmeel.prefix/`:
|
|
62
55
|
- As there is a dot, it is not a valid python module name, so no risk of importing anything there by mistake
|
|
63
56
|
- Play well with others, as everything is confined to `${PYTHON_SITELIB}/cmeel.prefix`
|
|
64
57
|
- `${PYTHON_SITELIB}/cmeel.pth` automatically load `${PYTHON_SITELIB}/cmeel.prefix/${PYTHON_SITELIB}`, so python
|
|
65
58
|
packages work out of the box
|
|
66
59
|
- Existing `${PYTHON_SITELIB}/cmeel.prefix` are automatically added to `$CMAKE_PREFIX_PATH`, so we can build CMake
|
|
67
|
-
packages whose dependencies are provided by other
|
|
68
|
-
- Stuff in `${PYTHON_SITELIB}/cmeel.prefix/bin` is exposed via `cmeel.run:cmeel_run
|
|
60
|
+
packages whose dependencies are provided by other packages installed with cmeel
|
|
61
|
+
- Stuff in `${PYTHON_SITELIB}/cmeel.prefix/bin` is exposed via `cmeel.run:cmeel_run`, or copied if start with a shebang
|
|
69
62
|
|
|
70
63
|
## Basic pyproject.toml example
|
|
71
64
|
|
|
72
65
|
extract from https://github.com/cmake-wheel/cmeel-example/blob/main/pyproject.toml:
|
|
73
66
|
|
|
74
67
|
```toml
|
|
68
|
+
[build-system]
|
|
69
|
+
build-backend = "cmeel"
|
|
70
|
+
requires = ["cmeel[build]"]
|
|
71
|
+
|
|
75
72
|
[project]
|
|
76
|
-
name = "
|
|
77
|
-
version = "0.4.12"
|
|
73
|
+
authors = [{email = "guilhem.saurel@laas.fr", name = "Guilhem Saurel"}]
|
|
78
74
|
description = "This is an example project, to show how to use cmeel"
|
|
79
|
-
requires-python = ">= 3.7"
|
|
80
75
|
license = "BSD-2-Clause"
|
|
81
|
-
|
|
76
|
+
name = "cmeel-example"
|
|
77
|
+
requires-python = ">= 3.8"
|
|
78
|
+
version = "0.7.0"
|
|
82
79
|
|
|
83
80
|
[project.urls]
|
|
81
|
+
changelog = "https://github.com/cmake-wheel/cmeel-example/blob/main/CHANGELOG.md"
|
|
84
82
|
homepage = "https://github.com/cmake-wheel/cmeel-example"
|
|
85
83
|
repository = "https://github.com/cmake-wheel/cmeel-example.git"
|
|
86
|
-
changelog = "https://github.com/cmake-wheel/cmeel-example/blob/main/CHANGELOG.md"
|
|
87
|
-
|
|
88
|
-
[build-system]
|
|
89
|
-
requires = ["cmeel[build]"]
|
|
90
|
-
build-backend = "cmeel.build"
|
|
91
84
|
```
|
|
92
85
|
|
|
86
|
+
Complete specification is available at:
|
|
87
|
+
https://packaging.python.org/en/latest/specifications/declaring-project-metadata
|
|
88
|
+
|
|
89
|
+
## Install
|
|
90
|
+
|
|
91
|
+
If you want to use the helpers provided by cmeel, to *eg*. test building a project in a manylinux container with
|
|
92
|
+
`cmeel docker`, the best way to install cmeel is to use pipx: `pipx install cmeel`
|
|
93
|
+
|
|
94
|
+
Otherwise, if you just want to use the build backend, there is no need to install anything: your frontent (*eg.* `pip`)
|
|
95
|
+
should do this for you
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
# CMake Wheel
|
|
1
|
+
# CMake Wheel: cmeel
|
|
2
2
|
|
|
3
3
|
[](https://pypi.org/project/cmeel)
|
|
4
4
|
[](https://results.pre-commit.ci/latest/github/cmake-wheel/cmeel/main)
|
|
5
5
|
[](https://cmeel.readthedocs.io/en/latest/?badge=latest)
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
[](https://github.com/charliermarsh/ruff)
|
|
8
|
+
[](https://github.com/astral-sh/uv)
|
|
8
9
|
|
|
9
|
-
Wheel build backend using CMake, to package
|
|
10
|
+
Wheel build backend using CMake, to package any CMake project with pip and distribute on PyPI.
|
|
10
11
|
|
|
11
12
|
Following those relevant PEPs:
|
|
12
13
|
- [PEP 427](https://peps.python.org/pep-0427/), The Wheel Binary Package Format 1.0
|
|
@@ -14,7 +15,7 @@ Following those relevant PEPs:
|
|
|
14
15
|
- [PEP 518](https://peps.python.org/pep-0518/), Specifying Minimum Build System Requirements for Python Projects
|
|
15
16
|
- [PEP 600](https://peps.python.org/pep-0600/), Future ‘manylinux’ Platform Tags for Portable Linux Built Distributions
|
|
16
17
|
- [PEP 621](https://peps.python.org/pep-0621/), Storing project metadata in pyproject.toml
|
|
17
|
-
- [PEP 639](https://peps.python.org/pep-0639/), Improving License Clarity with Better Package Metadata
|
|
18
|
+
- [PEP 639](https://peps.python.org/pep-0639/), Improving License Clarity with Better Package Metadata
|
|
18
19
|
- [PEP 660](https://peps.python.org/pep-0660/), Editable installs for pyproject.toml based builds (wheel based)
|
|
19
20
|
|
|
20
21
|
## Chat
|
|
@@ -23,36 +24,46 @@ https://matrix.to/#/#cmake-wheel:matrix.org
|
|
|
23
24
|
|
|
24
25
|
## Basic idea
|
|
25
26
|
|
|
26
|
-
Glue between PEP 517
|
|
27
|
-
|
|
28
|
-
This Install in `${PYTHON_SITELIB}/cmeel.prefix/`:
|
|
27
|
+
Glue between PEP 517 & 660 entry points and modern CMake standard project configuration / build / test / install, and
|
|
28
|
+
install in `${PYTHON_SITELIB}/cmeel.prefix/`:
|
|
29
29
|
- As there is a dot, it is not a valid python module name, so no risk of importing anything there by mistake
|
|
30
30
|
- Play well with others, as everything is confined to `${PYTHON_SITELIB}/cmeel.prefix`
|
|
31
31
|
- `${PYTHON_SITELIB}/cmeel.pth` automatically load `${PYTHON_SITELIB}/cmeel.prefix/${PYTHON_SITELIB}`, so python
|
|
32
32
|
packages work out of the box
|
|
33
33
|
- Existing `${PYTHON_SITELIB}/cmeel.prefix` are automatically added to `$CMAKE_PREFIX_PATH`, so we can build CMake
|
|
34
|
-
packages whose dependencies are provided by other
|
|
35
|
-
- Stuff in `${PYTHON_SITELIB}/cmeel.prefix/bin` is exposed via `cmeel.run:cmeel_run
|
|
34
|
+
packages whose dependencies are provided by other packages installed with cmeel
|
|
35
|
+
- Stuff in `${PYTHON_SITELIB}/cmeel.prefix/bin` is exposed via `cmeel.run:cmeel_run`, or copied if start with a shebang
|
|
36
36
|
|
|
37
37
|
## Basic pyproject.toml example
|
|
38
38
|
|
|
39
39
|
extract from https://github.com/cmake-wheel/cmeel-example/blob/main/pyproject.toml:
|
|
40
40
|
|
|
41
41
|
```toml
|
|
42
|
+
[build-system]
|
|
43
|
+
build-backend = "cmeel"
|
|
44
|
+
requires = ["cmeel[build]"]
|
|
45
|
+
|
|
42
46
|
[project]
|
|
43
|
-
name = "
|
|
44
|
-
version = "0.4.12"
|
|
47
|
+
authors = [{email = "guilhem.saurel@laas.fr", name = "Guilhem Saurel"}]
|
|
45
48
|
description = "This is an example project, to show how to use cmeel"
|
|
46
|
-
requires-python = ">= 3.7"
|
|
47
49
|
license = "BSD-2-Clause"
|
|
48
|
-
|
|
50
|
+
name = "cmeel-example"
|
|
51
|
+
requires-python = ">= 3.8"
|
|
52
|
+
version = "0.7.0"
|
|
49
53
|
|
|
50
54
|
[project.urls]
|
|
55
|
+
changelog = "https://github.com/cmake-wheel/cmeel-example/blob/main/CHANGELOG.md"
|
|
51
56
|
homepage = "https://github.com/cmake-wheel/cmeel-example"
|
|
52
57
|
repository = "https://github.com/cmake-wheel/cmeel-example.git"
|
|
53
|
-
changelog = "https://github.com/cmake-wheel/cmeel-example/blob/main/CHANGELOG.md"
|
|
54
|
-
|
|
55
|
-
[build-system]
|
|
56
|
-
requires = ["cmeel[build]"]
|
|
57
|
-
build-backend = "cmeel.build"
|
|
58
58
|
```
|
|
59
|
+
|
|
60
|
+
Complete specification is available at:
|
|
61
|
+
https://packaging.python.org/en/latest/specifications/declaring-project-metadata
|
|
62
|
+
|
|
63
|
+
## Install
|
|
64
|
+
|
|
65
|
+
If you want to use the helpers provided by cmeel, to *eg*. test building a project in a manylinux container with
|
|
66
|
+
`cmeel docker`, the best way to install cmeel is to use pipx: `pipx install cmeel`
|
|
67
|
+
|
|
68
|
+
Otherwise, if you just want to use the build backend, there is no need to install anything: your frontent (*eg.* `pip`)
|
|
69
|
+
should do this for you
|
|
@@ -6,8 +6,10 @@ import os
|
|
|
6
6
|
import pathlib
|
|
7
7
|
import sys
|
|
8
8
|
|
|
9
|
+
from . import __version__
|
|
9
10
|
from .docker import add_docker_arguments, docker_build
|
|
10
|
-
from .
|
|
11
|
+
from .env import add_paths_arguments, get_paths
|
|
12
|
+
from .release import add_release_arguments, release
|
|
11
13
|
|
|
12
14
|
LOG = logging.getLogger("cmeel")
|
|
13
15
|
|
|
@@ -22,7 +24,7 @@ def parse_args() -> argparse.Namespace:
|
|
|
22
24
|
|
|
23
25
|
parser = argparse.ArgumentParser(
|
|
24
26
|
prog=f"{python} -m cmeel",
|
|
25
|
-
description="cmeel
|
|
27
|
+
description="cmeel helpers",
|
|
26
28
|
)
|
|
27
29
|
parser.add_argument(
|
|
28
30
|
"-v",
|
|
@@ -39,6 +41,10 @@ def parse_args() -> argparse.Namespace:
|
|
|
39
41
|
|
|
40
42
|
add_paths_arguments(subparsers)
|
|
41
43
|
add_docker_arguments(subparsers)
|
|
44
|
+
add_release_arguments(subparsers)
|
|
45
|
+
|
|
46
|
+
ver = subparsers.add_parser("version", help="print current cmeel version.")
|
|
47
|
+
ver.set_defaults(cmd="version")
|
|
42
48
|
|
|
43
49
|
args = parser.parse_args()
|
|
44
50
|
|
|
@@ -48,6 +54,8 @@ def parse_args() -> argparse.Namespace:
|
|
|
48
54
|
level = 30 - 10 * args.verbose
|
|
49
55
|
logging.basicConfig(level=level)
|
|
50
56
|
|
|
57
|
+
LOG.debug("parsed arguments: %s", args)
|
|
58
|
+
|
|
51
59
|
if "cmd" in args:
|
|
52
60
|
LOG.debug("running subcommand %s", args.cmd)
|
|
53
61
|
return args
|
|
@@ -56,9 +64,18 @@ def parse_args() -> argparse.Namespace:
|
|
|
56
64
|
sys.exit(0)
|
|
57
65
|
|
|
58
66
|
|
|
59
|
-
|
|
67
|
+
def main():
|
|
68
|
+
"""Run helpers."""
|
|
60
69
|
args = parse_args()
|
|
61
70
|
if args.cmd == "docker":
|
|
62
71
|
docker_build(**vars(args))
|
|
72
|
+
elif args.cmd == "release":
|
|
73
|
+
release(**vars(args))
|
|
74
|
+
elif args.cmd == "version":
|
|
75
|
+
print(f"This is cmeel version {__version__}")
|
|
63
76
|
else:
|
|
64
77
|
print(get_paths(**vars(args)))
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
if __name__ == "__main__":
|
|
81
|
+
main()
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# ruff: noqa
|
|
2
|
+
|
|
3
|
+
try:
|
|
4
|
+
from argparse import BooleanOptionalAction # type: ignore
|
|
5
|
+
except ImportError:
|
|
6
|
+
# Python < 3.9
|
|
7
|
+
# https://github.com/python/cpython/blob/3.11/Lib/argparse.py#L885
|
|
8
|
+
|
|
9
|
+
from argparse import Action
|
|
10
|
+
|
|
11
|
+
class BooleanOptionalAction(Action): # type: ignore
|
|
12
|
+
def __init__(
|
|
13
|
+
self,
|
|
14
|
+
option_strings,
|
|
15
|
+
dest,
|
|
16
|
+
default=None,
|
|
17
|
+
type=None,
|
|
18
|
+
choices=None,
|
|
19
|
+
required=False,
|
|
20
|
+
help=None,
|
|
21
|
+
metavar=None,
|
|
22
|
+
):
|
|
23
|
+
_option_strings = []
|
|
24
|
+
for option_string in option_strings:
|
|
25
|
+
_option_strings.append(option_string)
|
|
26
|
+
|
|
27
|
+
if option_string.startswith("--"):
|
|
28
|
+
option_string = "--no-" + option_string[2:]
|
|
29
|
+
_option_strings.append(option_string)
|
|
30
|
+
|
|
31
|
+
super().__init__(
|
|
32
|
+
option_strings=_option_strings,
|
|
33
|
+
dest=dest,
|
|
34
|
+
nargs=0,
|
|
35
|
+
default=default,
|
|
36
|
+
type=type,
|
|
37
|
+
choices=choices,
|
|
38
|
+
required=required,
|
|
39
|
+
help=help,
|
|
40
|
+
metavar=metavar,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
def __call__(self, parser, namespace, values, option_string=None):
|
|
44
|
+
if option_string in self.option_strings:
|
|
45
|
+
setattr(namespace, self.dest, not option_string.startswith("--no-"))
|
|
46
|
+
|
|
47
|
+
def format_usage(self):
|
|
48
|
+
return " | ".join(self.option_strings)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""PEP 517 & 660 entry points."""
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
import os
|
|
5
|
+
|
|
6
|
+
from .impl import build_impl
|
|
7
|
+
from .sdist import sdist_impl
|
|
8
|
+
|
|
9
|
+
LOG = logging.getLogger("cmeel")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def build_editable(
|
|
13
|
+
wheel_directory,
|
|
14
|
+
config_settings=None,
|
|
15
|
+
metadata_directory=None,
|
|
16
|
+
) -> str:
|
|
17
|
+
"""Build an editable wheel: main entry point for PEP 660."""
|
|
18
|
+
LOG.info("cmeel build editable")
|
|
19
|
+
os.environ["CMAKE_INSTALL_MODE"] = "ABS_SYMLINK"
|
|
20
|
+
return build_impl(wheel_directory, editable=True)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def build_wheel(wheel_directory, config_settings=None, metadata_directory=None) -> str:
|
|
24
|
+
"""Build a binary wheel: main entry point for PEP 517."""
|
|
25
|
+
LOG.info("cmeel build wheel")
|
|
26
|
+
return build_impl(wheel_directory, editable=False)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def build_sdist(sdist_directory, config_settings=None) -> str:
|
|
30
|
+
"""Generate a gzipped distribution tarball."""
|
|
31
|
+
return sdist_impl(sdist_directory)
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
"""Cmeel
|
|
1
|
+
"""Cmeel metadata."""
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
from importlib.metadata import metadata
|
|
5
|
-
except ImportError: # Python < 3.8
|
|
6
|
-
from importlib_metadata import metadata # type: ignore
|
|
3
|
+
from importlib.metadata import metadata
|
|
7
4
|
|
|
8
5
|
__metadata__ = metadata("cmeel")
|
|
9
6
|
__project_name__ = __metadata__["name"]
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
"""Cmeel
|
|
2
|
-
|
|
1
|
+
"""Cmeel configuration.
|
|
2
|
+
|
|
3
|
+
Parse various configuration files and environment variables.
|
|
4
|
+
"""
|
|
5
|
+
|
|
3
6
|
import sys
|
|
7
|
+
from os import environ, pathsep
|
|
4
8
|
from pathlib import Path
|
|
5
9
|
from tempfile import TemporaryDirectory
|
|
6
|
-
from typing import Any,
|
|
10
|
+
from typing import Any, Optional, Union
|
|
7
11
|
|
|
8
|
-
|
|
12
|
+
try:
|
|
13
|
+
import tomllib # type: ignore
|
|
14
|
+
except ModuleNotFoundError:
|
|
15
|
+
import tomli as tomllib # type: ignore
|
|
9
16
|
|
|
10
17
|
from .consts import CMEEL_PREFIX, SITELIB
|
|
18
|
+
from .env import get_paths
|
|
11
19
|
|
|
12
20
|
|
|
13
21
|
class CmeelConfig:
|
|
@@ -16,18 +24,19 @@ class CmeelConfig:
|
|
|
16
24
|
def __init__(self) -> None:
|
|
17
25
|
"""Get config variables from environment, local, and global config files."""
|
|
18
26
|
config_home = Path("~/.config").expanduser()
|
|
19
|
-
config_home = Path(
|
|
27
|
+
config_home = Path(environ.get("XDG_CONFIG_HOME", config_home))
|
|
20
28
|
config_path = config_home / "cmeel"
|
|
21
29
|
config_file = config_path / "cmeel.toml"
|
|
22
30
|
|
|
23
31
|
self.conf = {}
|
|
24
32
|
if config_file.exists():
|
|
25
33
|
with config_file.open("rb") as f:
|
|
26
|
-
self.conf =
|
|
34
|
+
self.conf = tomllib.load(f)
|
|
27
35
|
if self.conf.get("default-env", True):
|
|
28
|
-
self.env =
|
|
36
|
+
self.env = environ.copy()
|
|
29
37
|
else:
|
|
30
|
-
self.env = {p:
|
|
38
|
+
self.env = {p: environ[p] for p in ["PATH", "PYTHONPATH"]}
|
|
39
|
+
self.env["CMEEL_BUILD"] = "1"
|
|
31
40
|
self.jobs = int(self.conf.get("jobs", self.env.get("CMEEL_JOBS", "4")))
|
|
32
41
|
self.test_jobs = self.conf.get(
|
|
33
42
|
"test-jobs",
|
|
@@ -49,53 +58,65 @@ class CmeelConfig:
|
|
|
49
58
|
|
|
50
59
|
def get_configure_args(
|
|
51
60
|
self,
|
|
52
|
-
conf:
|
|
61
|
+
conf: dict[str, Any],
|
|
53
62
|
install: Union[Path, str],
|
|
54
|
-
configure_args:
|
|
55
|
-
configure_env:
|
|
63
|
+
configure_args: list[str],
|
|
64
|
+
configure_env: dict[str, str],
|
|
56
65
|
run_tests: bool,
|
|
57
|
-
) ->
|
|
66
|
+
) -> list[str]:
|
|
58
67
|
"""Get CMake initial arguments."""
|
|
59
68
|
project = conf["name"]
|
|
60
|
-
build_testing:
|
|
69
|
+
build_testing: list[str] = [] if run_tests else ["-DBUILD_TESTING=OFF"]
|
|
61
70
|
ret = [
|
|
62
71
|
"-DBoost_NO_WARN_NEW_VERSIONS=ON",
|
|
63
72
|
"-DCMAKE_BUILD_TYPE=Release",
|
|
64
73
|
"-DCMAKE_INSTALL_LIBDIR=lib",
|
|
65
74
|
f"-DCMAKE_INSTALL_PREFIX={install}",
|
|
66
75
|
f"-DPYTHON_SITELIB={SITELIB}",
|
|
76
|
+
f"-DPython_EXECUTABLE={sys.executable}",
|
|
67
77
|
f"-DPython3_EXECUTABLE={sys.executable}",
|
|
68
78
|
"-DCMAKE_APPLE_SILICON_PROCESSOR=arm64",
|
|
79
|
+
f"-DCMEEL_JOBS={self.jobs}",
|
|
69
80
|
*build_testing,
|
|
70
81
|
*configure_args,
|
|
71
82
|
*self.conf.get("configure-args", []),
|
|
72
83
|
]
|
|
73
84
|
if project in self.conf:
|
|
74
85
|
ret += self.conf[project].get("configure-args", [])
|
|
75
|
-
if
|
|
86
|
+
if configure_env.get("CMEEL_CMAKE_ARGS"):
|
|
76
87
|
ret += configure_env["CMEEL_CMAKE_ARGS"].split()
|
|
77
88
|
return ret
|
|
78
89
|
|
|
79
|
-
def get_configure_env(self) ->
|
|
90
|
+
def get_configure_env(self) -> dict[str, str]:
|
|
80
91
|
"""Get CMake initial environment."""
|
|
81
92
|
ret = self.env.copy()
|
|
82
|
-
available
|
|
83
|
-
|
|
93
|
+
if available := self._get_available_prefix():
|
|
94
|
+
ret["CMEEL_AVAILABLE_PREFIX"] = str(available)
|
|
84
95
|
cpp = ret.get("CMAKE_PREFIX_PATH", "")
|
|
85
|
-
if available not in cpp.split(
|
|
86
|
-
ret["CMAKE_PREFIX_PATH"] = f"{available}
|
|
96
|
+
if str(available) not in cpp.split(pathsep):
|
|
97
|
+
ret["CMAKE_PREFIX_PATH"] = f"{available}{pathsep}{cpp}".strip(pathsep)
|
|
98
|
+
pcp = ret.get("PKG_CONFIG_PATH", "")
|
|
99
|
+
for subdir in ("lib", "share"):
|
|
100
|
+
lpcp = available / subdir / "pkgconfig"
|
|
101
|
+
if lpcp.is_dir() and str(lpcp) not in pcp.split(pathsep):
|
|
102
|
+
pcp = f"{lpcp}{pathsep}{pcp}"
|
|
103
|
+
ret["PKG_CONFIG_PATH"] = pcp.strip(pathsep)
|
|
87
104
|
return ret
|
|
88
105
|
|
|
89
|
-
def get_test_env(self) ->
|
|
106
|
+
def get_test_env(self) -> dict[str, str]:
|
|
90
107
|
"""Get test environment."""
|
|
91
108
|
ret = self.env.copy()
|
|
92
|
-
ret.update(
|
|
109
|
+
ret.update(
|
|
110
|
+
CTEST_OUTPUT_ON_FAILURE="1",
|
|
111
|
+
CTEST_PARALLEL_LEVEL=self.test_jobs,
|
|
112
|
+
LD_LIBRARY_PATH=get_paths("lib"),
|
|
113
|
+
)
|
|
93
114
|
return ret
|
|
94
115
|
|
|
95
|
-
def _get_available_prefix(self) -> Optional[
|
|
116
|
+
def _get_available_prefix(self) -> Optional[Path]:
|
|
96
117
|
for path in sys.path:
|
|
97
118
|
if CMEEL_PREFIX in path:
|
|
98
|
-
return
|
|
119
|
+
return Path(path).parent.parent.parent
|
|
99
120
|
return None
|
|
100
121
|
|
|
101
122
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Cmeel constants."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
# vvv Warning: keep sync with cmeel_pth.py
|
|
7
|
+
CMEEL_PREFIX = "cmeel.prefix"
|
|
8
|
+
SITELIB = os.path.join( # noqa: PTH118
|
|
9
|
+
"lib",
|
|
10
|
+
"python" + ".".join(sys.version.split(".")[:2]),
|
|
11
|
+
"site-packages",
|
|
12
|
+
)
|
|
13
|
+
# ^^^
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
"""Build a project with cmeel in a container."""
|
|
2
2
|
|
|
3
3
|
import logging
|
|
4
|
+
import os
|
|
4
5
|
import pathlib
|
|
5
6
|
from subprocess import check_call
|
|
6
|
-
from typing import
|
|
7
|
+
from typing import Optional
|
|
8
|
+
|
|
9
|
+
from .backports import BooleanOptionalAction
|
|
7
10
|
|
|
8
11
|
LOG = logging.getLogger("cmeel.docker")
|
|
9
12
|
|
|
@@ -20,7 +23,7 @@ def add_docker_arguments(subparsers):
|
|
|
20
23
|
sub.add_argument(
|
|
21
24
|
"-p",
|
|
22
25
|
"--python",
|
|
23
|
-
default="python3.
|
|
26
|
+
default="python3.13",
|
|
24
27
|
help="python interpreter inside that image",
|
|
25
28
|
)
|
|
26
29
|
sub.add_argument(
|
|
@@ -53,6 +56,12 @@ def add_docker_arguments(subparsers):
|
|
|
53
56
|
action="append",
|
|
54
57
|
help="pass environment variables to docker run",
|
|
55
58
|
)
|
|
59
|
+
sub.add_argument(
|
|
60
|
+
"--cmeel-env",
|
|
61
|
+
action=BooleanOptionalAction,
|
|
62
|
+
default=True,
|
|
63
|
+
help="forward 'CMEEL_*' environment variables to docker run",
|
|
64
|
+
)
|
|
56
65
|
sub.set_defaults(cmd="docker")
|
|
57
66
|
|
|
58
67
|
|
|
@@ -63,7 +72,8 @@ def docker_build(
|
|
|
63
72
|
cache: bool,
|
|
64
73
|
upgrade: bool,
|
|
65
74
|
cwd: str,
|
|
66
|
-
env:
|
|
75
|
+
env: Optional[list[str]],
|
|
76
|
+
cmeel_env: bool,
|
|
67
77
|
**kwargs,
|
|
68
78
|
):
|
|
69
79
|
"""Build a project with cmeel in a container."""
|
|
@@ -73,9 +83,14 @@ def docker_build(
|
|
|
73
83
|
check_call(pull)
|
|
74
84
|
|
|
75
85
|
volumes = ["-v", f"{cwd}/:/src"]
|
|
76
|
-
envs:
|
|
77
|
-
|
|
78
|
-
|
|
86
|
+
envs: list[str] = []
|
|
87
|
+
if env:
|
|
88
|
+
for e in env:
|
|
89
|
+
envs = [*envs, "-e", e]
|
|
90
|
+
if cmeel_env:
|
|
91
|
+
for e in os.environ:
|
|
92
|
+
if e.startswith("CMEEL_"):
|
|
93
|
+
envs = [*envs, "-e", e]
|
|
79
94
|
if cache:
|
|
80
95
|
volumes = [*volumes, "-v", "/root/.cache/pip:/root/.cache/pip"]
|
|
81
96
|
docker = ["docker", "run", "--rm", *envs, *volumes, "-w", "/src", "-t", image]
|
|
@@ -29,7 +29,7 @@ def get_paths(cmd: str, prepend: bool = False, **kwargs) -> str:
|
|
|
29
29
|
elif cmd == "pc":
|
|
30
30
|
prefixes = [p / sub / "pkgconfig" for p in prefixes for sub in ["lib", "share"]]
|
|
31
31
|
|
|
32
|
-
available = [str(p) for p in prefixes if p.
|
|
32
|
+
available = [str(p) for p in prefixes if p.is_dir()]
|
|
33
33
|
if prepend:
|
|
34
34
|
ret = []
|
|
35
35
|
for prefix in available + os.environ.get(PATHS[cmd], "").split(os.pathsep):
|