Skip to content

Commit

Permalink
Minimally migrate to pyproject.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
alex committed Jun 30, 2024
1 parent 37da768 commit a0ac97e
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 75 deletions.
40 changes: 17 additions & 23 deletions .github/workflows/wheel-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,21 @@ jobs:
persist-credentials: false
- run: ${{ matrix.PYTHON.PATH }} -m venv .venv
- name: Install python dependencies
run: .venv/bin/pip install -U pip cffi wheel
- name: Make sdist
run: .venv/bin/python setup.py sdist
- run: tar zxvf dist/PyNaCl*.tar.gz && mkdir tmpwheelhouse
run: .venv/bin/pip install -U pip cffi wheel build
- run: |
mkdir tmpwheelhouse
if [ -n "${{ matrix.PYTHON.ABI_VERSION }}" ]; then
PY_LIMITED_API="--py-limited-api=${{ matrix.PYTHON.ABI_VERSION }}"
PY_LIMITED_API="--config-setting=--build-option=--py-limited-api=${{ matrix.PYTHON.ABI_VERSION }}"
fi
cd PyNaCl*
LIBSODIUM_MAKE_ARGS="-j$(nproc)" ../.venv/bin/python setup.py bdist_wheel $PY_LIMITED_API && mv dist/PyNaCl*.whl ../tmpwheelhouse
- run: auditwheel repair --plat ${{ matrix.MANYLINUX.NAME }} tmpwheelhouse/PyNaCl*.whl -w wheelhouse/
LIBSODIUM_MAKE_ARGS="-j$(nproc)" .venv/bin/python -m build --wheel $PY_LIMITED_API
mv dist/pynacl*.whl tmpwheelhouse/
- run: auditwheel repair --plat ${{ matrix.MANYLINUX.NAME }} tmpwheelhouse/pynacl*.whl -w wheelhouse/
- run: .venv/bin/pip install pynacl --no-index -f wheelhouse/
- run: |
.venv/bin/python -c "import nacl.signing; key = nacl.signing.SigningKey.generate();signature = key.sign(b'test'); key.verify_key.verify(signature)"
- run: mkdir pynacl-wheelhouse
- run: mv wheelhouse/PyNaCl*.whl pynacl-wheelhouse/
- run: mv wheelhouse/pynacl*.whl pynacl-wheelhouse/
- uses: actions/upload-artifact@v4
with:
name: "pynacl-${{ github.event.inputs.version }}-${{ matrix.MANYLINUX.NAME }}- ${{ matrix.PYTHON.VERSION }}"
Expand Down Expand Up @@ -91,15 +89,13 @@ jobs:
PYTHON_DOWNLOAD_URL: ${{ matrix.PYTHON.DOWNLOAD_URL }}
- run: ${{ matrix.PYTHON.BIN_PATH }} -m pip install -U virtualenv
- run: ${{ matrix.PYTHON.BIN_PATH }} -m virtualenv venv
- run: venv/bin/pip install -U pip wheel cffi
- name: Make sdist
run: venv/bin/python setup.py sdist
- run: tar zxvf dist/pynacl*.tar.gz && mkdir wheelhouse
- run: venv/bin/pip install -U pip wheel cffi build
- name: Build the wheel
run: |
cd pynacl*
mkdir wheelhouse
LIBSODIUM_MAKE_ARGS="-j$(sysctl -n hw.ncpu)" \
../venv/bin/python setup.py bdist_wheel --py-limited-api=${{ matrix.PYTHON.ABI_VERSION }} && mv dist/PyNaCl*.whl ../wheelhouse
venv/bin/python -m wheel --config-setting=--build-option=--py-limited-api=${{ matrix.PYTHON.ABI_VERSION }}
mv dist/pynacl*.whl wheelhouse/
env:
PYTHON_VERSION: ${{ matrix.PYTHON.ABI_VERSION }}
MACOSX_DEPLOYMENT_TARGET: '10.10'
Expand All @@ -111,7 +107,7 @@ jobs:
venv/bin/python -c "import nacl.signing; key = nacl.signing.SigningKey.generate();signature = key.sign(b'test'); key.verify_key.verify(signature)"
- run: mkdir pynacl-wheelhouse
- run: mv wheelhouse/PyNaCl*.whl pynacl-wheelhouse/
- run: mv wheelhouse/pynacl*.whl pynacl-wheelhouse/
- uses: actions/upload-artifact@v4
with:
name: "pynacl-${{ github.event.inputs.version }}-macOS-${{ matrix.PYTHON.VERSION }}"
Expand Down Expand Up @@ -148,15 +144,13 @@ jobs:
shell: bash

