Skip to content

Commit

Permalink
Expose version as tomcrypt.__version__
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeboers committed Nov 23, 2013
1 parent 4e314e2 commit 36fe16f
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# General.
*.pyc
.DS_Store
*.egg-info

# Old venv.
/.Python
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
# built documents.
#
# The short X.Y version.
version = '0.8'
version = '0.10'
# The full version, including alpha/beta/rc tags.
release = '0.8.0'
release = '0.10.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
13 changes: 5 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
from distutils.extension import Extension


# RTD: Build the sources first.
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
if on_rtd:
from subprocess import call
call(['make', 'sources'])
version='0.10.0'


# Allow us to specify a single extension to build.
Expand Down Expand Up @@ -62,8 +58,9 @@
# These macros are needed for the math library.
LTM_DESC=None,
LTC_SOURCE=None,

).items()),
PTC_VERSION='"%s"' % version,

).items()) if name == '_core' else [],

extra_compile_args=['-O3', '-funroll-loops', ]
))
Expand All @@ -75,7 +72,7 @@

name='PyTomCrypt',
description='Python+Cython wrapper around LibTomCrypt',
version='0.10.0',
version=version,
license='BSD-3',
platforms=['any'],
packages=['tomcrypt'],
Expand Down
3 changes: 2 additions & 1 deletion src/_core.pxd
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@


cdef extern from "pytomcrypt.h" nogil:
pass
const char* PTC_VERSION


cdef extern from "stdlib.h" nogil:

Expand Down
4 changes: 4 additions & 0 deletions src/_core.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@


version = PTC_VERSION


# Setup TomsFastMath for use.
mp = ltm_desc

Expand Down
28 changes: 28 additions & 0 deletions tests/test_meta.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from . import *

import tomcrypt


class TestVersion(TestCase):

def test_setup_version(self):

setup_py = os.path.abspath(os.path.join(__file__, '..', '..', 'setup.py'))
proc = Popen(['python', setup_py, '--version'], stdout=PIPE)
out, _ = proc.communicate()

self.assertEqual(out.strip(), tomcrypt.__version__)

def test_docs_version(self):

conf_py = os.path.abspath(os.path.join(__file__, '..', '..', 'docs', 'conf.py'))
namespace = {}
execfile(conf_py, namespace)

self.assertEqual(namespace['release'], tomcrypt.__version__)

real = tomcrypt.__version__.split('.')
docs = namespace['version'].split('.')
self.assertEqual(docs, real[:len(docs)])


4 changes: 4 additions & 0 deletions tomcrypt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ class LibError(Error):
# are availible to the core.
from . import _core
ctypes.PyDLL(_core.__file__, mode=ctypes.RTLD_GLOBAL)


__version__ = _core.version

0 comments on commit 36fe16f

Please sign in to comment.