Skip to content

Commit 4850a26

Browse files
v1.1.0 Support python 3.7, 3,8
1 parent 5969164 commit 4850a26

File tree

6 files changed

+48106
-4142
lines changed

6 files changed

+48106
-4142
lines changed

Makefile

+14-7
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ SHELL := /bin/bash
33

44
MOD_NAME := protected_class
55
PYX_SOURCE := src/cython/${MOD_NAME}.pyx
6-
C_SOURCE := src/c/${MOD_NAME}.c
7-
CYTHON_PROG := $(shell which cython3 2>/dev/null || which cython 2>/dev/null)
6+
C_SOURCE_2 := src/c/2/${MOD_NAME}.c
7+
C_SOURCE_3 := src/c/3/${MOD_NAME}.c
8+
CYTHON_PROG := $(shell which cython 2>/dev/null || which cython3 2>/dev/null || which cython 2>/dev/null)
89
LS_CMD := ls -g --time-style="+%Y-%m-%d %H:%M:%S"
910
RUN_TEST_FILE := tests/run_tests.sh
1011

@@ -17,10 +18,16 @@ help: ## Show this help
1718

1819
# ---------- Combined targets --------------------------------------------
1920

20-
${C_SOURCE}: ${PYX_SOURCE}
21+
${C_SOURCE_2}: ${PYX_SOURCE}
2122
@echo Building C source using ${CYTHON_PROG}
22-
${CYTHON_PROG} ${PYX_SOURCE} -o ${C_SOURCE} 1>/dev/null
23-
${LS_CMD} ${C_SOURCE}
23+
${CYTHON_PROG} -2 ${PYX_SOURCE} -o ${C_SOURCE_2} 1>/dev/null
24+
${LS_CMD} ${C_SOURCE_2}
25+
@echo ""
26+
27+
${C_SOURCE_3}: ${PYX_SOURCE}
28+
@echo Building C source using ${CYTHON_PROG}
29+
${CYTHON_PROG} -3 ${PYX_SOURCE} -o ${C_SOURCE_3} 1>/dev/null
30+
${LS_CMD} ${C_SOURCE_3}
2431
@echo ""
2532

2633
module: py3 py2 ## (PY2 and PY3) Build modules
@@ -36,7 +43,7 @@ clean: ## (PY2 and PY3) Remove built modules
3643

3744
# ---------- Python 3 targets --------------------------------------------
3845

39-
protected_class.cpython-3*.so: ${C_SOURCE}
46+
protected_class.cpython-3*.so: ${C_SOURCE_3}
4047
@echo Building Python 3 extension module
4148
python3 setup.py build_ext --inplace 1>/dev/null && rm -rf build
4249
${LS_CMD} protected_class.cpython-3*.so
@@ -55,7 +62,7 @@ vtest3: py3 ## PY3 Build and test module (VERBOSE)
5562

5663
# ---------- Python 2 targets --------------------------------------------
5764

58-
protected_class.so: ${C_SOURCE}
65+
protected_class.so: ${C_SOURCE_2}
5966
@echo Building Python 2 extension module
6067
python2 setup.py build_ext --inplace 1>/dev/null && rm -rf build
6168
${LS_CMD} protected_class.so

README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,17 @@
77
- Does not leave a back door like:
88
- Attributes still accessible using ```object.__getattribute__(myobj, atribute)```
99
- Looking at python stack frame
10-
- Tested on Python 2.7.17 and python 3.6.9
10+
- Tested on Python 2.7.17 and python 3.6.9, 3.7.5, 3.8.0
1111
- Should work on any Python 3 version
1212
- Well documented (docstring)
1313
- doctests in tests directory
1414
- Tested (only) on Ubuntu Bionic 18.04. Should work on any Linux distribution
1515
- Should work wherever cython works
16+
- If you want to CHANGE the source and recompile protected_class.c, and you want it
17+
to work with Python 3.7+, you need to install cython version >= 0.27.3
18+
Do this with
19+
```sudo pip3 install --upgrade cython>=0.27.3```
20+
- This README.md is not completely up to date. Use ```pydoc protected_class``` for the most up-to-date documentation
1621

1722

1823
### Usage

setup.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import sys
2+
import os
23
from setuptools import Extension
34
from setuptools import setup
45

@@ -12,7 +13,7 @@
1213
)
1314
module_dir = name + '_src-' + pyver
1415

15-
version = '1.0.2'
16+
version = '1.1.0'
1617
description = 'Protect class attributes in any python object instance'
1718
long_description = open('README.md', 'r').read()
1819
long_description_content_type = 'text/markdown'
@@ -45,9 +46,14 @@
4546
}
4647

4748

49+
if sys.version_info.major < 3:
50+
src = 'src/c/2/' + name + '.c'
51+
else:
52+
src = 'src/c/3/' + name + '.c'
53+
4854
data_files = [
4955
(module_dir, [
50-
'src/c/' + name + '.c',
56+
src,
5157
'src/cython/' + name + '.pyx',
5258
'tests/__init__.py',
5359
'tests/test_protected_class.py',
@@ -58,7 +64,6 @@
5864
language = 'c'
5965
include_dirs = []
6066

61-
src = 'src/c/' + name + '.c'
6267
extensions = [
6368
Extension(
6469
name=name,

0 commit comments

Comments
 (0)