-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsetup.py
More file actions
61 lines (54 loc) · 1.85 KB
/
setup.py
File metadata and controls
61 lines (54 loc) · 1.85 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Available at setup time due to pyproject.toml
from pybind11.setup_helpers import Pybind11Extension, build_ext
from setuptools import setup
import subprocess
from os import environ
try:
NIX_SYSTEM = environ["NIX_SYSTEM"]
except KeyError:
raise EnvironmentError(
"Please set NIX_SYSTEM environment variable"
# or someone tell me how i can extract this automatically
)
with open("VERSION", "r") as r:
__version__ = r.read().strip()
def get_nix_version():
version_string = subprocess.run(["pkg-config", "--modversion", "nix-store"], capture_output=True, text=True).stdout.strip("\n")
return tuple(map(int, (version_string.split("+")[0].split("."))))
nix_version = get_nix_version()
ext_modules = [
Pybind11Extension(
"nix_heuristic_gc.libnixstore_wrapper",
["src/main.cpp"],
libraries = [ "nixstore", "nixmain" ],
# Example: passing in the version to the compiled code
define_macros=[
("VERSION_INFO", __version__),
("NIX_SYSTEM", NIX_SYSTEM),
('NIX_VERSION_MINOR', nix_version[1]),
],
cxx_std = "23" if nix_version[1] >= 31 else "20",
),
]
setup(
name="nix-heuristic-gc",
version=__version__,
author="Robert Scott",
author_email="code@humanleg.org.uk",
url="https://github.com/risicle/nix-heuristic-gc",
description="A more discerning cousin of nix-collect-garbage",
long_description="",
packages=["nix_heuristic_gc"],
ext_modules=ext_modules,
extras_require={},
cmdclass={"build_ext": build_ext},
entry_points={
"console_scripts": ["nix-heuristic-gc=nix_heuristic_gc.__main__:main"],
},
zip_safe=False,
python_requires=">=3.8",
license="LGPL-2.1-or-later",
classifiers=[
"License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)",
],
)