Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
arigo committed Oct 29, 2024
2 parents fcb8594 + 88f48d2 commit 6870f5a
Show file tree
Hide file tree
Showing 21 changed files with 181 additions and 109 deletions.
30 changes: 19 additions & 11 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ env:
jobs:
python_sdist:
runs-on: ubuntu-22.04
outputs:
sdist_artifact_name: ${{ steps.build_sdist.outputs.sdist_artifact_name }}
package_version: ${{ steps.build_sdist.outputs.package_version }}
steps:
- name: clone repo
uses: actions/checkout@v4
Expand All @@ -45,13 +48,14 @@ jobs:
python -m pip install build
python -m build --sdist
echo "artifact_name=$(ls ./dist)" >> "$GITHUB_OUTPUT"
echo "sdist_artifact_name=$(ls ./dist)" >> "$GITHUB_OUTPUT"
echo "package_version=$(ls ./dist | sed -En 's/cffi-(.+)\.tar\.gz/\1/p')" >> "$GITHUB_OUTPUT"
- name: upload sdist artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.build_sdist.outputs.artifact_name }}
path: dist/${{ steps.build_sdist.outputs.artifact_name }}
name: ${{ steps.build_sdist.outputs.sdist_artifact_name }}
path: dist/${{ steps.build_sdist.outputs.sdist_artifact_name }}
if-no-files-found: error
# always upload the sdist artifact- all the wheel build jobs require it

Expand Down Expand Up @@ -83,6 +87,9 @@ jobs:
omit: ${{ env.skip_ci_redundant_jobs }}
- spec: cp313-manylinux_x86_64
- spec: cp313t-manylinux_x86_64
skip_artifact_upload: 'true'
- spec: cp38-manylinux_i686
omit: ${{ env.skip_ci_redundant_jobs }}
Expand Down Expand Up @@ -258,7 +265,7 @@ jobs:
id: fetch_sdist
uses: actions/download-artifact@v4
with:
name: ${{ needs.build_sdist.outputs.artifact_name }}
name: ${{ needs.python_sdist.outputs.sdist_artifact_name }}

