pkgconf 2.4.3.post2__py3-none-win_arm64.whl

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.
Binary file
pkgconf/__init__.py ADDED
@@ -0,0 +1,150 @@
1
+ import logging
2
+ import operator
3
+ import os
4
+ import pathlib
5
+ import shlex
6
+ import shutil
7
+ import subprocess
8
+ import sys
9
+ import sysconfig
10
+ import warnings
11
+
12
+ from collections.abc import Sequence
13
+ from typing import Any, Optional
14
+
15
+
16
+ if sys.version_info >= (3, 10):
17
+ import importlib.metadata as importlib_metadata
18
+ else:
19
+ import importlib_metadata
20
+
21
+
22
+ __version__ = '2.4.3-2'
23
+
24
+
25
+ _LOGGER = logging.getLogger(__name__)
26
+
27
+
28
+ class PathWarning(Warning):
29
+ def __init__(self, message: str, entrypoint: importlib_metadata.EntryPoint) -> None:
30
+ self._message = message
31
+ self._entrypoint = entrypoint
32
+
33
+ def __str__(self) -> str:
34
+ return (
35
+ f'Skipping PKG_CONFIG_PATH entry: {self._message}'
36
+ f'- Entrypoint: {self._entrypoint}'
37
+ f'- Distribution: {self._distribution_info()}'
38
+ )
39
+
40
+ def _distribution_info(self) -> str:
41
+ info = f'{self._entrypoint.dist}-{self._entrypoint.dist.version}'
42
+ metadata_path = self._find_metadata_path()
43
+ if metadata_path:
44
+ info += f' at {metadata_path!r}'
45
+ return info
46
+
47
+ def _find_metadata_path(self) -> Optional[str]:
48
+ try:
49
+ dist_root = self._entrypoint.dist.locate_file('')
50
+ except NotImplementedError:
51
+ return None
52
+
53
+ for file in self._entrypoint.dist.files() or []:
54
+ if file.parts[0].endswith('.dist-info'):
55
+ return str(dist_root / file.parts[0])
56
+ return None
57
+
58
+
59
+ def _get_system_executable() -> Optional[pathlib.Path]:
60
+ if os.environ.get('PKGCONF_PYPI_EMBEDDED_ONLY'):
61
+ return None
62
+
63
+ scripts = sysconfig.get_path('scripts')
64
+ path_list = os.environ.get('PATH', os.defpath).split(os.pathsep)
65
+ if scripts in path_list:
66
+ path_list.remove(scripts)
67
+ path = os.pathsep.join(path_list)
68
+
69
+ executable = shutil.which('pkgconf', path=path) or shutil.which('pkg-config', path=path)
70
+ if executable:
71
+ return pathlib.Path(executable)
72
+ return None
73
+
74
+
75
+ def get_executable() -> pathlib.Path:
76
+ """Get the pkgconf executable."""
77
+ if os.name == 'posix':
78
+ executable_name = 'pkgconf'
79
+ elif os.name == 'nt':
80
+ executable_name = 'pkgconf.EXE'
81
+ else:
82
+ raise NotImplementedError
83
+
84
+ for path in __path__:
85
+ executable = pathlib.Path(path) / '.bin' / executable_name
86
+ if executable.exists():
87
+ return executable
88
+
89
+ warnings.warn('Bundled pkgconf not found, using the system executable', stacklevel=2)
90
+ executable = _get_system_executable()
91
+ if executable:
92
+ return executable
93
+
94
+ msg = 'No pkgconf/pkg-config executable available'
95
+ raise RuntimeError(msg)
96
+
97
+
98
+ def _find_entrypoints() -> Sequence[importlib_metadata.EntryPoint]:
99
+ """Return the list of pkg_config entrypoints sorted by name."""
100
+ entrypoints = importlib_metadata.entry_points(group='pkg_config')
101
+ return sorted(entrypoints, key=operator.attrgetter('name'))
102
+
103
+
104
+ def _resolve_entrypoint_path(entrypoint: importlib_metadata.EntryPoint) -> str:
105
+ """Return a filesystem path for module specified in the entrypoint.
106
+
107
+ XXX: This only considers files provided by the distribution that registered the entrypoint.
108
+ """
109
+ assert entrypoint.dist
110
+ subpath = pathlib.PurePath(*entrypoint.value.split('.'))
111
+ try:
112
+ module_path = entrypoint.dist.locate_file(subpath).resolve()
113
+ except NotImplementedError:
114
+ warnings.warn(
115
+ PathWarning(
116
+ 'Unable to resolve the file-system path for the entrypoint, '
117
+ f"as {entrypoint.dist} doesn't implement locate_file()"
118
+ ),
119
+ stacklevel=2,
120
+ )
121
+ return os.fspath(module_path)
122
+
123
+
124
+ def get_pkg_config_path() -> Sequence[str]:
125
+ """Calculate PKG_CONFIG_PATH for Python packages in the current environment.
126
+
127
+ Python packages may register a directory for their pkg-config files by
128
+ specifying a "pkg-config" entrypoint.
129
+
130
+ TODO: Document the entrypoint creation and point to that here.
131
+ [project.entry-points.pkg-config]
132
+ entrypoint-name = 'project.package'
133
+ """
134
+ return [_resolve_entrypoint_path(ep) for ep in _find_entrypoints()]
135
+
136
+
137
+ def run_pkgconf(*args: str, **subprocess_kwargs: Any) -> subprocess.CompletedProcess:
138
+ """Run the pkgconf executable.
139
+
140
+ :param args: Arguments to pass to the pkgconf call.
141
+ :param subprocess_kwargs: Keyword arguments to pass to the subprocess.run call.
142
+ """
143
+ env = os.environ.copy()
144
+ PKG_CONFIG_PATH = env.get('PKG_CONFIG_PATH', '').split(os.pathsep) + get_pkg_config_path()
145
+ PKG_CONFIG_PATH = list(dict.fromkeys(PKG_CONFIG_PATH)) # Remove duplicated entried
146
+ env['PKG_CONFIG_PATH'] = os.pathsep.join(PKG_CONFIG_PATH)
147
+ cmd = [os.fspath(get_executable()), *args]
148
+ _LOGGER.info('Running the Python pkgconf')
149
+ _LOGGER.info('$ ' + shlex.join(('PKG_CONFIG_PATH=' + shlex.quote(env['PKG_CONFIG_PATH']), *cmd)))
150
+ return subprocess.run(cmd, env=env, **subprocess_kwargs)
pkgconf/__main__.py ADDED
@@ -0,0 +1,121 @@
1
+ import logging
2
+ import os
3
+ import shlex
4
+ import subprocess
5
+ import sys
6
+ import sysconfig
7
+ import warnings
8
+
9
+ from typing import Optional, TextIO, Union
10
+
11
+ import pkgconf
12
+
13
+
14
+ _LOGGER = logging.getLogger(__name__)
15
+
16
+
17
+ def main() -> None:
18
+ args = sys.argv[1:]
19
+
20
+ # If we find that we are calling ourselves, exit immediately
21
+ if os.environ.get('PKGCONF_PYPI_RECURSIVE') == __file__:
22
+ _LOGGER.info('Giving up, pkgconf recursion loop detected')
23
+ sys.exit(1)
24
+
25
+ os.environ['PKGCONF_PYPI_RECURSIVE'] = __file__
26
+ returncode = 1
27
+ try:
28
+ returncode = pkgconf.run_pkgconf(*args, check=True).returncode
29
+ except subprocess.SubprocessError as e:
30
+ # If our pkgconf lookup fails, fallback to the system pkgconf/pkg-config.
31
+ # For simplicity, the previous call will output to stdout/stderr
32
+ # regardless of its success, since capturing stdout/stderr in order to
33
+ # replay is tricky. If the fallback path triggers, it will also output
34
+ # to stdout/stderr, meaning we will have the output of both process
35
+ # calls. While a bit unexpected, I believe this is the best option for
36
+ # debugging.
37
+ system_executable = pkgconf._get_system_executable()
38
+ if system_executable:
39
+ cmd = [os.fspath(system_executable), *args]
40
+ _LOGGER.info(f'Running the system {system_executable.name}')
41
+ _LOGGER.info('$ ' + shlex.join(cmd))
42
+ returncode = subprocess.run(cmd).returncode
43
+ elif isinstance(e, subprocess.CalledProcessError):
44
+ returncode = e.returncode
45
+
46
+ sys.exit(returncode)
47
+
48
+
49
+ def _venv_paths(config_vars: dict[str, str]) -> str:
50
+ if 'venv' in sysconfig.get_scheme_names():
51
+ return sysconfig.get_paths('venv', vars=config_vars)
52
+ return sysconfig.get_paths(vars=config_vars)
53
+
54
+
55
+ def _entrypoint():
56
+ # Since project.script entrypoints use an hardcoded interpreter path from
57
+ # the environment they were installed in, when stacking environments (eg.
58
+ # using venv's --system-site-packages option), the entrypoint will run in
59
+ # the base environment and, as such, it will not have access to the
60
+ # entrypoints from the "child" environment. Because of this, when a virtual
61
+ # environment is enabled, instead of running main() from this process, we
62
+ # will run 'python -m pkgconf', so that we have access to the full
63
+ # environment.
64
+ if 'VIRTUAL_ENV' in os.environ:
65
+ venv_vars = sysconfig.get_config_vars().copy()
66
+ venv_vars['base'] = venv_vars['platbase'] = os.environ['VIRTUAL_ENV']
67
+ scripts = _venv_paths(venv_vars)['scripts']
68
+ python_path = os.path.join(scripts, 'python')
69
+ process = subprocess.run([python_path, '-m', 'pkgconf', *sys.argv[1:]])
70
+ sys.exit(process.returncode)
71
+ else:
72
+ _setup_cli()
73
+ main()
74
+
75
+
76
+ def _use_colors() -> bool:
77
+ if 'NO_COLOR' in os.environ:
78
+ if 'FORCE_COLOR' in os.environ:
79
+ warnings.warn('Both NO_COLOR and FORCE_COLOR environment variables are set, disabling color', stacklevel=2)
80
+ return False
81
+ elif 'FORCE_COLOR' in os.environ or sys.stdout.isatty():
82
+ if os.name == 'nt':
83
+ try:
84
+ import colorama
85
+ except ModuleNotFoundError:
86
+ return False
87
+ colorama.init()
88
+ return True
89
+ return False
90
+
91
+
92
+ def _setup_cli():
93
+ if _use_colors():
94
+ dim = '\33[2m'
95
+ yellow = '\33[93m'
96
+ reset = '\33[0m'
97
+ else:
98
+ dim = yellow = reset = ''
99
+
100
+ logging.basicConfig(
101
+ stream=sys.stderr,
102
+ format=f'{dim}> %(message)s{reset}',
103
+ level=logging.INFO,
104
+ )
105
+
106
+ def _showwarning(
107
+ message: Union[Warning, str],
108
+ category: type[Warning],
109
+ filename: str,
110
+ lineno: int,
111
+ file: Optional[TextIO] = None,
112
+ line: Optional[str] = None,
113
+ ) -> None: # pragma: no cover
114
+ print(f'{yellow}WARNING{reset} {message}', file=sys.stderr)
115
+
116
+ warnings.showwarning = _showwarning
117
+
118
+
119
+ if __name__ == '__main__':
120
+ _setup_cli()
121
+ main()
pkgconf/diagnose.py ADDED
@@ -0,0 +1,22 @@
1
+ import os
2
+
3
+ import pkgconf
4
+
5
+
6
+ def report() -> None:
7
+ print(f'pkgconf executable: {pkgconf.get_executable()}')
8
+
9
+ print('entrypoints:')
10
+ for entrypoint in pkgconf._find_entrypoints():
11
+ print(f' {entrypoint.name}:')
12
+ print(f' value: {entrypoint.value}')
13
+ print(f' path: {pkgconf._resolve_entrypoint_path(entrypoint)}')
14
+
15
+ print(f'PKG_CONFIG_PATH: {os.pathsep.join(pkgconf.get_pkg_config_path())}')
16
+
17
+
18
+ if __name__ == '__main__':
19
+ try:
20
+ report()
21
+ except (KeyboardInterrupt, BrokenPipeError): # pragma: no cover
22
+ pass
pkgconf/py.typed ADDED
File without changes
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2024 pypackaging-native contributors
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the “Software”), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7
+ of the Software, and to permit persons to whom the Software is furnished to do
8
+ so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
@@ -0,0 +1,83 @@
1
+ Metadata-Version: 2.1
2
+ Name: pkgconf
3
+ Version: 2.4.3.post2
4
+ Summary: `pkgconf` is a program which helps with discovering library dependencies and configuring compiler and linker flags.
5
+ Author-Email: Ralf Gommers <ralf.gommers@gmail.com>, =?utf-8?q?Filipe_La=C3=ADns?= <lains@riseup.net>
6
+ License: Copyright (c) 2024 pypackaging-native contributors
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
9
+ this software and associated documentation files (the “Software”), to deal in
10
+ the Software without restriction, including without limitation the rights to
11
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12
+ of the Software, and to permit persons to whom the Software is furnished to do
13
+ so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in all
16
+ copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ SOFTWARE.
25
+
26
+ Classifier: Development Status :: 4 - Beta
27
+ Classifier: Intended Audience :: Developers
28
+ Classifier: License :: OSI Approved :: MIT License
29
+ Classifier: License :: OSI Approved :: ISC License (ISCL)
30
+ Classifier: Programming Language :: C
31
+ Classifier: Topic :: Software Development
32
+ Classifier: Operating System :: Microsoft :: Windows
33
+ Classifier: Operating System :: POSIX
34
+ Classifier: Operating System :: Unix
35
+ Classifier: Operating System :: MacOS
36
+ Project-URL: homepage, https://pkgconf-pypi.readthedocs.io/en/latest/
37
+ Project-URL: issues, https://github.com/pypackaging-native/pkgconf-pypi/issues
38
+ Project-URL: source, https://github.com/pypackaging-native/pkgconf-pypi
39
+ Requires-Python: >=3.9
40
+ Requires-Dist: colorama; os_name == "nt"
41
+ Requires-Dist: importlib_metadata; python_version < "3.10"
42
+ Provides-Extra: test
43
+ Requires-Dist: pytest; extra == "test"
44
+ Requires-Dist: pytest-cov>=5; extra == "test"
45
+ Requires-Dist: pytest-mock>=2; extra == "test"
46
+ Requires-Dist: pytest-order>=1; extra == "test"
47
+ Requires-Dist: pytest-github-actions-annotate-failures; extra == "test"
48
+ Requires-Dist: meson-python; extra == "test"
49
+ Requires-Dist: environment-helpers>=0.1.3; extra == "test"
50
+ Provides-Extra: docs
51
+ Requires-Dist: sphinx~=7.0; extra == "docs"
52
+ Requires-Dist: furo; extra == "docs"
53
+ Requires-Dist: sphinx-design; extra == "docs"
54
+ Description-Content-Type: text/markdown
55
+
56
+ # pkgconf-pypi
57
+
58
+ [![CI test](https://github.com/pypackaging-native/pkgconf-pypi/actions/workflows/test.yml/badge.svg)](https://github.com/pypackaging-native/pkgconf-pypi/actions/workflows/test.yml)
59
+ [![CI build](https://github.com/pypackaging-native/pkgconf-pypi/actions/workflows/build.yml/badge.svg)](https://github.com/pypackaging-native/pkgconf-pypi/actions/workflows/build.yml)
60
+ [![pre-commit.ci status](https://results.pre-commit.ci/badge/github/pypackaging-native/pkgconf-pypi/main.svg)](https://results.pre-commit.ci/latest/github/pypackaging-native/pkgconf-pypi/main)
61
+ [![codecov](https://codecov.io/gh/pypackaging-native/pkgconf-pypi/graph/badge.svg)](https://codecov.io/gh/pypackaging-native/pkgconf-pypi)
62
+
63
+ [![Documentation Status](https://readthedocs.org/projects/pkgconf-pypi/badge/?version=latest)](https://pkgconf-pypi.readthedocs.io/en/latest/?badge=latest)
64
+ [![PyPI version](https://badge.fury.io/py/pkgconf.svg)](https://pypi.org/project/pkgconf/)
65
+ [![Discord](https://img.shields.io/discord/803025117553754132?label=Discord%20chat%20pkgconf-pypi)](https://discord.gg/pypa)
66
+
67
+ This goal of this repo is to facility building and publishing of
68
+ [pkgconf](https://github.com/pkgconf/pkgconf) binaries on PyPI, primarily for
69
+ ease of installing in a cross-platform manner. This is useful when `pkgconf` is
70
+ for example needed in workflows of other Python packages.
71
+
72
+ ## Choices
73
+
74
+ The intent is to:
75
+
76
+ - distribute `pkgconf` without any modifications
77
+ - configure the build with no system directory
78
+ - install `pkg-config` as an alias in the scripts directory of the Python
79
+ environment
80
+
81
+ ## Links
82
+
83
+ Documentation: https://pkgconf-pypi.readthedocs.io
@@ -0,0 +1,10 @@
1
+ pkgconf-2.4.3.post2.dist-info/METADATA,sha256=eyvk4tXOLiYPYHNHu2uYKXHvosUj8xfzA8x3GvNO2DQ,4546
2
+ pkgconf-2.4.3.post2.dist-info/WHEEL,sha256=B3B4KN1DoTlWtNhRRRGkD-knxtCiXk730NQ8ihkn3eI,85
3
+ pkgconf-2.4.3.post2.dist-info/entry_points.txt,sha256=rqbdxRekoww-gAluYeeJvZ_y1v2Lz4Vn5txhiwhXsUM,100
4
+ pkgconf-2.4.3.post2.dist-info/LICENSE,sha256=ZkgDE-MK5aHoknemDQt1la7dQ91Mw6i5YRVW120ARTg,1102
5
+ pkgconf/.bin/pkgconf.exe,sha256=i2-rwUR4a2a2717ZOP4yelYKT0PzIjo2YoEreP4AnoU,86528
6
+ pkgconf/__init__.py,sha256=FUwhqiljnIzWIeyICov4n8Xg2AF-eEe1AE6d1EKqT7U,5071
7
+ pkgconf/__main__.py,sha256=0yaqleseScIlGtCMXO3YQNuczhFaC91c_6w8kQhCjCs,4161
8
+ pkgconf/diagnose.py,sha256=b8UX1QhUwHdhqPMjPvQ8-cUqeSONTen8pYRDrxmzYnY,592
9
+ pkgconf/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ pkgconf-2.4.3.post2.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: meson
3
+ Root-Is-Purelib: false
4
+ Tag: py3-none-linux_x86_64
@@ -0,0 +1,4 @@
1
+ [console_scripts]
2
+ pkg-config = pkgconf.__main__:_entrypoint
3
+ pkgconf = pkgconf.__main__:_entrypoint
4
+