-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
34 lines (30 loc) · 1.02 KB
/
setup.py
File metadata and controls
34 lines (30 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import re
import os
from setuptools import setup, find_packages
import toml
def sync_version(directory,version):
furl = os.path.join(directory,'pyproject.toml')
with open(furl, 'r') as file:
data = toml.load(file)
data['project']['version'] = version
with open(furl, 'w') as file:
toml.dump(data, file)
def get_version():
"""
Reads the version string from the package __init__.py file.
"""
directory = os.path.abspath(os.path.dirname(__file__))
init_path = os.path.join(directory,'src','livedc', '__init__.py')
with open(init_path, 'r') as file:
version_file_contents = file.read()
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file_contents, re.M)
if version_match:
sync_version(directory,version_match.group(1))
return version_match.group(1)
raise RuntimeError("Unable to find version string.")
setup(
name='livedc',
version=get_version(),
package_dir={'': 'src'},
packages=find_packages(where='src'),
)