-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
60 lines (54 loc) · 1.99 KB
/
setup.py
File metadata and controls
60 lines (54 loc) · 1.99 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
import cython
import glob
import os
import shutil
import sys
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
from Cython.Build import cythonize
extension_modules = [
Extension ("zser.zser", ["zser/zser.pyx"], depends = ["zser/zser.pxd"])
]
include_dirs = os.environ.get("CYTHON_INCLUDE_DIRS", ".").split (":")
base_path = os.path.dirname (__file__)
with open (os.path.join (base_path, "VERSION")) as version:
VERSION = version.read().rstrip ()
with open (os.path.join (base_path, "zser/_version.py"), "w") as vfile:
vfile.write ('__version__ = "%s"' % VERSION)
with open (os.path.join (base_path, "requirements.txt")) as reqs:
requirements = reqs.read ()
with (open (os.path.join (base_path, 'zser/zser.pyx'), 'w') as out,
open (os.path.join (base_path, 'zser/_zser.pyx')) as file_in):
text = file_in.read ()
if cython.__version__[0] < '3':
# Older cython doesn't support the noexcept function attribute.
text = text.replace (' noexcept', '')
out.write (text)
class CustomBuild (build_ext):
def run (self):
super().run ()
suffix = '.dll' if 'win' in sys.platform.lower () else '.so'
files = glob.glob ('build/*/zser/*' + suffix)
if files:
shutil.copy (files[0], 'zser/zser' + suffix)
setup (
name = "zser",
version = VERSION,
description = "zero-copy (de)serialization",
author = "Luciano Lo Giudice & Agustina Arzille",
author_email = "lmlogiudice@gmail.com",
maintainer = "Luciano Lo Giudice",
maintainer_email = "lmlogiudice@gmail.com",
url = "https://github.com/lmlg/zser/",
license = "LGPLv3",
packages = ["zser"],
package_dir = {"zser": "zser"},
tests_require = ["pytest"],
test_suite = "tests",
install_requires = requirements,
zip_safe = False,
cmdclass = {'build_ext': CustomBuild},
ext_modules = cythonize (extension_modules, include_path = include_dirs,
language_level = 3, annotate = True,
compiler_directives = {'embedsignature': True}),
)