Skip to content

Commit 932eba2

Browse files
authored
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/
1 parent 475c466 commit 932eba2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+35
-32
lines changed

.github/workflows/ci.yaml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,51 +54,51 @@ jobs:
5454

5555
- spec: cp38-manylinux_aarch64
5656
foreign_arch: true
57-
test_args: '{project}/c'
57+
test_args: '{project}/src/c'
5858
- spec: cp39-manylinux_aarch64
5959
foreign_arch: true
60-
test_args: '{project}/c'
60+
test_args: '{project}/src/c'
6161
- spec: cp310-manylinux_aarch64
6262
foreign_arch: true
63-
test_args: '{project}/c'
63+
test_args: '{project}/src/c'
6464
- spec: cp311-manylinux_aarch64
6565
foreign_arch: true
66-
test_args: '{project}/c'
66+
test_args: '{project}/src/c'
6767
- spec: cp312-manylinux_aarch64
6868
foreign_arch: true
69-
test_args: '{project}/c'
69+
test_args: '{project}/src/c'
7070

7171
- spec: cp38-manylinux_ppc64le
7272
foreign_arch: true
73-
test_args: '{project}/c'
73+
test_args: '{project}/src/c'
7474
- spec: cp39-manylinux_ppc64le
7575
foreign_arch: true
76-
test_args: '{project}/c'
76+
test_args: '{project}/src/c'
7777
- spec: cp310-manylinux_ppc64le
7878
foreign_arch: true
79-
test_args: '{project}/c'
79+
test_args: '{project}/src/c'
8080
- spec: cp311-manylinux_ppc64le
8181
foreign_arch: true
82-
test_args: '{project}/c'
82+
test_args: '{project}/src/c'
8383
- spec: cp312-manylinux_ppc64le
8484
foreign_arch: true
85-
test_args: '{project}/c'
85+
test_args: '{project}/src/c'
8686

8787
- spec: cp38-manylinux_s390x
8888
foreign_arch: true
89-
test_args: '{project}/c'
89+
test_args: '{project}/src/c'
9090
- spec: cp39-manylinux_s390x
9191
foreign_arch: true
92-
test_args: '{project}/c'
92+
test_args: '{project}/src/c'
9393
- spec: cp310-manylinux_s390x
9494
foreign_arch: true
95-
test_args: '{project}/c'
95+
test_args: '{project}/src/c'
9696
- spec: cp311-manylinux_s390x
9797
foreign_arch: true
98-
test_args: '{project}/c'
98+
test_args: '{project}/src/c'
9999
- spec: cp312-manylinux_s390x
100100
foreign_arch: true
101-
test_args: '{project}/c'
101+
test_args: '{project}/src/c'
102102

103103
steps:
104104
- name: clone repo
@@ -261,9 +261,9 @@ jobs:
261261
CIBW_BUILD: ${{ matrix.spec }}
262262
CIBW_PRERELEASE_PYTHONS: 'True'
263263
CIBW_TEST_REQUIRES: pytest setuptools
264-
CIBW_TEST_COMMAND: 'python -m pytest {project}/c'
264+
CIBW_TEST_COMMAND: 'python -m pytest {project}/src/c'
265265
# FIXME: /testing takes ~45min on Windows and has some failures...
266-
# CIBW_TEST_COMMAND='python -m pytest {project}/c {project}/testing'
266+
# CIBW_TEST_COMMAND='python -m pytest {project}/src/c {project}/testing'
267267
run: |
268268
python -m pip install --upgrade pip
269269
pip install "${{ matrix.cibw_version || 'cibuildwheel'}}"

MANIFEST.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
recursive-include cffi *.py *.h
2-
recursive-include c *.c *.h *.asm *.py win64.obj ffi.lib
1+
recursive-include src/cffi *.py *.h
2+
recursive-include src/c *.c *.h *.asm *.py win64.obj ffi.lib
33
recursive-include testing *.py *.c *.h
44
recursive-include doc *.py *.rst Makefile *.bat
55
recursive-include demo py.cleanup *.py embedding_test.c manual.c

setup.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import setuptools
88

99

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

126126
if sys.platform == "win32" and uses_msvc():
127127
if platform.machine() == "ARM64":
128-
include_dirs.append(os.path.join("c/libffi_arm64/include"))
129-
library_dirs.append(os.path.join("c/libffi_arm64"))
128+
include_dirs.append(os.path.join("src/c/libffi_arm64/include"))
129+
library_dirs.append(os.path.join("src/c/libffi_arm64"))
130130
else:
131-
COMPILE_LIBFFI = 'c/libffi_x86_x64' # from the CPython distribution
131+
COMPILE_LIBFFI = 'src/c/libffi_x86_x64' # from the CPython distribution
132132
assert os.path.isdir(COMPILE_LIBFFI), "directory not found!"
133133
include_dirs[:] = [COMPILE_LIBFFI]
134134
libraries[:] = []
@@ -198,6 +198,7 @@ def has_ext_modules(self):
198198
version='1.16.0rc1',
199199
python_requires='>=3.8',
200200
packages=['cffi'] if cpython else [],
201+
package_dir={"": "src"},
201202
package_data={'cffi': ['_cffi_include.h', 'parse_c_type.h',
202203
'_embedding.h', '_cffi_errors.h']}
203204
if cpython else {},
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.

0 commit comments

Comments
 (0)