FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-cityhash/setup.py at master · escherba/python-cityhash · GitHub
escherba
/
python-cityhash
Public
Notifications
You must be signed in to change notification settings
Fork
33
Star
46
Code
Issues
3
Pull requests
0
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
python-cityhash
/
setup.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
193 lines (165 loc) · 5.1 KB
Breadcrumbs
python-cityhash
/
setup.py
Copy path
File metadata and controls
193 lines (165 loc) · 5.1 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import
os
import
platform
import
struct
from
setuptools
import
setup
from
setuptools
.
dist
import
Distribution
from
setuptools
.
extension
import
Extension
try
:
from
cpuinfo
import
get_cpu_info
CPU_FLAGS
=
get_cpu_info
()[
"flags"
]
except
Exception
as
exc
:
print
(
"exception loading cpuinfo"
,
exc
)
CPU_FLAGS
=
{}
try
:
from
Cython
.
Distutils
import
build_ext
USE_CYTHON
=
True
except
ImportError
:
USE_CYTHON
=
False
class
BinaryDistribution
(
Distribution
):
"""
Subclass the setuptools Distribution to flip the purity flag to false.
See https://lucumr.pocoo.org/2014/1/27/python-on-wheels/
"""
def
is_pure
(
self
):
"""Returns purity flag"""
return
False
def
get_system_bits
():
"""Return 32 for 32-bit systems and 64 for 64-bit"""
return
struct
.
calcsize
(
"P"
)
*
8
SYSTEM
=
os
.
name
BITS
=
get_system_bits
()
HAVE_SSE42
=
"sse4_2"
in
CPU_FLAGS
HAVE_AES
=
"aes"
in
CPU_FLAGS
CXXFLAGS
=
[]
print
(
"system: %s-%d"
%
(
SYSTEM
,
BITS
))
print
(
"available CPU flags:"
,
CPU_FLAGS
)
print
(
"environment:"
,
", "
.
join
([
"%s=%s"
%
(
k
,
v
)
for
k
,
v
in
os
.
environ
.
items
()]))
if
SYSTEM
==
"nt"
:
CXXFLAGS
.
extend
([
"/O2"
])
else
:
CXXFLAGS
.
extend
(
[
"-O3"
,
"-Wno-unused-value"
,
"-Wno-unused-function"
,
]
)
# The "cibuildwheel" tool sets AUDITWHEEL_ARCH variable to architecture strings
# such as 'x86_64', 'aarch64', 'i686', etc. If this variable is not set, we
# assume that the build is not a CI build and target current machine
# architecture.
TARGET_ARCH
=
os
.
environ
.
get
(
"AUDITWHEEL_ARCH"
,
platform
.
machine
())
print
(
"building for target architecture:"
,
TARGET_ARCH
)
if
HAVE_SSE42
and
(
TARGET_ARCH
==
"x86_64"
)
and
(
BITS
==
64
):
print
(
"enabling SSE4.2 on compile"
)
if
SYSTEM
==
"nt"
:
CXXFLAGS
.
append
(
"/D__SSE4_2__"
)
else
:
CXXFLAGS
.
append
(
"-msse4.2"
)
if
HAVE_AES
and
(
TARGET_ARCH
==
"x86_64"
)
and
(
BITS
==
64
):
print
(
"enabling AES on compile"
)
if
SYSTEM
==
"nt"
:
CXXFLAGS
.
append
(
"/D__AES__"
)
else
:
CXXFLAGS
.
append
(
"-maes"
)
if
USE_CYTHON
:
print
(
"building extension using Cython"
)
CMDCLASS
=
{
"build_ext"
:
build_ext
}
SRC_EXT
=
".pyx"
else
:
print
(
"building extension w/o Cython"
)
CMDCLASS
=
{}
SRC_EXT
=
".cpp"
EXT_MODULES
=
[
Extension
(
"cityhash"
,
[
"src/city.cc"
,
"src/cityhash"
+
SRC_EXT
],
depends
=
[
"src/city.h"
],
language
=
"c++"
,
extra_compile_args
=
CXXFLAGS
,
include_dirs
=
[
"src"
],
),
Extension
(
"farmhash"
,
[
"src/farm.cc"
,
"src/farmhash"
+
SRC_EXT
],
depends
=
[
"src/farm.h"
],
language
=
"c++"
,
extra_compile_args
=
CXXFLAGS
,
include_dirs
=
[
"src"
],
),
]
if
HAVE_SSE42
and
(
TARGET_ARCH
==
"x86_64"
)
and
(
BITS
==
64
):
EXT_MODULES
.
append
(
Extension
(
"cityhashcrc"
,
[
"src/city.cc"
,
"src/cityhashcrc"
+
SRC_EXT
],
depends
=
[
"src/city.h"
,
"src/citycrc.h"
,
],
language
=
"c++"
,
extra_compile_args
=
CXXFLAGS
,
include_dirs
=
[
"src"
],
)
)
VERSION
=
"0.4.10"
URL
=
"https://github.com/escherba/python-cityhash"
def
get_long_description
(
relpath
,
encoding
=
"utf-8"
):
_long_desc
=
"""
"""
fname
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
relpath
)
try
:
with
open
(
fname
,
"rb"
)
as
fh
:
return
fh
.
read
().
decode
(
encoding
)
except
Exception
:
return
_long_desc
setup
(
version
=
VERSION
,
description
=
"Python bindings for CityHash and FarmHash"
,
author
=
"Eugene Scherba"
,
author_email
=
"escherba+cityhash@gmail.com"
,
url
=
URL
,
download_url
=
URL
+
"/tarball/master/"
+
VERSION
,
name
=
"cityhash"
,
license
=
"MIT"
,
python_requires
=
'>=3.6'
,
zip_safe
=
False
,
cmdclass
=
CMDCLASS
,
ext_modules
=
EXT_MODULES
,
package_dir
=
{
""
:
"src"
},
keywords
=
[
"google"
,
"hash"
,
"hashing"
,
"cityhash"
,
"farmhash"
,
"murmurhash"
,
"cython"
,
],
classifiers
=
[
"Development Status :: 5 - Production/Stable"
,
"Intended Audience :: Developers"
,
"Intended Audience :: Science/Research"
,
"License :: OSI Approved :: MIT License"
,
"Operating System :: OS Independent"
,
"Programming Language :: C++"
,
"Programming Language :: Cython"
,
"Programming Language :: Python :: 3.6"
,
"Programming Language :: Python :: 3.7"
,
"Programming Language :: Python :: 3.8"
,
"Programming Language :: Python :: 3.9"
,
"Programming Language :: Python :: 3.10"
,
"Programming Language :: Python :: 3.11"
,
"Programming Language :: Python :: 3.12"
,
"Programming Language :: Python :: 3.13"
,
"Topic :: Scientific/Engineering :: Information Analysis"
,
"Topic :: Software Development :: Libraries"
,
"Topic :: System :: Distributed Computing"
,
],
long_description
=
get_long_description
(
"README.md"
),
long_description_content_type
=
"text/markdown"
,
tests_require
=
[
"pytest"
],
distclass
=
BinaryDistribution
,
)
Back
|
FazBrowse Home
|
New Git URL