예제 #1
0
파일: setup.py 프로젝트: cryptape/pyevmjit
    def run(self):
        if has_system_lib():
            log.info("Using system library")
            return

        build_temp = os.path.abspath(self.build_temp)

        try:
            os.makedirs(build_temp)
        except OSError as e:
            if e.errno != errno.EEXIST:
                raise

        subprocess.check_call(["cmake"], cwd=build_temp)
        subprocess.check_call(["make"], cwd=build_temp)
        subprocess.check_call(["make", "install"], cwd=build_temp)
        subprocess.check_call(["ldconfig"], cwd=build_temp)

        self.build_flags['include_dirs'].extend(
            build_flags('libevmjit', 'I', build_temp))
        self.build_flags['library_dirs'].extend(
            build_flags('libevmjit', 'L', build_temp))
        if not has_system_lib():
            self.build_flags['define'].append(('CFFI_ENABLE_RECOVERY', None))
        else:
            pass
예제 #2
0
 def run(self):
     if not has_system_lib():
         raise DistutilsError(
             "This library is not usable in 'develop' mode when using the "
             'bundled libsecp256k1. See README for details.'
         )
     _develop.run(self)
예제 #3
0
    def run(self):
        if has_system_lib():
            log.info("Using system library")
            return

        build_temp = os.path.abspath(self.build_temp)

        try:
            os.makedirs(build_temp)
        except OSError as e:
            if e.errno != errno.EEXIST:
                raise

        if not os.path.exists(absolute("libsecp256k1/configure")):
            # configure script hasn't been generated yet
            autogen = absolute("libsecp256k1/autogen.sh")
            os.chmod(absolute(autogen), 0o755)
            subprocess.check_call(
                [autogen],
                cwd=absolute("libsecp256k1"),
            )

        for filename in [
            "libsecp256k1/configure",
            "libsecp256k1/build-aux/compile",
            "libsecp256k1/build-aux/config.guess",
            "libsecp256k1/build-aux/config.sub",
            "libsecp256k1/build-aux/depcomp",
            "libsecp256k1/build-aux/install-sh",
            "libsecp256k1/build-aux/missing",
            "libsecp256k1/build-aux/test-driver",
        ]:
            try:
                os.chmod(absolute(filename), 0o755)
            except OSError as e:
                # some of these files might not exist depending on autoconf version
                if e.errno != errno.ENOENT:
                    # If the error isn't "No such file or directory" something
                    # else is wrong and we want to know about it
                    raise

        cmd = [
            absolute("libsecp256k1/configure"),
            "--disable-shared",
            "--enable-static",
            "--disable-dependency-tracking",
            "--with-pic",
            "--enable-module-recovery",
            "--prefix",
            os.path.abspath(self.build_clib),
        ]
        if os.environ.get('SECP_BUNDLED_WITH_BIGNUM'):
            log.info("Building with bignum support (requires libgmp)")
            cmd.extend(["--with-bignum=gmp"])
        else:
            cmd.extend(["--without-bignum"])

        if os.environ.get('SECP_BUNDLED_EXPERIMENTAL'):
            log.info("Building experimental")
            cmd.extend([
                "--enable-experimental",
                "--enable-module-ecdh",
                "--enable-module-schnorr",
            ])

        log.debug("Running configure: {}".format(" ".join(cmd)))
        subprocess.check_call(
            cmd,
            cwd=build_temp,
        )

        subprocess.check_call(["make"], cwd=build_temp)
        subprocess.check_call(["make", "install"], cwd=build_temp)

        self.build_flags['include_dirs'].extend(build_flags('libsecp256k1', 'I', build_temp))
        self.build_flags['library_dirs'].extend(build_flags('libsecp256k1', 'L', build_temp))
        if not has_system_lib():
            self.build_flags['define'].append(('CFFI_ENABLE_RECOVERY', None))
        else:
            pass
예제 #4
0
 def has_c_libraries(self):
     return not has_system_lib()
