|
1 | 1 | #!/usr/bin/env python3
|
2 | 2 | import re
|
3 | 3 | import sys
|
| 4 | +import tomllib |
4 | 5 | import pathlib
|
5 | 6 | from setuptools import find_packages, setup
|
6 | 7 |
|
|
13 | 14 |
|
14 | 15 |
|
15 | 16 | def get_description() -> str:
|
16 |
| - """ |
17 |
| - Read full description from 'README.md' |
18 |
| - :return: description |
19 |
| - :rtype: str |
20 |
| - """ |
21 | 17 | with open('README.md', 'r', encoding='utf-8') as f:
|
22 | 18 | return f.read()
|
23 | 19 |
|
24 | 20 |
|
25 |
| -def get_version() -> str: |
26 |
| - """ |
27 |
| - Read version |
28 |
| - :return: str |
29 |
| - """ |
30 |
| - txt = (WORK_DIR / 'pyproject.toml').read_text('utf-8') |
| 21 | +def get_meta_info() -> dict: |
31 | 22 | try:
|
32 |
| - return re.findall(r"^version = \"([^']+)\"\r?$", txt, re.M)[0] |
| 23 | + with open("pyproject.toml", "rb") as f: |
| 24 | + return tomllib.load(f) |
33 | 25 | except IndexError:
|
34 | 26 | raise RuntimeError('Unable to determine version.')
|
35 | 27 |
|
36 | 28 |
|
37 |
| -version = get_version() |
| 29 | +project_meta = get_meta_info() |
| 30 | +project_dir = project_meta["project"]["name"].replace("-", "_") |
| 31 | + |
38 | 32 |
|
39 | 33 | setup(
|
40 |
| - name='magic_config', |
41 |
| - version=version, |
42 |
| - license='MIT', |
43 |
| - author='Alexander Majorov', |
44 |
| - |
45 |
| - description=('Is a pretty simple library for working with configuration' |
46 |
| - ' files based on the .env files and environment variables' |
47 |
| - ), |
| 34 | + license="MIT", |
| 35 | + name=project_meta["project"]["name"], |
| 36 | + version=project_meta["project"]["version"], |
| 37 | + author=project_meta["project"]["authors"][0]["name"], |
| 38 | + author_email=project_meta["project"]["authors"][0]["email"], |
| 39 | + description=project_meta["project"]["description"], |
48 | 40 | long_description=get_description(),
|
49 | 41 | long_description_content_type="text/markdown",
|
50 | 42 | url='https://github.com/frontdevops/magic-config',
|
51 |
| - download_url=f"https://github.com/frontdevops/magic-config/archive/refs/tags/{version}.tar.gz", |
| 43 | + download_url=("https://github.com/frontdevops/magic-config/archive/refs/tags/" |
| 44 | + f'{project_meta["project"]["version"]}.tar.gz'), |
52 | 45 | project_urls={
|
53 | 46 | "Documentation": "https://github.com/frontdevops/magic-config/blob/main/README.md",
|
54 | 47 | "Source": "https://github.com/frontdevops/magic-config",
|
|
0 commit comments