|
@@ -2,7 +2,6 @@
|
|
import os
|
|
import os
|
|
import sys
|
|
import sys
|
|
from glob import glob
|
|
from glob import glob
|
|
-import attic
|
|
|
|
|
|
|
|
import versioneer
|
|
import versioneer
|
|
versioneer.versionfile_source = 'attic/_version.py'
|
|
versioneer.versionfile_source = 'attic/_version.py'
|
|
@@ -21,6 +20,7 @@ try:
|
|
except ImportError:
|
|
except ImportError:
|
|
from distutils.core import setup, Extension
|
|
from distutils.core import setup, Extension
|
|
|
|
|
|
|
|
+crypto_source = 'attic/crypto.pyx'
|
|
chunker_source = 'attic/chunker.pyx'
|
|
chunker_source = 'attic/chunker.pyx'
|
|
hashindex_source = 'attic/hashindex.pyx'
|
|
hashindex_source = 'attic/hashindex.pyx'
|
|
|
|
|
|
@@ -36,7 +36,7 @@ try:
|
|
versioneer.cmd_sdist.__init__(self, *args, **kwargs)
|
|
versioneer.cmd_sdist.__init__(self, *args, **kwargs)
|
|
|
|
|
|
def make_distribution(self):
|
|
def make_distribution(self):
|
|
- self.filelist.extend(['attic/chunker.c', 'attic/_chunker.c', 'attic/hashindex.c', 'attic/_hashindex.c'])
|
|
|
|
|
|
+ self.filelist.extend(['attic/crypto.c', 'attic/chunker.c', 'attic/_chunker.c', 'attic/hashindex.c', 'attic/_hashindex.c'])
|
|
super(Sdist, self).make_distribution()
|
|
super(Sdist, self).make_distribution()
|
|
|
|
|
|
except ImportError:
|
|
except ImportError:
|
|
@@ -44,11 +44,32 @@ except ImportError:
|
|
def __init__(self, *args, **kwargs):
|
|
def __init__(self, *args, **kwargs):
|
|
raise Exception('Cython is required to run sdist')
|
|
raise Exception('Cython is required to run sdist')
|
|
|
|
|
|
|
|
+ crypto_source = crypto_source.replace('.pyx', '.c')
|
|
chunker_source = chunker_source.replace('.pyx', '.c')
|
|
chunker_source = chunker_source.replace('.pyx', '.c')
|
|
hashindex_source = hashindex_source.replace('.pyx', '.c')
|
|
hashindex_source = hashindex_source.replace('.pyx', '.c')
|
|
from distutils.command.build_ext import build_ext
|
|
from distutils.command.build_ext import build_ext
|
|
- if not os.path.exists(chunker_source) or not os.path.exists(hashindex_source):
|
|
|
|
- raise ImportError('The GIT version of attic needs Cython. Install Cython or use a released version')
|
|
|
|
|
|
+ if not all(os.path.exists(path) for path in [crypto_source, chunker_source, hashindex_source]):
|
|
|
|
+ raise ImportError('The GIT version of Attic needs Cython. Install Cython or use a released version')
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+def detect_openssl(prefixes):
|
|
|
|
+ for prefix in prefixes:
|
|
|
|
+ filename = os.path.join(prefix, 'include', 'openssl', 'evp.h')
|
|
|
|
+ if os.path.exists(filename):
|
|
|
|
+ with open(filename, 'r') as fd:
|
|
|
|
+ if 'PKCS5_PBKDF2_HMAC(' in fd.read():
|
|
|
|
+ return prefix
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+possible_openssl_prefixes = ['/usr', '/usr/local', '/usr/local/opt/openssl', '/usr/local/ssl', '/usr/local/openssl', '/usr/local/attic']
|
|
|
|
+if os.environ.get('ATTIC_OPENSSL_PREFIX'):
|
|
|
|
+ possible_openssl_prefixes.insert(0, os.environ.get('ATTIC_OPENSSL_PREFIX'))
|
|
|
|
+ssl_prefix = detect_openssl(possible_openssl_prefixes)
|
|
|
|
+if not ssl_prefix:
|
|
|
|
+ raise Exception('Unable to find OpenSSL >= 1.0 headers. (Looked here: {})'.format(', '.join(possible_openssl_prefixes)))
|
|
|
|
+include_dirs = [os.path.join(ssl_prefix, 'include')]
|
|
|
|
+library_dirs = [os.path.join(ssl_prefix, 'lib')]
|
|
|
|
+
|
|
|
|
|
|
with open('README.rst', 'r') as fd:
|
|
with open('README.rst', 'r') as fd:
|
|
long_description = fd.read()
|
|
long_description = fd.read()
|
|
@@ -82,6 +103,7 @@ setup(
|
|
scripts=['scripts/attic'],
|
|
scripts=['scripts/attic'],
|
|
cmdclass=cmdclass,
|
|
cmdclass=cmdclass,
|
|
ext_modules=[
|
|
ext_modules=[
|
|
|
|
+ Extension('attic.crypto', [crypto_source], libraries=['crypto'], include_dirs=include_dirs, library_dirs=library_dirs),
|
|
Extension('attic.chunker', [chunker_source]),
|
|
Extension('attic.chunker', [chunker_source]),
|
|
Extension('attic.hashindex', [hashindex_source])
|
|
Extension('attic.hashindex', [hashindex_source])
|
|
],
|
|
],
|