Skip to content

Commit

Permalink
v1.1.0 Support python 3.7, 3,8
Browse files Browse the repository at this point in the history
  • Loading branch information
sundarnagarajan committed Jan 5, 2021
1 parent 5969164 commit 4850a26
Show file tree
Hide file tree
Showing 6 changed files with 48,106 additions and 4,142 deletions.
21 changes: 14 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ SHELL := /bin/bash

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

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

# ---------- Combined targets --------------------------------------------

${C_SOURCE}: ${PYX_SOURCE}
${C_SOURCE_2}: ${PYX_SOURCE}
@echo Building C source using ${CYTHON_PROG}
${CYTHON_PROG} ${PYX_SOURCE} -o ${C_SOURCE} 1>/dev/null
${LS_CMD} ${C_SOURCE}
${CYTHON_PROG} -2 ${PYX_SOURCE} -o ${C_SOURCE_2} 1>/dev/null
${LS_CMD} ${C_SOURCE_2}
@echo ""

${C_SOURCE_3}: ${PYX_SOURCE}
@echo Building C source using ${CYTHON_PROG}
${CYTHON_PROG} -3 ${PYX_SOURCE} -o ${C_SOURCE_3} 1>/dev/null
${LS_CMD} ${C_SOURCE_3}
@echo ""

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

# ---------- Python 3 targets --------------------------------------------

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

# ---------- Python 2 targets --------------------------------------------

protected_class.so: ${C_SOURCE}
protected_class.so: ${C_SOURCE_2}
@echo Building Python 2 extension module
python2 setup.py build_ext --inplace 1>/dev/null && rm -rf build
${LS_CMD} protected_class.so
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@
- Does not leave a back door like:
- Attributes still accessible using ```object.__getattribute__(myobj, atribute)```
- Looking at python stack frame
- Tested on Python 2.7.17 and python 3.6.9
- Tested on Python 2.7.17 and python 3.6.9, 3.7.5, 3.8.0
- Should work on any Python 3 version
- Well documented (docstring)
- doctests in tests directory
- Tested (only) on Ubuntu Bionic 18.04. Should work on any Linux distribution
- Should work wherever cython works
- If you want to CHANGE the source and recompile protected_class.c, and you want it
to work with Python 3.7+, you need to install cython version >= 0.27.3
Do this with
```sudo pip3 install --upgrade cython>=0.27.3```
- This README.md is not completely up to date. Use ```pydoc protected_class``` for the most up-to-date documentation


### Usage
Expand Down
11 changes: 8 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
import os
from setuptools import Extension
from setuptools import setup

Expand All @@ -12,7 +13,7 @@
)
module_dir = name + '_src-' + pyver

version = '1.0.2'
version = '1.1.0'
description = 'Protect class attributes in any python object instance'
long_description = open('README.md', 'r').read()
long_description_content_type = 'text/markdown'
Expand Down Expand Up @@ -45,9 +46,14 @@
}


if sys.version_info.major < 3:
src = 'src/c/2/' + name + '.c'
else:
src = 'src/c/3/' + name + '.c'

data_files = [
(module_dir, [
'src/c/' + name + '.c',
src,
'src/cython/' + name + '.pyx',
'tests/__init__.py',
'tests/test_protected_class.py',
Expand All @@ -58,7 +64,6 @@
language = 'c'
include_dirs = []

src = 'src/c/' + name + '.c'
extensions = [
Extension(
name=name,
Expand Down
Loading

0 comments on commit 4850a26

Please sign in to comment.