- name: Install wheel and our Python dependencies
run: python -m pip install -U pip wheel cffi
- name: Make sdist
run: python setup.py sdist
- run: tar zxvf dist/PyNaCl*.tar.gz && mkdir wheelhouse
shell: bash
run: python -m pip install -U pip wheel cffi build
- name: Build the wheel
run: |
mkdir wheelhouse
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsDevCmd.bat" -no_logo -arch=${{ matrix.WINDOWS.VS_ARCH }}
cd PyNaCl* && python setup.py bdist_wheel --py-limited-api=${{ matrix.PYTHON.ABI_VERSION }} && mv dist/PyNaCl*.whl ../wheelhouse
python -m build --wheel --config-setting=--build-option=--py-limited-api=${{ matrix.PYTHON.ABI_VERSION }}
mv dist/pynacl*.whl wheelhouse/
shell: cmd
env:
PYNACL_SODIUM_LIBRARY_NAME: sodium
Expand All @@ -168,7 +162,7 @@ jobs:
run: |
python -c "import nacl.signing; key = nacl.signing.SigningKey.generate();signature = key.sign(b'test'); key.verify_key.verify(signature)"
- run: mkdir pynacl-wheelhouse
- run: move wheelhouse\PyNaCl*.whl pynacl-wheelhouse\
- run: move wheelhouse\pynacls*.whl pynacl-wheelhouse\
- uses: actions/upload-artifact@v4
with:
name: "pynacl-${{ github.event.inputs.version }}-win-${{ matrix.WINDOWS.ARCH }}-${{ matrix.PYTHON.VERSION }}"
Expand Down
42 changes: 40 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,50 @@
[build-system]
# Must be kept in sync with `setup_requirements` in `setup.py`
# Must be kept in sync with `dependencies` below
requires = [
"setuptools>=40.8.0",
"setuptools>=61.0.0",
"wheel",
"cffi>=1.4.1; platform_python_implementation != 'PyPy'",
]
build-backend = "setuptools.build_meta"

[project]
dynamic = ["readme"]

name = "PyNaCl"
# Must be kept in sync with `src/nacl/__init__.py`
version = "1.6.0.dev1"
authors = [
{name = "The PyNaCl developers", email = "[email protected]"}
]
description = "Python binding to the Networking and Cryptography (NaCl) library"
license = {text = "Apache-2.0"}
classifiers = [
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"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",
]
requires-python = ">=3.6"
dependencies = [
"cffi>=1.4.1; platform_python_implementation != 'PyPy'"
]

[project.optional-dependencies]
tests = [
"pytest>=3.2.1,!=3.3.0",
"hypothesis>=3.27.0",
]
docs = [
"sphinx<7",
"sphinx_rtd_theme"
]

[tool.black]
line-length = 79
target-version = ["py36"]
Expand Down
35 changes: 0 additions & 35 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,12 @@
from setuptools.command.build_ext import build_ext as _build_ext


requirements = []
setup_requirements = ["setuptools"]
test_requirements = [
"pytest>=3.2.1,!=3.3.0",
"hypothesis>=3.27.0",
]
docs_requirements = ["sphinx<7", "sphinx_rtd_theme"]


if platform.python_implementation() == "PyPy":
if sys.pypy_version_info < (2, 6):
raise RuntimeError(
"PyNaCl is not compatible with PyPy < 2.6. Please "
"upgrade PyPy to use this library."
)
else:
requirements.append("cffi>=1.4.1")
setup_requirements.append("cffi>=1.4.1")


def here(*paths):
Expand Down Expand Up @@ -194,19 +182,8 @@ def run(self):


setup(
name=nacl.__title__,
version=nacl.__version__,
description=nacl.__summary__,
long_description="\n".join((README, INSTALL, CHANGELOG)),
url=nacl.__uri__,
license=nacl.__license__,
author=nacl.__author__,
author_email=nacl.__email__,
python_requires=">=3.6",
setup_requires=setup_requirements,
install_requires=requirements,
extras_require={"tests": test_requirements, "docs": docs_requirements},
tests_require=test_requirements,
package_dir={"": "src"},
packages=["nacl", "nacl.pwhash", "nacl.bindings"],
package_data={"nacl": ["py.typed"]},
Expand All @@ -215,16 +192,4 @@ def run(self):
cmdclass={"build_clib": build_clib, "build_ext": build_ext},
distclass=Distribution,
zip_safe=False,
classifiers=[
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"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",
],
)
16 changes: 1 addition & 15 deletions src/nacl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,12 @@


__all__ = [
"__title__",
"__summary__",
"__uri__",
"__version__",
"__author__",
"__email__",
"__license__",
"__copyright__",
]

__title__ = "PyNaCl"
__summary__ = (
"Python binding to the Networking and Cryptography (NaCl) library"
)
__uri__ = "https://github.com/pyca/pynacl/"

# Must be kept in sync with `pyproject.toml`
__version__ = "1.6.0.dev1"

__author__ = "The PyNaCl developers"
__email__ = "[email protected]"

__license__ = "Apache License 2.0"
__copyright__ = "Copyright 2013-2018 {}".format(__author__)

0 comments on commit a0ac97e

Please sign in to comment.