Skip to content

Commit 6345fce

Browse files
authored
Join all cythonized code (speed optimizations) (#62)
Tested on windows and linux. About 30% faster.
1 parent 8ee2f7e commit 6345fce

File tree

4 files changed

+60
-25
lines changed

4 files changed

+60
-25
lines changed

appveyor.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
environment:
2-
TWINE_USERNAME: penguinolog
3-
TWINE_PASSWORD:
4-
secure: TCKGf77kkVeo2Pbd+lQY5Q==
5-
62
matrix:
73
- PYTHON: "C:\\Python35"
84
PYTHON_VERSION: "3.5.x" # currently 3.5.1
@@ -20,6 +16,14 @@ environment:
2016
PYTHON_VERSION: "3.6.x" # currently 3.6.0
2117
PYTHON_ARCH: "64"
2218

19+
- PYTHON: "C:\\Python37"
20+
PYTHON_VERSION: "3.7.x" # currently 3.6.0
21+
PYTHON_ARCH: "32"
22+
23+
- PYTHON: "C:\\Python37-x64"
24+
PYTHON_VERSION: "3.7.x" # currently 3.6.0
25+
PYTHON_ARCH: "64"
26+
2327
install:
2428
- cmd: echo "Using cmd"
2529

@@ -56,6 +60,3 @@ test_script:
5660
artifacts:
5761
- path: dist\*
5862
name: Python built code
59-
60-
on_success:
61-
- if "%APPVEYOR_REPO_TAG%"=="true" ( pip install -U twine && twine upload dist/*.whl )

logwrap/__init__.pxd

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
11
cpdef tuple __all__
2+
3+
cpdef str __version__
4+
cpdef str __author__
5+
cpdef str __author_email__
6+
cpdef dict __maintainers__
7+
cpdef str __url__
8+
cpdef str __description__
9+
cpdef str __license__

logwrap/__init__.pyx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
# Copyright 2016-2018 Alexey Stepanov aka penguinolog
2+
##
3+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
4+
# not use this file except in compliance with the License. You may obtain
5+
# a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12+
# License for the specific language governing permissions and limitations
13+
# under the License.
14+
15+
import pkg_resources
16+
117
from .repr_utils cimport PrettyFormat, PrettyRepr, PrettyStr, pretty_repr, pretty_str
218

319
from .log_wrap cimport LogWrap
@@ -14,3 +30,27 @@ cpdef tuple __all__ = (
1430
"BoundParameter",
1531
"bind_args_kwargs",
1632
)
33+
34+
cpdef str __version__
35+
36+
try:
37+
__version__ = pkg_resources.get_distribution(__name__).version
38+
except pkg_resources.DistributionNotFound:
39+
# package is not installed, try to get from SCM
40+
try:
41+
import setuptools_scm # type: ignore
42+
43+
__version__ = setuptools_scm.get_version()
44+
except ImportError:
45+
pass
46+
47+
cpdef str __author__ = "Alexey Stepanov"
48+
cpdef str __author_email__ = "penguinolog@gmail.com"
49+
cpdef dict __maintainers__ = {
50+
"Alexey Stepanov": "penguinolog@gmail.com",
51+
"Antonio Esposito": "esposito.cloud@gmail.com",
52+
"Dennis Dmitriev": "dis-xcom@gmail.com",
53+
}
54+
cpdef str __url__ = "https://github.com/python-useful-helpers/logwrap"
55+
cpdef str __description__ = "Decorator for logging function arguments and return value by human-readable way"
56+
cpdef str __license__ = "Apache License, Version 2.0"

setup.py

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
import collections
2323
from distutils.command import build_ext
2424
import distutils.errors
25+
import glob
2526
import os.path
2627
import shutil
27-
import sys
2828

2929
try:
3030
# noinspection PyPackageRequirements
@@ -44,19 +44,7 @@
4444
long_description = f.read()
4545

4646

47-
def _extension(modpath):
48-
"""Make setuptools.Extension."""
49-
return setuptools.Extension(modpath, [modpath.replace(".", "/") + ".py"])
50-
51-
52-
requires_optimization = [
53-
setuptools.Extension("logwrap.class_decorator", ["logwrap/class_decorator.pyx"]),
54-
setuptools.Extension("logwrap.log_wrap", ["logwrap/log_wrap.pyx"]),
55-
setuptools.Extension("logwrap.repr_utils", ["logwrap/repr_utils.pyx"]),
56-
]
57-
58-
if "win32" != sys.platform:
59-
requires_optimization.append(_extension("logwrap.__init__"))
47+
requires_optimization = [setuptools.Extension("logwrap", glob.glob("logwrap/*.pyx"))]
6048

6149
# noinspection PyCallingNonCallable
6250
ext_modules = (
@@ -90,9 +78,7 @@ def run(self):
9078
root_dir = os.path.abspath(os.path.join(__file__, ".."))
9179
target_dir = build_dir if not self.inplace else root_dir
9280

93-
src_files = (
94-
os.path.join("logwrap", "__init__.py"),
95-
)
81+
src_files = (os.path.join("logwrap", "__init__.py"),)
9682

9783
for src_file in src_files:
9884
src = os.path.join(root_dir, src_file)
@@ -233,7 +219,7 @@ def get_simple_vars_from_src(src):
233219
"setuptools >= 21.0.0,!=24.0.0,"
234220
"!=34.0.0,!=34.0.1,!=34.0.2,!=34.0.3,!=34.1.0,!=34.1.1,!=34.2.0,!=34.3.0,!=34.3.1,!=34.3.2,"
235221
"!=36.2.0",
236-
"setuptools_scm"
222+
"setuptools_scm",
237223
],
238224
use_scm_version=True,
239225
install_requires=required,

0 commit comments

Comments
 (0)