- name: configure docker foreign arch support
uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -290,14 +297,15 @@ jobs:
CIBW_MUSLLINUX_I686_IMAGE: ${{ matrix.musllinux_img || 'musllinux_1_1' }}
CIBW_MUSLLINUX_AARCH64_IMAGE: ${{ matrix.musllinux_img || 'musllinux_1_1' }}
CIBW_PRERELEASE_PYTHONS: 'True'
CIBW_FREE_THREADED_SUPPORT: 'True'
CIBW_TEST_REQUIRES: pytest setuptools # 3.12+ no longer includes distutils, just always ensure setuptools is present
CIBW_TEST_COMMAND: PYTHONUNBUFFERED=1 python -m pytest ${{ matrix.test_args || '{project}' }} # default to test all
run: |
set -eux
mkdir cffi
tar zxf ${{ steps.fetch_sdist.outputs.download-path }}/cffi*.tar.gz/cffi*.tar.gz --strip-components=1 -C cffi
tar zxf ${{ steps.fetch_sdist.outputs.download-path }}/cffi*.tar.gz --strip-components=1 -C cffi
python -m pip install --upgrade "${{ matrix.cibw_version || 'cibuildwheel' }}"
# actually build libffi + wheel (using env tweaks above)
Expand All @@ -311,7 +319,7 @@ jobs:
name: ${{ steps.build.outputs.artifact_name }}
path: dist/*.whl
if-no-files-found: error
if: ${{ env.skip_artifact_upload != 'true' }}
if: ${{ (matrix.skip_artifact_upload != 'true') && (env.skip_artifact_upload != 'true') }}

make_macos_matrix:
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -390,7 +398,7 @@ jobs:
id: fetch_sdist
uses: actions/download-artifact@v4
with:
name: ${{ needs.build_sdist.outputs.artifact_name }}
name: ${{ needs.python_sdist.outputs.sdist_artifact_name }}

- name: install python
uses: actions/setup-python@v5
Expand Down Expand Up @@ -418,7 +426,7 @@ jobs:
mkdir cffi
tar zxf ${{ steps.fetch_sdist.outputs.download-path }}/cffi*.tar.gz/cffi*.tar.gz --strip-components=1 -C cffi
tar zxf ${{ steps.fetch_sdist.outputs.download-path }}/cffi*.tar.gz --strip-components=1 -C cffi
python3 -m cibuildwheel --output-dir dist cffi
Expand Down Expand Up @@ -493,7 +501,7 @@ jobs:
id: fetch_sdist
uses: actions/download-artifact@v4
with:
name: ${{ needs.build_sdist.outputs.artifact_name }}
name: ${{ needs.python_sdist.outputs.sdist_artifact_name }}

- name: build/test wheels
id: build
Expand All @@ -509,7 +517,7 @@ jobs:
mkdir cffi
tar zxf cffi*.tar.gz/cffi*.tar.gz --strip-components=1 -C cffi
tar zxf cffi*.tar.gz --strip-components=1 -C cffi
python -m pip install --upgrade pip
pip install "${{ matrix.cibw_version || 'cibuildwheel'}}"
Expand All @@ -534,7 +542,7 @@ jobs:
- name: merge all artifacts
uses: actions/upload-artifact/merge@v4
with:
name: dist
name: dist-cffi-${{ needs.python_sdist.outputs.package_version }}
delete-merged: true
if: ${{ env.skip_artifact_upload != 'true' }}

Expand Down
12 changes: 12 additions & 0 deletions doc/source/cdef.rst
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,12 @@ write). If you choose, you can include this .py file pre-packaged in
your own distributions: it is identical for any Python version (2 or
3).

*New in version 1.17.1:* ``filename`` can instead be a file-like object
(such as a StringIO instance). The generated code will be written to this
file-like object. However, if an error arises during generation, partial
code may be written; it is the caller's responsibility to clean up
if this occurs.

**ffibuilder.emit_c_code(filename):** generate the given .c file (for API
mode) without compiling it. Can be used if you have some other method
to compile it, e.g. if you want to integrate with some larger build
Expand All @@ -676,6 +682,12 @@ platform, the .c file itself is generic (it would be exactly the same
if produced on a different OS, with a different version of CPython, or
with PyPy; it is done with generating the appropriate ``#ifdef``).

*New in version 1.17.1:* ``filename`` can instead be a file-like object
(such as a StringIO instance). The generated code will be written to this
file-like object. However, if an error arises during generation, partial
code may be written; it is the caller's responsibility to clean up
if this occurs.

**ffibuilder.distutils_extension(tmpdir='build', verbose=True):** for
distutils-based ``setup.py`` files. Calling this creates the .c file
if needed in the given ``tmpdir``, and returns a
Expand Down
4 changes: 2 additions & 2 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
# built documents.
#
# The short X.Y version.
version = '1.17'
version = '1.18'
# The full version, including alpha/beta/rc tags.
release = '1.17.0.dev0'
release = '1.18.0.dev0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
27 changes: 23 additions & 4 deletions doc/source/whatsnew.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,24 @@
What's New
======================

v1.17
=====
v1.18.0.dev0
============

* WIP

v1.17.1
=======

* Fix failing ``distutils.msvc9compiler`` imports under Windows (`#118`_).
* ``ffibuilder.emit_python_code()`` and ``ffibuiler.emit_c_code()`` accept file-like objects (`#115`_).
* ``ffiplatform`` calls are bypassed by ``ffibuilder.emit_python_code()`` and ``ffibuilder.emit_c_code()`` (`#81`_).

.. _`#118`: https://github.com/python-cffi/cffi/pull/118
.. _`#115`: https://github.com/python-cffi/cffi/pull/115
.. _`#81`: https://github.com/python-cffi/cffi/pull/81

v1.17.0
=======

* In API mode, when you get a function from a C library by writing
`fn = lib.myfunc`, you get an object of a special type for performance
Expand All @@ -18,8 +34,8 @@ v1.17
structure field of the correct pointer-to-function type, or use
`ffi.cast()` or `ffi.typeof()` on it.

v1.16.0rc1
==========
v1.16.0
=======

* Add support for Python 3.12. With the removal of ``distutils`` from Python 3.12, projects
using CFFI features that depend on ``distutils`` at runtime must add a dependency on
Expand All @@ -29,6 +45,9 @@ v1.16.0rc1
* Add support for PEP517 builds; ``setuptools`` is now a required build dependency.
* Declare ``python_requires`` metadata for Python 3.8+. This allows unsupported Pythons
to continue using previously released sdists and wheels.
* Upstream project hosting moved from Heptapod to `GitHub`_.

.. _`GitHub`: https://github.com/python-cffi/cffi

v1.15.1
=======
Expand Down
43 changes: 43 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,46 @@ requires = [
"setuptools >= 66.1"
]
build-backend = "setuptools.build_meta"

[project]
name = "cffi"
version = "1.18.0.dev0"
dependencies = [
"pycparser; implementation_name != 'PyPy'",
]
requires-python = ">=3.8"

description = "Foreign Function Interface for Python calling C code."
readme = {file = "README.md", content-type = "text/markdown"}
classifiers = [
"Programming Language :: Python",
"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 :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"License :: OSI Approved :: MIT License",
]
authors = [
{name = "Armin Rigo"},
{name = "Maciej Fijalkowski"},
]
maintainers = [
{name = "Matt Davis"},
{name = "Matt Clay"},
]

[project.entry-points."distutils.setup_keywords"]
cffi_modules = "cffi.setuptools_ext:cffi_modules"

[project.urls]
Documentation = "https://cffi.readthedocs.io/"
Changelog = "https://cffi.readthedocs.io/en/latest/whatsnew.html"
Downloads = "https://github.com/python-cffi/cffi/releases"
Contact = "https://groups.google.com/forum/#!forum/python-cffi"
"Source Code" = "https://github.com/python-cffi/cffi"
"Issue Tracker" = "https://github.com/python-cffi/cffi/issues"
10 changes: 0 additions & 10 deletions setup.cfg

This file was deleted.

48 changes: 0 additions & 48 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,40 +176,14 @@ def has_ext_modules(self):
# arguments mostly empty in this case.
cpython = ('_cffi_backend' not in sys.builtin_module_names)

install_requires = []
if cpython:
install_requires.append('pycparser')

setup(
name='cffi',
description='Foreign Function Interface for Python calling C code.',
long_description="""
CFFI
====
Foreign Function Interface for Python calling C code.
Please see the `Documentation <http://cffi.readthedocs.org/>`_.
Contact
-------
`Mailing list <https://groups.google.com/forum/#!forum/python-cffi>`_
""",
version='1.17.0.dev0',
python_requires='>=3.8',
packages=['cffi'] if cpython else [],
package_dir={"": "src"},
package_data={'cffi': ['_cffi_include.h', 'parse_c_type.h',
'_embedding.h', '_cffi_errors.h']}
if cpython else {},
zip_safe=False,

url='http://cffi.readthedocs.org',
author='Armin Rigo, Maciej Fijalkowski',
author_email='python-cffi@googlegroups.com',

license='MIT',

distclass=CFFIDistribution,
ext_modules=[Extension(
name='_cffi_backend',
Expand All @@ -222,26 +196,4 @@ def has_ext_modules(self):
extra_link_args=extra_link_args,
extra_objects=forced_extra_objs,
)] if cpython else [],

install_requires=install_requires,

entry_points = {
"distutils.setup_keywords": [
"cffi_modules = cffi.setuptools_ext:cffi_modules",
],
},

classifiers=[
'Programming Language :: Python',
'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 :: 3.13',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'License :: OSI Approved :: MIT License',
],
)
2 changes: 1 addition & 1 deletion src/c/_cffi_backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <Python.h>
#include "structmember.h"

#define CFFI_VERSION "1.17.0.dev0"
#define CFFI_VERSION "1.18.0.dev0"

#ifdef MS_WIN32
#include <windows.h>
Expand Down
2 changes: 1 addition & 1 deletion src/c/test_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def _capture_unraisable_hook(ur_args):
# ____________________________________________________________

import sys
assert __version__ == "1.17.0.dev0", ("This test_c.py file is for testing a version"
assert __version__ == "1.18.0.dev0", ("This test_c.py file is for testing a version"
" of cffi that differs from the one that we"
" get from 'import _cffi_backend'")
if sys.version_info < (3,):
Expand Down
4 changes: 2 additions & 2 deletions src/cffi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from .error import CDefError, FFIError, VerificationError, VerificationMissing
from .error import PkgConfigError

__version__ = "1.17.0.dev0"
__version_info__ = (1, 17, 0, 'dev0')
__version__ = "1.18.0.dev0"
__version_info__ = (1, 18, 0, 'dev0')

# The verifier module file names are based on the CRC32 of a string that
# contains the following version number. It may be older than __version__
Expand Down
2 changes: 1 addition & 1 deletion src/cffi/_embedding.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ static int _cffi_initialize_python(void)

if (f != NULL && f != Py_None) {
PyFile_WriteString("\nFrom: " _CFFI_MODULE_NAME
"\ncompiled with cffi version: 1.17.0.dev0"
"\ncompiled with cffi version: 1.18.0.dev0"
"\n_cffi_backend module: ", f);
modules = PyImport_GetModuleDict();
mod = PyDict_GetItemString(modules, "_cffi_backend");
Expand Down
6 changes: 5 additions & 1 deletion src/cffi/_shimmed_dist_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@
from distutils.log import set_threshold, set_verbosity

if sys.platform == 'win32':
from distutils.msvc9compiler import MSVCCompiler
try:
# FUTURE: msvc9compiler module was removed in setuptools 74; consider removing, as it's only used by an ancient patch in `recompiler`
from distutils.msvc9compiler import MSVCCompiler
except ImportError:
MSVCCompiler = None
except Exception as ex:
if sys.version_info >= (3, 12):
raise Exception("This CFFI feature requires setuptools on Python >= 3.12. Please install the setuptools package.") from ex
Expand Down
Loading

0 comments on commit 6870f5a

Please sign in to comment.