-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
115 lines (103 loc) · 3.84 KB
/
setup.py
File metadata and controls
115 lines (103 loc) · 3.84 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/usr/bin/python3
#
# Copyright (C) 2022 Richard Preen <rpreen@gmail.com>
#
"""Python setup script for installing SUMiT."""
import os
import platform
import shutil
import subprocess
import sys
from pathlib import Path
from setuptools import Extension, find_packages, setup
from setuptools.command.build_ext import build_ext
class CMakeExtension(Extension):
"""Creates a CMake extension module."""
def __init__(self, name, sourcedir=""):
Extension.__init__(self, name, sources=[])
self.sourcedir = os.path.abspath(sourcedir)
class CMakeBuild(build_ext):
"""Builds CMake extension."""
def build_extension(self, ext):
self.announce("Configuring", level=3)
extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
if not extdir.endswith(os.path.sep):
extdir += os.path.sep
if not os.path.exists(self.build_temp):
os.makedirs(self.build_temp)
cmake_args = [
f"-DPYTHON_EXECUTABLE={sys.executable}",
"-DCMAKE_BUILD_TYPE=Release",
"-DCMAKE_CXX_COMPILER=g++",
"-DNATIVE_OPT=OFF",
]
build_args = [
"--config",
"Release",
]
if platform.system() == "Windows":
cmake_args += ["-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=" + extdir]
cmake_args += ["-GMinGW Makefiles"]
else:
cmake_args += ["-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=" + extdir]
build_args += ["-j4"]
subprocess.check_call(
["cmake", ext.sourcedir] + cmake_args, cwd=self.build_temp
)
self.announce("Building", level=3)
subprocess.check_call(
["cmake", "--build", "."] + build_args, cwd=self.build_temp
)
self.announce("Copying cell suppression tool", level=3)
path = "/sumit/cell_suppression_tool/"
exe = "cell_suppression_tool"
if platform.system() == "Windows":
exe += ".exe"
shutil.copy(self.build_temp + path + exe, self.build_lib + path)
self.announce("Copying cell suppression server", level=3)
path = "/sumit/sumit_server/"
exe = "cell_suppression_server.jar"
shutil.copy(self.build_temp + path + exe, self.build_lib + path)
this_directory = Path(__file__).parent
long_description = (this_directory / "README.md").read_text()
setup(
name="sumit",
version="1.0.0",
license="MIT",
maintainer="Jim Smith",
maintainer_email="james.smith@uwe.ac.uk",
description="SUMiT: Statistical Uncertainty Management Toolkit",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/AI-SDC/SUMiT",
packages=find_packages(),
# package_data={"cell_suppression_tool": ["tool"]},
ext_modules=[CMakeExtension("sumit/sumit")],
cmdclass={"build_ext": CMakeBuild},
zip_safe=False,
python_requires=">=3.8",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Programming Language :: C++",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Information Analysis",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows :: Windows 10",
"Operating System :: Microsoft :: Windows :: Windows 11",
],
keywords=[
"data-privacy",
"data-protection",
"privacy",
"privacy-tools",
"statistical-disclosure-control",
],
)