Skip to content

Commit

Permalink
Merge pull request #4 from jakirkham/use_cython_tmplt
Browse files Browse the repository at this point in the history
Update project to use Cython
  • Loading branch information
jakirkham committed Aug 7, 2018
2 parents 000e23b + bc90391 commit a6f6a72
Show file tree
Hide file tree
Showing 29 changed files with 161 additions and 61 deletions.
3 changes: 2 additions & 1 deletion .appveyor_support/environments/dpl.yml
Expand Up @@ -4,8 +4,9 @@ channels:
- conda-forge

dependencies:
- python==3.6
- python=3.6.*
- pip==18.0
- wheel==0.31.1
- cython==0.28.5
- coverage==4.5.1
- coveralls==1.3.0
4 changes: 3 additions & 1 deletion .appveyor_support/environments/tst_py27.yml
@@ -1,9 +1,11 @@
name: pysharedmem_env
name: pysharedmem_py27_env

channels:
- conda-forge

dependencies:
- python=2.7.*
- pip==18.0
- wheel==0.31.1
- cython==0.28.5
- coverage==4.5.1
4 changes: 3 additions & 1 deletion .appveyor_support/environments/tst_py35.yml
@@ -1,9 +1,11 @@
name: pysharedmem_env
name: pysharedmem_py35_env

channels:
- conda-forge

dependencies:
- python=3.5.*
- pip==18.0
- wheel==0.31.1
- cython==0.28.5
- coverage==4.5.1
4 changes: 3 additions & 1 deletion .appveyor_support/environments/tst_py36.yml
@@ -1,9 +1,11 @@
name: pysharedmem_env
name: pysharedmem_py36_env

channels:
- conda-forge

dependencies:
- python=3.6.*
- pip==18.0
- wheel==0.31.1
- cython==0.28.5
- coverage==4.5.1
3 changes: 2 additions & 1 deletion .circleci/environments/dpl.yml
Expand Up @@ -4,8 +4,9 @@ channels:
- conda-forge

dependencies:
- python==3.6
- python=3.6.*
- pip==18.0
- wheel==0.31.1
- cython==0.28.5
- coverage==4.5.1
- coveralls==1.3.0
4 changes: 3 additions & 1 deletion .circleci/environments/tst_py27.yml
@@ -1,9 +1,11 @@
name: pysharedmem_env
name: pysharedmem_py27_env

channels:
- conda-forge

dependencies:
- python=2.7.*
- pip==18.0
- wheel==0.31.1
- cython==0.28.5
- coverage==4.5.1
4 changes: 3 additions & 1 deletion .circleci/environments/tst_py35.yml
@@ -1,9 +1,11 @@
name: pysharedmem_env
name: pysharedmem_py35_env

channels:
- conda-forge

dependencies:
- python=3.5.*
- pip==18.0
- wheel==0.31.1
- cython==0.28.5
- coverage==4.5.1
4 changes: 3 additions & 1 deletion .circleci/environments/tst_py36.yml
@@ -1,9 +1,11 @@
name: pysharedmem_env
name: pysharedmem_py36_env

channels:
- conda-forge

dependencies:
- python=3.6.*
- pip==18.0
- wheel==0.31.1
- cython==0.28.5
- coverage==4.5.1
6 changes: 6 additions & 0 deletions .coveragerc
@@ -1,8 +1,14 @@
[run]
branch = True
source = pysharedmem
plugins = Cython.Coverage
[report]
exclude_lines =
# Include the no cover pragma as it needs to be listed explicitly when
# using exclude_lines.
# ( http://coverage.readthedocs.io/en/coverage-4.1/excluding.html#advanced-exclusion )
pragma: no cover

# Ignore coverage of code that requires the module to be executed.
if __name__ == .__main__.:

Expand Down
2 changes: 1 addition & 1 deletion .gitattributes
@@ -1,4 +1,4 @@
pysharedmem/_version.py export-subst
_version.py export-subst

*.bat text eol=crlf
*.sh text eol=lf
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -5,6 +5,8 @@ __pycache__/

# C extensions
*.so
src/pysharedmem.c
src/version.pxi

# Distribution / packaging
.Python
Expand Down
3 changes: 2 additions & 1 deletion .travis_support/environments/dpl.yml
Expand Up @@ -4,8 +4,9 @@ channels:
- conda-forge

dependencies:
- python==3.6
- python=3.6.*
- pip==18.0
- wheel==0.31.1
- cython==0.28.5
- coverage==4.5.1
- coveralls==1.3.0
4 changes: 3 additions & 1 deletion .travis_support/environments/tst_py27.yml
@@ -1,9 +1,11 @@
name: pysharedmem_env
name: pysharedmem_py27_env

channels:
- conda-forge

dependencies:
- python=2.7.*
- pip==18.0
- wheel==0.31.1
- cython==0.28.5
- coverage==4.5.1
4 changes: 3 additions & 1 deletion .travis_support/environments/tst_py35.yml
@@ -1,9 +1,11 @@
name: pysharedmem_env
name: pysharedmem_py35_env

channels:
- conda-forge

dependencies:
- python=3.5.*
- pip==18.0
- wheel==0.31.1
- cython==0.28.5
- coverage==4.5.1
4 changes: 3 additions & 1 deletion .travis_support/environments/tst_py36.yml
@@ -1,9 +1,11 @@
name: pysharedmem_env
name: pysharedmem_py36_env

channels:
- conda-forge

dependencies:
- python=3.6.*
- pip==18.0
- wheel==0.31.1
- cython==0.28.5
- coverage==4.5.1
4 changes: 3 additions & 1 deletion MANIFEST.in
Expand Up @@ -10,5 +10,7 @@ recursive-exclude * *.py[co]

recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif

include pyproject.toml

include versioneer.py
include pysharedmem/_version.py
include _version.py
2 changes: 1 addition & 1 deletion pysharedmem/_version.py → _version.py
Expand Up @@ -43,7 +43,7 @@ def get_config():
cfg.style = "pep440"
cfg.tag_prefix = "v"
cfg.parentdir_prefix = "pysharedmem"
cfg.versionfile_source = "pysharedmem/_version.py"
cfg.versionfile_source = "_version.py"
cfg.verbose = False
return cfg

Expand Down
2 changes: 1 addition & 1 deletion docs/installation.rst
Expand Up @@ -14,7 +14,7 @@ To install pysharedmem, run this command in your terminal:
$ pip install pysharedmem
This is the preferred method to install pysharedmem, as it will always install the most recent stable release.
This is the preferred method to install pysharedmem, as it will always install the most recent stable release.

If you don't have `pip`_ installed, this `Python installation guide`_ can guide
you through the process.
Expand Down
2 changes: 2 additions & 0 deletions environment_doc.yml
Expand Up @@ -4,6 +4,8 @@ channels:
- conda-forge

dependencies:
- python=3.6.*
- pip==18.0
- wheel==0.31.1
- cython==0.28.5
- sphinx==1.7.5
2 changes: 2 additions & 0 deletions pyproject.toml
@@ -0,0 +1,2 @@
[build-system]
requires = ["setuptools", "wheel", "cython"]
8 changes: 0 additions & 8 deletions pysharedmem/__init__.py

This file was deleted.

1 change: 0 additions & 1 deletion pysharedmem/core.py

This file was deleted.

2 changes: 2 additions & 0 deletions readthedocs.yml
@@ -1,2 +1,4 @@
conda:
file: environment_doc.yml
python:
setup_py_install: true
4 changes: 2 additions & 2 deletions setup.cfg
@@ -1,8 +1,8 @@
[versioneer]
VCS = git
style = pep440
versionfile_source = pysharedmem/_version.py
versionfile_build = pysharedmem/_version.py
versionfile_source = _version.py
versionfile_build = _version.py
tag_prefix = v
parentdir_prefix = pysharedmem

Expand Down
93 changes: 88 additions & 5 deletions setup.py
@@ -1,38 +1,121 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import glob
import os
import sys

import setuptools
from setuptools import setup
from setuptools import setup, Extension

from distutils.sysconfig import get_config_var, get_python_inc

import versioneer

version = versioneer.get_version()

with open("README.rst") as readme_file:
readme = readme_file.read()

with open("HISTORY.rst") as history_file:
history = history_file.read()

requirements = [
setup_requirements = [
"Cython>=0.28.5",
]

install_requirements = [
# TODO: put package requirements here
]

test_requirements = [
# TODO: put package test requirements here
]

cmdclasses = dict()
cmdclasses.update(versioneer.get_cmdclass())

if not (({"develop", "test"} & set(sys.argv)) or
any([v.startswith("build") for v in sys.argv]) or
any([v.startswith("bdist") for v in sys.argv]) or
any([v.startswith("install") for v in sys.argv])):
setup_requirements = []
else:
with open("src/version.pxi", "w") as f:
f.writelines([
"__version__ = " + "\"" + str(version) + "\""
])


try:
i = sys.argv.index("test")
sys.argv = sys.argv[:i] + ["build_ext", "--inplace"] + sys.argv[i:]
except ValueError:
pass


include_dirs = [
os.path.dirname(get_python_inc()),
get_python_inc()
]
library_dirs = list(filter(
lambda v: v is not None,
[get_config_var("LIBDIR")]
))

headers = []
sources = glob.glob("src/*.pxd") + glob.glob("src/*.pyx")
libraries = []
define_macros = []
extra_compile_args = []
cython_directives = {}
cython_line_directives = {}


if "test" in sys.argv:
cython_directives["binding"] = True
cython_directives["embedsignature"] = True
cython_directives["profile"] = True
cython_directives["linetrace"] = True
define_macros += [
("CYTHON_PROFILE", 1),
("CYTHON_TRACE", 1),
("CYTHON_TRACE_NOGIL", 1),
]


ext_modules = [
Extension(
"pysharedmem",
sources=sources,
include_dirs=include_dirs,
library_dirs=library_dirs,
libraries=libraries,
define_macros=define_macros,
extra_compile_args=extra_compile_args,
language="c"
)
]
for em in ext_modules:
em.cython_directives = dict(cython_directives)
em.cython_line_directives = dict(cython_line_directives)


setup(
name="pysharedmem",
version=versioneer.get_version(),
version=version,
description="Code for using interprocess shared memory in Python",
long_description=readme + "\n\n" + history,
author="John Kirkham",
author_email="kirkhamj@janelia.hhmi.org",
url="https://github.com/jakirkham/pysharedmem",
cmdclass=versioneer.get_cmdclass(),
cmdclass=cmdclasses,
packages=setuptools.find_packages(exclude=["tests*"]),
include_package_data=True,
install_requires=requirements,
setup_requires=setup_requirements,
install_requires=install_requirements,
headers=headers,
ext_modules=ext_modules,
license="BSD 3-Clause",
zip_safe=False,
keywords="pysharedmem",
Expand Down
1 change: 1 addition & 0 deletions src/pysharedmem.pxd
@@ -0,0 +1 @@

3 changes: 3 additions & 0 deletions src/pysharedmem.pyx
@@ -0,0 +1,3 @@
cimport pysharedmem

include "version.pxi"

0 comments on commit a6f6a72

Please sign in to comment.