예제 #5
0
    def run(self):
        if has_system_lib():
            log.info('Using system library')
            return

        build_temp = os.path.abspath(self.build_temp)

        try:
            os.makedirs(build_temp)
        except OSError as e:
            if e.errno != errno.EEXIST:
                raise

        if not os.path.exists(absolute('libsecp256k1')):
            # library needs to be downloaded
            self.get_source_files()

        if not os.path.exists(absolute('libsecp256k1/configure')):
            # configure script hasn't been generated yet
            autogen = absolute('libsecp256k1/autogen.sh')
            os.chmod(absolute(autogen), 0o755)
            subprocess.check_call([autogen], cwd=absolute('libsecp256k1'))

        for filename in [
                'libsecp256k1/configure',
                'libsecp256k1/build-aux/compile',
                'libsecp256k1/build-aux/config.guess',
                'libsecp256k1/build-aux/config.sub',
                'libsecp256k1/build-aux/depcomp',
                'libsecp256k1/build-aux/install-sh',
                'libsecp256k1/build-aux/missing',
                'libsecp256k1/build-aux/test-driver',
        ]:
            try:
                os.chmod(absolute(filename), 0o755)
            except OSError as e:
                # some of these files might not exist depending on autoconf version
                if e.errno != errno.ENOENT:
                    # If the error isn't 'No such file or directory' something
                    # else is wrong and we want to know about it
                    raise

        cmd = [
            absolute('libsecp256k1/configure'),
            '--disable-shared',
            '--enable-static',
            '--disable-dependency-tracking',
            '--with-pic',
            '--enable-module-recovery',
            '--prefix',
            os.path.abspath(self.build_clib),
            '--enable-experimental',
            '--enable-module-ecdh',
            '--enable-benchmark=no',
            '--enable-tests=no',
            '--enable-openssl-tests=no',
            '--enable-exhaustive-tests=no',
        ]
        if 'COINCURVE_CROSS_HOST' in os.environ:
            cmd.append('--host={}'.format(os.environ['COINCURVE_CROSS_HOST']))

        log.debug('Running configure: {}'.format(' '.join(cmd)))
        subprocess.check_call(cmd, cwd=build_temp)

        subprocess.check_call([MAKE], cwd=build_temp)
        subprocess.check_call([MAKE, 'install'], cwd=build_temp)

        self.build_flags['include_dirs'].extend(
            build_flags('libsecp256k1', 'I', build_temp))
        self.build_flags['library_dirs'].extend(
            build_flags('libsecp256k1', 'L', build_temp))
        if not has_system_lib():
            self.build_flags['define'].append(('CFFI_ENABLE_RECOVERY', None))
        else:
            pass
예제 #6
0
        absolute("_cffi_build/secp256k1_recovery.h"),
        "#include <secp256k1_recovery.h>",
    ),
    'schnorr':
    Source(
        absolute("_cffi_build/secp256k1_schnorr.h"),
        "#include <secp256k1_schnorr.h>",
    ),
}

ffi = None

# The following is used to detect whether the library is already installed on
# the system (and if so which modules are enabled) or if we will use the
# bundled one.
if has_system_lib():
    _available = []
    try:
        # try all combinations of optional modules that could be enabled
        # works downwards from most enabled modules to fewest
        for l in range(len(_modules), -1, -1):
            for combination in combinations(_modules.items(), l):
                try:
                    _test_ffi = _mk_ffi(_base +
                                        [item[1] for item in combination],
                                        name="_testcompile",
                                        bundled=False,
                                        libraries=['secp256k1'])
                    with redirect(sys.stderr, os.devnull), workdir():
                        _test_ffi.compile()
                    _available = combination
예제 #7
0
파일: setup.py 프로젝트: ulope/secp256k1-py
 def run(self):
     if not has_system_lib():
         raise DistutilsError(
             "This library is not usable in 'develop' mode when using the "
             "bundled libsecp256k1. See README for details.")
     _develop.run(self)
