forked from jd-boyd/python-lzo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
130 lines (103 loc) · 3.56 KB
/
setup.py
File metadata and controls
130 lines (103 loc) · 3.56 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#! /usr/bin/env python
# vi:ts=4:et
from __future__ import print_function
import os, sys
import setuptools
import distutils
from distutils.cmd import Command
from distutils.core import setup
from distutils.extension import Extension
from distutils.util import split_quoted
include_dirs = []
define_macros = []
library_dirs = []
libraries = []
runtime_library_dirs = []
extra_objects = []
extra_compile_args = []
extra_link_args = []
class TestCommand(Command):
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
import sys, subprocess
raise SystemExit(
subprocess.call([sys.executable,
'-m',
'nose']))
if sys.platform == "win32":
# Windows users have to configure the LZO_DIR path parameter to match
# their LZO source installation. The path set here is just an example
# and thus unlikely to match your installation.
LZO_DIR = os.environ.get('LZO_DIR', r"c:\src\lzo-2.10")
print("LZO_DIR:", LZO_DIR)
if not os.path.exists(LZO_DIR):
raise Exception("please set LZO_DIR to where the lzo source lives")
include_dirs.append(os.path.join(LZO_DIR, r"include\lzo"))
include_dirs.append(os.path.join(LZO_DIR, "include"))
lib1_file = os.path.join(LZO_DIR, "lzo.lib")
lib2_file = os.path.join(LZO_DIR, "lzo2.lib")
if os.path.exists(lib2_file):
lib_file = lib2_file
else:
lib_file = lib1_file
extra_objects.append(lib_file)
elif sys.platform == "darwin":
libraries = ["lzo2"]
LZO_DIR = os.environ.get('LZO_DIR', "/usr")
if not os.path.exists(LZO_DIR+"/include/lzo"):
LZO_DIR = os. getcwd()+"/lzo-2.10"
print("LZO_DIR:", LZO_DIR)
print("include dir:", LZO_DIR+"/include")
include_dirs.append(LZO_DIR+"/include")
library_dirs.append(LZO_DIR+"/lib")
extra_link_args.append("-flat_namespace")
else:
libraries = ["lzo2"]
include_dirs.append(os.environ.get("PREFIX", "/usr")+"/include")
##library_dirs.append("/usr/local/lib")
##runtime_library_dirs.append("/usr/local/lib")
###############################################################################
def get_kw(**kw): return kw
ext = Extension(
name="lzo",
sources=["lzomodule.c"],
include_dirs=include_dirs,
define_macros=define_macros,
library_dirs=library_dirs,
libraries=libraries,
runtime_library_dirs=runtime_library_dirs,
extra_objects=extra_objects,
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
)
setup_args = get_kw(
name="python-lzo",
version="1.16",
description="Python bindings for the LZO data compression library",
author="Markus F.X.J. Oberhumer",
author_email="markus@oberhumer.com",
maintainer="Joshua D. Boyd",
maintainer_email="jdboyd@jdboyd.net",
url="https://github.com/jd-boyd/python-lzo",
license="GNU General Public License (GPL)",
tests_require=['nose'],
cmdclass={
'test': TestCommand
},
ext_modules=[ext],
long_description="""
This module provides Python bindings for the LZO data compression library.
LZO is a portable lossless data compression library written in ANSI C.
It offers pretty fast compression and *very* fast decompression.
Decompression requires no memory.
In addition there are slower compression levels achieving a quite
competitive compression ratio while still decompressing at
this very high speed.""",
)
if distutils.__version__ >= "1.0.2":
setup_args["platforms"] = "All"
setup(**setup_args)