certbot/letstest/scripts/version.py
ohemorange 16f858547f
Add --use-pep517 flag to pip to silence warning in tools/venv.py, and switch codebase to src-layout (#10249)
Fixes #10252.

See further discussion here: https://github.com/pypa/pip/issues/11457

We are doing option:

> Alternatively, enable the --use-pep517 pip option, possibly with
--no-build-isolation. The --use-pip517 flag will force pip to use the
modern mechanism for editable installs. --no-build-isolation may be
needed if your project has build-time requirements beyond setuptools and
wheel. By passing this flag, you are responsible for making sure your
environment already has the required dependencies to build your package.
Once the legacy mechanism is removed, --use-pep517 will have no effect
and will essentially be enabled by default in this context.

Major changes made here include:
- Add `--use-pep517` to use the modern mechanism, which will be the only
mechanism in future pip releases
- Change to `/src` layout to appease mypy, and because for editable
installs that really is the normal way these days.
  - `cd acme && mkdir src && mv acme src/` etc.
- add `where='src'` argument to `find_packages` and add
`package_dir={'': 'src'},` in `setup.py`s
  - update `MANIFEST.in` files with new path locations 
- Update our many hardcoded filepaths
- Update `importlib-metadata` requirement to fix
double-plugin-entry-point problem in oldest tests
2025-04-11 19:30:33 +00:00

32 lines
930 B
Python
Executable file

#!/usr/bin/env python
"""Get the current Certbot version number.
Provides a simple utility for determining the Certbot version number
"""
from __future__ import print_function
from os.path import abspath
from os.path import dirname
from os.path import join
import re
def certbot_version(letstest_scripts_dir):
"""Return the version number stamped in certbot/__init__.py."""
return re.search('''^__version__ = ['"](.+)['"].*''',
file_contents(join(dirname(dirname(letstest_scripts_dir)),
'certbot',
'src',
'certbot',
'__init__.py')),
re.M).group(1)
def file_contents(path):
with open(path) as file:
return file.read()
if __name__ == '__main__':
print(certbot_version(dirname(abspath(__file__))))