Skip to content

Commit

Permalink
Release 1.16.0rc2 (#13)
Browse files Browse the repository at this point in the history
* move project sources to `src/` subdir (#12)

* move the distutils shim module back to a plain module

* MANIFEST.in, the source layout, and pytest's default sys.path behavior conspired to mask a busted package, even though we were testing against the built package. `pytest` adds cwd to the path first, and since the `cffi` is in the root (grr), even though we're testing against the installed wheel, pytest loaded the subpackage from the source, masking that it was missing from the actual package (due to flat inclusions in MANIFEST.in). This is a longer-term problem that should be addressed by moving to a standard `src/` layout, and possibly also by bringing `_cffi_backend` in as a subpackage, but there are likely many dragons there with wheels that assume the presence of the top-level package.

* move project sources under src/

(cherry picked from commit 932eba2)

* release 1.16.0rc2
  • Loading branch information
nitzmahone committed Sep 26, 2023
1 parent e98d1bb commit e20c65d
Show file tree
Hide file tree
Showing 67 changed files with 48 additions and 39 deletions.
34 changes: 17 additions & 17 deletions .github/workflows/ci.yaml
Expand Up @@ -54,51 +54,51 @@ jobs:

- spec: cp38-manylinux_aarch64
foreign_arch: true
test_args: '{project}/c'
test_args: '{project}/src/c'
- spec: cp39-manylinux_aarch64
foreign_arch: true
test_args: '{project}/c'
test_args: '{project}/src/c'
- spec: cp310-manylinux_aarch64
foreign_arch: true
test_args: '{project}/c'
test_args: '{project}/src/c'
- spec: cp311-manylinux_aarch64
foreign_arch: true
test_args: '{project}/c'
test_args: '{project}/src/c'
- spec: cp312-manylinux_aarch64
foreign_arch: true
test_args: '{project}/c'
test_args: '{project}/src/c'

- spec: cp38-manylinux_ppc64le
foreign_arch: true
test_args: '{project}/c'
test_args: '{project}/src/c'
- spec: cp39-manylinux_ppc64le
foreign_arch: true
test_args: '{project}/c'
test_args: '{project}/src/c'
- spec: cp310-manylinux_ppc64le
foreign_arch: true
test_args: '{project}/c'
test_args: '{project}/src/c'
- spec: cp311-manylinux_ppc64le
foreign_arch: true
test_args: '{project}/c'
test_args: '{project}/src/c'
- spec: cp312-manylinux_ppc64le
foreign_arch: true
test_args: '{project}/c'
test_args: '{project}/src/c'

- spec: cp38-manylinux_s390x
foreign_arch: true
test_args: '{project}/c'
test_args: '{project}/src/c'
- spec: cp39-manylinux_s390x
foreign_arch: true
test_args: '{project}/c'
test_args: '{project}/src/c'
- spec: cp310-manylinux_s390x
foreign_arch: true
test_args: '{project}/c'
test_args: '{project}/src/c'
- spec: cp311-manylinux_s390x
foreign_arch: true
test_args: '{project}/c'
test_args: '{project}/src/c'
- spec: cp312-manylinux_s390x
foreign_arch: true
test_args: '{project}/c'
test_args: '{project}/src/c'

steps:
- name: clone repo
Expand Down Expand Up @@ -261,9 +261,9 @@ jobs:
CIBW_BUILD: ${{ matrix.spec }}
CIBW_PRERELEASE_PYTHONS: 'True'
CIBW_TEST_REQUIRES: pytest setuptools
CIBW_TEST_COMMAND: 'python -m pytest {project}/c'
CIBW_TEST_COMMAND: 'python -m pytest {project}/src/c'
# FIXME: /testing takes ~45min on Windows and has some failures...
# CIBW_TEST_COMMAND='python -m pytest {project}/c {project}/testing'
# CIBW_TEST_COMMAND='python -m pytest {project}/src/c {project}/testing'
run: |
python -m pip install --upgrade pip
pip install "${{ matrix.cibw_version || 'cibuildwheel'}}"
Expand Down
4 changes: 2 additions & 2 deletions MANIFEST.in
@@ -1,5 +1,5 @@
recursive-include cffi *.py *.h
recursive-include c *.c *.h *.asm *.py win64.obj ffi.lib
recursive-include src/cffi *.py *.h
recursive-include src/c *.c *.h *.asm *.py win64.obj ffi.lib
recursive-include testing *.py *.c *.h
recursive-include doc *.py *.rst Makefile *.bat
recursive-include demo py.cleanup *.py embedding_test.c manual.c
Expand Down
2 changes: 1 addition & 1 deletion doc/source/conf.py
Expand Up @@ -47,7 +47,7 @@
# The short X.Y version.
version = '1.16'
# The full version, including alpha/beta/rc tags.
release = '1.16.0rc1'
release = '1.16.0rc2'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
6 changes: 6 additions & 0 deletions doc/source/whatsnew.rst
Expand Up @@ -2,6 +2,12 @@
What's New
======================

v1.16.0rc2
==========

* Fix module packaging issue; move project source under ``src/`` so packaging tests can catch
similar failures in the future.

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

Expand Down
11 changes: 6 additions & 5 deletions setup.py
Expand Up @@ -7,7 +7,7 @@
import setuptools


sources = ['c/_cffi_backend.c']
sources = ['src/c/_cffi_backend.c']
libraries = ['ffi']
include_dirs = ['/usr/include/ffi',
'/usr/include/libffi'] # may be changed by pkg-config
Expand Down Expand Up @@ -125,10 +125,10 @@ def use_homebrew_for_libffi():

if sys.platform == "win32" and uses_msvc():
if platform.machine() == "ARM64":
include_dirs.append(os.path.join("c/libffi_arm64/include"))
library_dirs.append(os.path.join("c/libffi_arm64"))
include_dirs.append(os.path.join("src/c/libffi_arm64/include"))
library_dirs.append(os.path.join("src/c/libffi_arm64"))
else:
COMPILE_LIBFFI = 'c/libffi_x86_x64' # from the CPython distribution
COMPILE_LIBFFI = 'src/c/libffi_x86_x64' # from the CPython distribution
assert os.path.isdir(COMPILE_LIBFFI), "directory not found!"
include_dirs[:] = [COMPILE_LIBFFI]
libraries[:] = []
Expand Down Expand Up @@ -195,9 +195,10 @@ def has_ext_modules(self):
`Mailing list <https://groups.google.com/forum/#!forum/python-cffi>`_
""",
version='1.16.0rc1',
version='1.16.0rc2',
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 {},
Expand Down
2 changes: 1 addition & 1 deletion c/_cffi_backend.c → src/c/_cffi_backend.c
Expand Up @@ -2,7 +2,7 @@
#include <Python.h>
#include "structmember.h"

#define CFFI_VERSION "1.16.0rc1"
#define CFFI_VERSION "1.16.0rc2"

#ifdef MS_WIN32
#include <windows.h>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion c/test_c.py → src/c/test_c.py
Expand Up @@ -26,7 +26,7 @@ def _testfunc(num):
# ____________________________________________________________

import sys
assert __version__ == "1.16.0rc1", ("This test_c.py file is for testing a version"
assert __version__ == "1.16.0rc2", ("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
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions cffi/__init__.py → src/cffi/__init__.py
Expand Up @@ -5,8 +5,8 @@
from .error import CDefError, FFIError, VerificationError, VerificationMissing
from .error import PkgConfigError

__version__ = "1.16.0rc1"
__version_info__ = (1, 16, 0, 'rc1')
__version__ = "1.16.0rc2"
__version_info__ = (1, 16, 0, 'rc2')

# 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
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion cffi/_embedding.h → src/cffi/_embedding.h
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.16.0rc1"
"\ncompiled with cffi version: 1.16.0rc2"
"\n_cffi_backend module: ", f);
modules = PyImport_GetModuleDict();
mod = PyDict_GetItemString(modules, "_cffi_backend");
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 9 additions & 8 deletions testing/cffi0/test_version.py
@@ -1,6 +1,7 @@
import os, sys
import pytest
import cffi, _cffi_backend
from pathlib import Path

def setup_module(mod):
if '_cffi_backend' in sys.builtin_module_names:
Expand All @@ -25,33 +26,33 @@ def test_version():
assert v == _cffi_backend.__version__

def test_doc_version():
parent = os.path.dirname(os.path.dirname(cffi.__file__))
p = os.path.join(parent, 'doc', 'source', 'conf.py')
cffi_root = Path(os.path.dirname(__file__)).parent.parent
p = cffi_root / 'doc/source/conf.py'
content = open(p).read()
#
v = cffi.__version__
assert ("version = '%s'\n" % v[:4]) in content
assert ("release = '%s'\n" % v) in content

def test_setup_version():
parent = os.path.dirname(os.path.dirname(cffi.__file__))
p = os.path.join(parent, 'setup.py')
cffi_root = Path(os.path.dirname(__file__)).parent.parent
p = cffi_root / 'setup.py'
content = open(p).read()
#
v = cffi.__version__.replace('+', '')
assert ("version='%s'" % v) in content

def test_c_version():
parent = os.path.dirname(os.path.dirname(cffi.__file__))
cffi_root = Path(os.path.dirname(__file__)).parent.parent
v = cffi.__version__
p = os.path.join(parent, 'c', 'test_c.py')
p = cffi_root / 'src/c/test_c.py'
content = open(p).read()
#v = BACKEND_VERSIONS.get(v, v)
assert (('assert __version__ == "%s"' % v) in content)

def test_embedding_h():
parent = os.path.dirname(os.path.dirname(cffi.__file__))
cffi_root = Path(os.path.dirname(__file__)).parent.parent
v = cffi.__version__
p = os.path.join(parent, 'cffi', '_embedding.h')
p = cffi_root / 'src/cffi/_embedding.h'
content = open(p).read()
assert ('cffi version: %s"' % (v,)) in content
3 changes: 2 additions & 1 deletion testing/cffi1/test_parse_c_type.py
Expand Up @@ -2,6 +2,7 @@
import pytest
import cffi
from cffi import cffi_opcode
from pathlib import Path

if '__pypy__' in sys.builtin_module_names:
try:
Expand All @@ -11,7 +12,7 @@
# older pytest
pytest.skip("not available on pypy")

cffi_dir = os.path.dirname(cffi_opcode.__file__)
cffi_dir = str(Path(os.path.dirname(__file__)).parent.parent / "src/cffi")

r_macro = re.compile(r"#define \w+[(][^\n]*|#include [^\n]*")
r_define = re.compile(r"(#define \w+) [^\n]*")
Expand Down

0 comments on commit e20c65d

Please sign in to comment.