Skip to content

Commit 39a2314

Browse files
pipcl.py: build_extension(): fixed failure to rebuild if .o files are newer.
Also fixed doctests.
1 parent 92f47a8 commit 39a2314

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

pipcl.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ class Package:
9696
... name = 'foo',
9797
... path_i = 'foo.i',
9898
... outdir = 'build',
99+
... source_extra = 'wibble.c',
99100
... )
100101
... return [
101102
... ('build/foo.py', 'foo/__init__.py'),
@@ -107,8 +108,10 @@ class Package:
107108
...
108109
... def sdist():
109110
... return [
111+
... 'pyproject.toml',
110112
... 'foo.i',
111113
... 'bar.i',
114+
... 'wibble.c',
112115
... 'setup.py',
113116
... 'pipcl.py',
114117
... 'wdev.py',
@@ -160,6 +163,12 @@ class Package:
160163
>>> with open('pipcl_test/bar.i', 'w') as f:
161164
... _ = f.write( '\\n')
162165
166+
>>> with open('pipcl_test/wibble.c', 'w') as f:
167+
... _ = f.write( '\\n')
168+
169+
>>> with open('pipcl_test/pyproject.toml', 'w') as f:
170+
... pass
171+
163172
>>> with open('pipcl_test/README', 'w') as f:
164173
... _ = f.write(textwrap.dedent("""
165174
... This is Foo.
@@ -262,6 +271,19 @@ class Package:
262271
>>> so = so[0]
263272
>>> assert os.path.getmtime(so) > t0
264273
274+
Check that touching wibbble.c does not run swig, but does recompile/link.
275+
276+
>>> t0 = time.time()
277+
>>> os.utime('pipcl_test/wibble.c')
278+
>>> _ = subprocess.run(
279+
... f'cd pipcl_test && {sys.executable} setup.py bdist_wheel',
280+
... shell=1, check=1)
281+
>>> assert os.path.getmtime('pipcl_test/build/foo.py') <= t0
282+
>>> so = glob.glob('pipcl_test/build/*.so')
283+
>>> assert len(so) == 1
284+
>>> so = so[0]
285+
>>> assert os.path.getmtime(so) > t0
286+
265287
Check `entry_points` causes creation of command `foo_cli` when we install
266288
from our wheel using pip. [As of 2024-02-24 using pipcl's CLI interface
267289
directly with `setup.py install` does not support entry points.]
@@ -1802,7 +1824,7 @@ def build_extension(
18021824

18031825
for path_source in [path_cpp] + source_extra:
18041826
path_o = f'{path_source}.obj' if windows() else f'{path_source}.o'
1805-
path_os.append(f' {path_o}')
1827+
path_os.append(path_o)
18061828

18071829
prerequisites_path = f'{path_o}.d'
18081830

0 commit comments

Comments
 (0)