예제 #8
0
파일: setup.py 프로젝트: ulope/secp256k1-py
    def run(self):
        if has_system_lib():
            log.info("Using system library")
            return

        build_temp = os.path.abspath(self.build_temp)

        try:
            os.makedirs(build_temp)
        except OSError as e:
            if e.errno != errno.EEXIST:
                raise

        if not os.path.exists(absolute("libsecp256k1/configure")):
            # configure script hasn't been generated yet
            autogen = absolute("libsecp256k1/autogen.sh")
            os.chmod(absolute(autogen), 0o755)
            subprocess.check_call(
                [autogen],
                cwd=absolute("libsecp256k1"),
            )

        for filename in [
            "libsecp256k1/configure",
            "libsecp256k1/build-aux/compile",
            "libsecp256k1/build-aux/config.guess",
            "libsecp256k1/build-aux/config.sub",
            "libsecp256k1/build-aux/depcomp",
            "libsecp256k1/build-aux/install-sh",
            "libsecp256k1/build-aux/missing",
            "libsecp256k1/build-aux/test-driver",
        ]:
            try:
                os.chmod(absolute(filename), 0o755)
            except OSError as e:
                # some of these files might not exist depending on autoconf version
                if e.errno != errno.ENOENT:
                    # If the error isn't "No such file or directory" something
                    # else is wrong and we want to know about it
                    raise

        cmd = [
            absolute("libsecp256k1/configure"),
            "--disable-shared",
            "--enable-static",
            "--disable-dependency-tracking",
            "--with-pic",
            "--enable-module-recovery",
            "--prefix",
            os.path.abspath(self.build_clib),
        ]
        if os.environ.get('SECP_BUNDLED_WITH_BIGNUM'):
            log.info("Building with bignum support (requires libgmp)")
            cmd.extend(["--with-bignum=gmp"])
        else:
            cmd.extend(["--without-bignum"])

        if os.environ.get('SECP_BUNDLED_EXPERIMENTAL'):
            log.info("Building experimental")
            cmd.extend([
                "--enable-experimental",
                "--enable-module-ecdh",
                "--enable-module-schnorr",
            ])

        log.debug("Running configure: {}".format(" ".join(cmd)))
        subprocess.check_call(
            cmd,
            cwd=build_temp,
        )

        subprocess.check_call(["make"], cwd=build_temp)
        subprocess.check_call(["make", "install"], cwd=build_temp)

        self.build_flags['include_dirs'].extend(build_flags('libsecp256k1', 'I', build_temp))
        self.build_flags['library_dirs'].extend(build_flags('libsecp256k1', 'L', build_temp))
        if not has_system_lib():
            self.build_flags['define'].append(('CFFI_ENABLE_RECOVERY', None))
        else:
            pass
예제 #9
0
파일: setup.py 프로젝트: ulope/secp256k1-py
 def has_c_libraries(self):
     return not has_system_lib()
예제 #10
0
파일: build.py 프로젝트: ulope/secp256k1-py
_base = [Source(absolute("_cffi_build/secp256k1.h"), "#include <secp256k1.h>")]

_modules = {
    "ecdh": Source(absolute("_cffi_build/secp256k1_ecdh.h"), "#include <secp256k1_ecdh.h>"),
    "recovery": Source(absolute("_cffi_build/secp256k1_recovery.h"), "#include <secp256k1_recovery.h>"),
    "schnorr": Source(absolute("_cffi_build/secp256k1_schnorr.h"), "#include <secp256k1_schnorr.h>"),
}


ffi = None

# The following is used to detect whether the library is already installed on
# the system (and if so which modules are enabled) or if we will use the
# bundled one.
if has_system_lib():
    _available = []
    try:
        # try all combinations of optional modules that could be enabled
        # works downwards from most enabled modules to fewest
        for l in range(len(_modules), -1, -1):
            for combination in combinations(_modules.items(), l):
                try:
                    _test_ffi = _mk_ffi(
                        _base + [item[1] for item in combination],
                        name="_testcompile",
                        bundled=False,
                        libraries=["secp256k1"],
                    )
                    with redirect(sys.stderr, os.devnull), workdir():
                        _test_ffi.compile()