Skip to content

Commit

Permalink
FEAT: from setup to pyproject (#161)
Browse files Browse the repository at this point in the history
* FEAT: from setup to pyproject

* (ref) setuptools version should not be an issue

* (ref) no longer need to extract version

* (ref) package-data

* (ref) python -m build for windows (temporary, since CMake builds native)

* (fix) lint setuptools.__version__

* (fix) let's be fancy. python -m build FTW

* (cos) clean comments

* (cos) simpler command
  • Loading branch information
MementoRC authored Mar 20, 2024
1 parent b9f0930 commit 5e46aca
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 69 deletions.
8 changes: 4 additions & 4 deletions .github/scripts/build-windows-wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ cp 64bit 32bit -R

cd 64bit
build_dll x86_64-w64-mingw32
# Not sure why it ended-up being a -2.dll instead of -0.dll: Researching
# As the API changes, the -x.dll will change to -y.dll, so we use a wildcard
mv .libs/libsecp256k1-?.dll ../clean/src/coincurve/libsecp256k1.dll
cd ../clean
python setup.py bdist_wheel --plat-name=win_amd64 -vvv
python -m build --wheel -C="--build-option=--plat-name win_amd64"
rm src/coincurve/libsecp256k1.dll
rm -rf build/temp.*

cd ../32bit
build_dll i686-w64-mingw32
# Not sure why it ended-up being a -2.dll instead of -0.dll: Researching
# As the API changes, the -x.dll will change to -y.dll, so we use a wildcard
mv .libs/libsecp256k1-?.dll ../clean/src/coincurve/libsecp256k1.dll
cd ../clean
python setup.py bdist_wheel --plat-name=win32
python -m build --wheel -C="--build-option--plat-name win32"

mv dist/* ../coincurve/dist
cd ../coincurve
60 changes: 59 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,65 @@
[build-system]
requires = ["setuptools>=61", "cffi>=1.3.0", "requests"]
requires = ["setuptools>=61", "cffi>=1.3.0", "requests", "setuptools-scm", 'asn1crypto']
build-backend = "setuptools.build_meta"

[project]
name = "coincurve"
authors = [
{ name="Ofek Lev", email="oss@ofek.dev" },
]
description = "Cross-platform Python CFFI bindings for libsecp256k1"
keywords = ["secp256k1", "crypto", "elliptic curves", "bitcoin", "ethereum", "cryptocurrency"]
requires-python = ">=3.8"
dependencies = [
"asn1crypto",
"cffi>=1.3.0"
]
classifiers = [
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'License :: OSI Approved :: Apache Software License',
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Software Development :: Libraries',
'Topic :: Security :: Cryptography',
]
dynamic = ['version', 'readme']

[project.optional-dependencies]
dev = [
"coverage",
"pytest",
"pytest-benchmark"
]

[project.urls]
Homepage = "https://github.com/ofek/coincurve"
Documentation = "https://ofek.dev/coincurve/"
Repository = "https://github.com/ofek/coincurve"
"Bug Tracker" = "https://github.com/ofek/coincurve/issues"

# --- setuptools ---
[tool.setuptools]
packages = ['coincurve']
package-dir = {'' = 'src'}
package-data = {'coincurve' = ['py.typed']}

[tool.setuptools.dynamic]
version = {attr = "coincurve._version.__version__"}
readme = {content-type = "text/markdown", file = "README.md"}

# --- hatch ---

[tool.pytest.ini_options]
addopts = [
"--import-mode=importlib",
Expand Down
65 changes: 1 addition & 64 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from os.path import join
from sys import path as PATH

from setuptools import Distribution as _Distribution, setup, __version__ as setuptools_version
from setuptools import Distribution as _Distribution, setup
from setuptools.extension import Extension

# Define the package root directory and add it to the system path
Expand All @@ -29,20 +29,6 @@

LIB_TARBALL_URL = f'https://github.com/bitcoin-core/secp256k1/archive/{UPSTREAM_REF}.tar.gz'

globals_ = {}
with open(join(COINCURVE_ROOT_DIR, 'src', 'coincurve', '_version.py')) as fp:
exec(fp.read(), globals_) # noqa S102
__version__ = globals_['__version__']

# We require setuptools >= 3.3
if [int(i) for i in setuptools_version.split('.', 2)[:2]] < [3, 3]:
raise SystemExit(
f'Your setuptools version ({setuptools_version}) is too old to correctly install this package. Please upgrade '
f'to a newer version (>= 3.3).'
)

package_data = {'coincurve': ['py.typed']}


def main():
from setup_tools.commands import BdistWheel, EggInfo, Sdist, Develop
Expand Down Expand Up @@ -96,7 +82,6 @@ class Distribution(_Distribution):
def is_pure(self):
return False

package_data['coincurve'].append('libsecp256k1.dll')
setup_kwargs = {}

else:
Expand All @@ -119,56 +104,8 @@ def has_c_libraries(self):
)

setup(
name='coincurve',
version=__version__,

description='Cross-platform Python CFFI bindings for libsecp256k1',
long_description=open('README.md', 'r').read(),
long_description_content_type='text/markdown',
author_email='Ofek Lev <oss@ofek.dev>',
license='MIT OR Apache-2.0',

python_requires='>=3.8',
setup_requires=['cffi>=1.3.0'],
install_requires=['asn1crypto', 'cffi>=1.3.0'],

packages=['coincurve'],
package_dir={'coincurve': 'src/coincurve'},

distclass=Distribution,
zip_safe=False,

project_urls={
'Documentation': 'https://ofek.dev/coincurve/',
'Issues': 'https://github.com/ofek/coincurve/issues',
'Source': 'https://github.com/ofek/coincurve',
},
keywords=[
'secp256k1',
'crypto',
'elliptic curves',
'bitcoin',
'ethereum',
'cryptocurrency',
],
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'License :: OSI Approved :: Apache Software License',
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Software Development :: Libraries',
'Topic :: Security :: Cryptography',
],
**setup_kwargs
)

Expand Down

0 comments on commit 5e46aca

Please sign in to comment.