File size: 808 Bytes
b53ca97
 
725c510
0c0aff7
b53ca97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
725c510
b53ca97
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
import os

from setuptools import setup

if os.path.exists(".git"):
    kwargs = {
        "use_scm_version": {
            "write_to": "pysr/version.py",
        },
        "setup_requires": ["setuptools", "setuptools_scm"],
    }
else:
    # Read from pyproject.toml directly
    import re

    with open(os.path.join(os.path.dirname(__file__), "pyproject.toml")) as f:
        data = f.read()
        # Find the version
        version = re.search(r'version = "(.*)"', data).group(1)

    # Write the version to version.py
    with open(os.path.join(os.path.dirname(__file__), "pysr", "version.py"), "w") as f:
        f.write(f'__version__ = "{version}"')

    kwargs = {
        "use_scm_version": False,
        "version": version,
    }


# Build options are managed in pyproject.toml
setup(**kwargs)