Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/update v0.4.1 #132

Merged
merged 67 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
802fb77
(feat) secp256k1 v0.4.0
MementoRC Dec 19, 2023
35c8680
(feat) CFFI for new support
MementoRC Dec 20, 2023
93b69b8
(fix) Could not figure out why egg_info adds absolute paths. Prune them
MementoRC Dec 20, 2023
778887e
(feat) Use TOML project definition. Version bump to 19.0.0
MementoRC Dec 20, 2023
6a9380d
(feat) Use TOML project definition. Version bump to 19.0.0
MementoRC Dec 20, 2023
d88e47d
(feat) tox with python 3.12
MementoRC Dec 20, 2023
bfaa1b0
(fix) copy-paste fumble
MementoRC Dec 20, 2023
bfcc546
(fix) missing EOL
MementoRC Dec 20, 2023
4242b8c
(fix) relaxed setuptools constraint
MementoRC Dec 20, 2023
4aa3b09
(fix) issues with mkdocstring
MementoRC Dec 20, 2023
a2654cd
(ref) remove unnecessary dependence
MementoRC Dec 20, 2023
e56a4d6
(ref) remove deprecated functions
MementoRC Dec 20, 2023
90f33ab
(fea) selectable download using pkg-config
MementoRC Dec 20, 2023
9022b08
(fix) path to header for windows
MementoRC Dec 20, 2023
cdc504a
(fix) don't remember why zzz
MementoRC Dec 20, 2023
50be3d5
(fix) bypass download for windows?
MementoRC Dec 20, 2023
948709e
(fix) bypass download for windows. lint check
MementoRC Dec 20, 2023
b8de00c
(fix) use pkgconfig to resolve lib location in windows?
MementoRC Dec 20, 2023
c633c65
(fix) odd ruff fail
MementoRC Dec 20, 2023
ff76128
(dbg) trying to figure out the windows annoyance
MementoRC Dec 20, 2023
45fc8ad
(dbg) trying to figure out the windows annoyance
MementoRC Dec 21, 2023
5e03265
(fix) ffi.dlopen() needs full lib name under windows?
MementoRC Dec 21, 2023
e6ad6a4
(dbg) linking on windows requires to prepend with 'lib', how to do that?
MementoRC Dec 21, 2023
bd0afe0
(fix) linking on windows requires to prepend with 'lib'
MementoRC Dec 21, 2023
5dffd77
(fix) catch PackageNotFoundError when detecting system libsecp256k1
MementoRC Dec 21, 2023
5183f60
(fix) wrong PackageNotFoundError?
MementoRC Dec 21, 2023
3b2bddc
(dbg) libname on windows
MementoRC Dec 21, 2023
e668925
(fix) build for linking shared libsecp256k1 on windows
MementoRC Dec 22, 2023
caf243c
Apply suggestions from code review
ofek Dec 24, 2023
42ddb17
(ref) Move library to API (instead of ABI)
MementoRC Dec 25, 2023
e8f063d
Merge remote-tracking branch 'origin/feat/update_v0.4.0' into feat/up…
MementoRC Dec 25, 2023
2d67b16
(fix) There's an issue with import pkgconfig on windows ...
MementoRC Dec 25, 2023
3e113bf
(fix) There's an issue with import pkgconfig on windows ...
MementoRC Dec 25, 2023
fb6c6a5
(fix) Turning in circles around windows ...
MementoRC Dec 25, 2023
62c0867
(fix) Turning in circles around windows ...
MementoRC Dec 25, 2023
a2a0f8d
(fix) The issue is when building with setup.py (not TOML)
MementoRC Dec 25, 2023
f80097e
(fix) remove pkgconfig, usr pkg-config instead?
MementoRC Dec 26, 2023
cd4239f
(fix) fmt
MementoRC Dec 26, 2023
79e3ca3
(fix) subprocess fails if command exists with 1
MementoRC Dec 26, 2023
20438f3
(fix) back to guessing game :\
MementoRC Dec 26, 2023
8a80653
(ref) Let's have a pkg name, UNKNOWN-0.0.0 is too mysterious
MementoRC Dec 26, 2023
67ff706
(fea) Update to SECP256K1 v0.4.1
MementoRC Dec 26, 2023
ec5f8ff
(fea) which part of "IMPORTANT: Keep in sync" did I not understand?
MementoRC Dec 26, 2023
c48a973
(fix) broke the build with system libs :,(
MementoRC Dec 26, 2023
aa49ab8
(ref) forgot to re-enable windows selection for libname change. depre…
MementoRC Dec 26, 2023
c0b8cf1
(ref) update workflow to python 3.12. cibuildwheels to 2.16.2
MementoRC Dec 26, 2023
d05dc77
(ref) update workflow to python 3.12. cibuildwheel fails due to urlli…
MementoRC Dec 26, 2023
853a55a
(ref) update workflow to python 3.12. cibuildwheel fails due to urlli…
MementoRC Dec 26, 2023
c9bd577
(bld) urllib3>2?
MementoRC Dec 26, 2023
039ddc5
(fix) missing Distribution for system lib case?
MementoRC Dec 26, 2023
aa34de5
(fix) retrofit cibuildwheel to 2.11.2 for linux (urllib3/ssl issue)
MementoRC Dec 26, 2023
e0e9cdc
(fix) why is it not finding the lib?
MementoRC Dec 26, 2023
49cc059
(fix) why is it not finding the lib?
MementoRC Dec 26, 2023
b028137
(fix) why is it not finding the lib?
MementoRC Dec 26, 2023
f9ccbb9
(dbg) why is it not finding the lib?
MementoRC Dec 26, 2023
9d0fb9b
(dbg) too fast to simplify, header not found!
MementoRC Dec 26, 2023
70487e7
(fix) path to headers found?
MementoRC Dec 26, 2023
ed53aca
(fix) byte to string
MementoRC Dec 27, 2023
4031784
(fix) lint/fmt
MementoRC Dec 27, 2023
bbc8e0b
(dbg) back to squre one on conda recipe ... it downloads :/
MementoRC Dec 27, 2023
94723ac
(ref) silly, I don't need to commit, just patch-debug the recipe
MementoRC Dec 27, 2023
35b775b
(ref) silly, I don't need to commit, just patch-debug the recipe
MementoRC Dec 27, 2023
f8bb9fc
(ref) silly, I don't need to commit, just patch-debug the recipe
MementoRC Dec 27, 2023
75f9a5c
(ref) correct differences between pkg-config and pkgconfig
MementoRC Dec 27, 2023
d315b13
(fix) Do we need env?
MementoRC Dec 28, 2023
e8aa04d
Apply suggestions from code review
ofek Jan 11, 2024
a5c46cb
Apply suggestions from code review
ofek Jan 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ concurrency:
cancel-in-progress: true

env:
COINCURVE_UPSTREAM_REF: acf5c55ae6a94e5ca847e07def40427547876101
COINCURVE_UPSTREAM_REF: 1ad5185cd42c0636104129fcc9f6a4bf9c67cc40
COINCURVE_IGNORE_SYSTEM_LIB: '1'
CIBW_BEFORE_ALL_MACOS: ./.github/scripts/install-macos-build-deps.sh
CIBW_ENVIRONMENT_PASS_LINUX: >
Expand All @@ -38,7 +38,7 @@ jobs:
runs-on: ubuntu-latest

env:
PYTHON_VERSION: '3.10'
PYTHON_VERSION: '3.12'

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -75,7 +75,7 @@ jobs:
name: Build Linux wheels
needs:
- test
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3
Expand All @@ -99,7 +99,7 @@ jobs:
- uses: actions/checkout@v3

- name: Build wheels
uses: pypa/cibuildwheel@v2.11.2
uses: pypa/cibuildwheel@v2.16.2
env:
CIBW_ARCHS_MACOS: x86_64

Expand All @@ -119,7 +119,7 @@ jobs:
- uses: actions/checkout@v3

- name: Build wheels
uses: pypa/cibuildwheel@v2.11.2
uses: pypa/cibuildwheel@v2.16.2
env:
CIBW_ARCHS_MACOS: arm64
COINCURVE_CROSS_HOST: aarch64-apple-darwin
Expand Down Expand Up @@ -174,7 +174,7 @@ jobs:
platforms: arm64

- name: Build wheels
uses: pypa/cibuildwheel@v2.11.2
uses: pypa/cibuildwheel@v2.16.2
env:
CIBW_ARCHS_LINUX: aarch64

Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include coincurve/py.typed
include setup_support.py
recursive-include _cffi_build *.py *.h
prune /*
graft libsecp256k1
2 changes: 2 additions & 0 deletions _cffi_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def _mk_ffi(sources, name='_libsecp256k1', **kwargs):
Source('secp256k1_extrakeys.h', '#include <secp256k1_extrakeys.h>'),
Source('secp256k1_recovery.h', '#include <secp256k1_recovery.h>'),
Source('secp256k1_schnorrsig.h', '#include <secp256k1_schnorrsig.h>'),
Source('secp256k1_ellswift.h', '#include <secp256k1_ellswift.h>'),
Source('secp256k1_preallocated.h', '#include <secp256k1_preallocated.h>'),
]

ffi = _mk_ffi(modules, libraries=['secp256k1'])
84 changes: 84 additions & 0 deletions _cffi_build/build_shared.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import argparse
import logging
import os
from collections import namedtuple
from typing import List

from cffi import FFI

logging.basicConfig(level=logging.INFO)

here = os.path.dirname(os.path.abspath(__file__))

Source = namedtuple('Source', ('h', 'include'))


def gather_sources_from_directory(directory: str) -> List[Source]:
"""
Gather source files from a given directory.

:param directory: The directory where source files are located.
:return: A list of Source namedtuples.
"""
sources = []
for filename in os.listdir(directory):
if filename.endswith('.h'):
include_line = f'#include <{filename}>'
sources.append(Source(filename, include_line))
return sorted(sources)


define_static_lib = """
#if defined(_WIN32)
# define SECP256K1_STATIC 1
# define SECP256K1_API extern __declspec(dllexport)
#endif
"""

define_shared_lib = """
#if defined(_WIN32)
# define SECP256K1_API extern __declspec(dllimport)
#endif
"""


def mk_ffi(sources: List[Source],
static_lib: str = '0',
name: str = '_libsecp256k1') -> FFI:
"""
Create an FFI object.

:param sources: A list of Source namedtuples.
:param libraries: A list of libraries to link against.
:param static_lib: Whether to generate a static lib in Windows.
:param name: The name of the FFI object.
:return: An FFI object.
"""
_ffi = FFI()
code = [define_static_lib] if static_lib == '1' else [define_shared_lib]

for source in sources:
with open(os.path.join(here, source.h)) as h:
logging.info(f' Including {source.h}...')
c_header = h.read().replace('SECP256K1_API', '')
_ffi.cdef(c_header)

code.append(source.include)

code.append('#define PY_USE_BUNDLED')
_ffi.set_source(name, '\n'.join(code))

return _ffi


if __name__ == '__main__':
logging.info('Starting CFFI build process...')
parser = argparse.ArgumentParser(description='Generate C code using CFFI.')
parser.add_argument('c_file', help='Generated C code filename.')
parser.add_argument('static_lib', help='Generate static lib in Windows.', default=False)
args = parser.parse_args()

modules = gather_sources_from_directory(here)
ffi = mk_ffi(modules, args.static_lib)
ffi.emit_c_code(args.c_file)
logging.info(f' Generated C code: {args.c_file}')
Loading
Loading