Skip to content
This repository was archived by the owner on Oct 27, 2022. It is now read-only.

Commit 06114fb

Browse files
authored
Run autoconf before building the extension. #40 (#48)
Add an autoconf script to test for features. Run autoconf at setuptools build_ext time. Python 2.x's configure script does not test for the more recent features we use so their defines are not in pyconfig.h. We run our own autoconf to verify those and use its generated header to pick those up. Getting configure to run via setuptools is... wacky. :/ also, internal: Run python2 tests first, get rid of the old .hgtags file.
1 parent 1d45b1e commit 06114fb

8 files changed

+5023
-26
lines changed

.hgtags

-1
This file was deleted.

MANIFEST.in

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
include *.md
2-
include LICENSE*
2+
include LICENSE
33
include setup.py
44
include setup.cfg
55
include ChangeLog
66
include MANIFEST.in
77

8-
include *.c *.h *.py
8+
include configure.ac configure *.h.in
9+
10+
include *.c *.py
911
include testdata/*
1012
include python3_redirect/*
1113

1214
prune build
1315
prune dist
14-
prune .hg*
16+
prune config.*
17+
prune *.pyc

_posixsubprocess.c

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
/* Authors: Gregory P. Smith & Jeffrey Yasskin */
22

3-
/* Needed to enable CLOEXEC support on OSes with ancient defaults. */
4-
#define _POSIX_C_SOURCE 200809L
5-
#define _XOPEN_SOURCE 700
3+
/* We use our own small autoconf to fill in for things that were not checked
4+
* for in Python 2's configure and thus pyconfig.h.
5+
*
6+
* This comes before Python.h on purpose. 2.7's Python.h redefines critical
7+
* defines such as _POSIX_C_SOURCE with undesirable old values impacting system
8+
* which header defines are available.
9+
*/
10+
#include "_posixsubprocess_config.h"
11+
#ifdef HAVE_SYS_CDEFS_H
12+
#include <sys/cdefs.h>
13+
#endif
614

715
#define PY_SSIZE_T_CLEAN
816
#include "Python.h"
9-
#if defined(__linux__) && !defined(HAVE_PIPE2)
10-
# define HAVE_PIPE2 1 /* From 3.2's configure script, undef if you don't. */
11-
#endif
12-
#if defined(HAVE_PIPE2) && !defined(_GNU_SOURCE)
13-
# define _GNU_SOURCE
14-
#endif
17+
1518
#include <unistd.h>
1619
#include <fcntl.h>
17-
#ifdef __linux__
18-
# define HAVE_SYS_TYPES_H 1 /* From 3.2's configure script, undef if reqd. */
19-
# define HAVE_SYS_SYSCALL_H 1 /* From 3.2's configure script, undef if reqd. */
20-
# define HAVE_SYS_DIRENT_H 1 /* From 3.2's configure script, undef if reqd. */
21-
#endif
2220
#ifdef HAVE_SYS_TYPES_H
2321
#include <sys/types.h>
2422
#endif
@@ -32,6 +30,8 @@
3230
#include <dirent.h>
3331
#endif
3432

33+
/* TODO: Some platform conditions below could move into configure.ac. */
34+
3535
#if defined(__ANDROID__) && !defined(SYS_getdents64)
3636
/* Android doesn't expose syscalls, add the definition manually. */
3737
# include <sys/linux-syscalls.h>

_posixsubprocess_config.h.in

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/* _posixsubprocess_config.h.in. Generated from configure.ac by autoheader. */
2+
3+
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
4+
*/
5+
#undef HAVE_DIRENT_H
6+
7+
/* Define if you have the 'dirfd' function or macro. */
8+
#undef HAVE_DIRFD
9+
10+
/* Define to 1 if you have the <fcntl.h> header file. */
11+
#undef HAVE_FCNTL_H
12+
13+
/* Define to 1 if you have the <inttypes.h> header file. */
14+
#undef HAVE_INTTYPES_H
15+
16+
/* Define to 1 if you have the <memory.h> header file. */
17+
#undef HAVE_MEMORY_H
18+
19+
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
20+
#undef HAVE_NDIR_H
21+
22+
/* Define to 1 if you have the `pipe2' function. */
23+
#undef HAVE_PIPE2
24+
25+
/* Define to 1 if you have the `setsid' function. */
26+
#undef HAVE_SETSID
27+
28+
/* Define to 1 if you have the <stdint.h> header file. */
29+
#undef HAVE_STDINT_H
30+
31+
/* Define to 1 if you have the <stdlib.h> header file. */
32+
#undef HAVE_STDLIB_H
33+
34+
/* Define to 1 if you have the <strings.h> header file. */
35+
#undef HAVE_STRINGS_H
36+
37+
/* Define to 1 if you have the <string.h> header file. */
38+
#undef HAVE_STRING_H
39+
40+
/* Define to 1 if you have the <sys/cdefs.h> header file. */
41+
#undef HAVE_SYS_CDEFS_H
42+
43+
/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
44+
*/
45+
#undef HAVE_SYS_DIR_H
46+
47+
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
48+
*/
49+
#undef HAVE_SYS_NDIR_H
50+
51+
/* Define to 1 if you have the <sys/stat.h> header file. */
52+
#undef HAVE_SYS_STAT_H
53+
54+
/* Define to 1 if you have the <sys/syscall.h> header file. */
55+
#undef HAVE_SYS_SYSCALL_H
56+
57+
/* Define to 1 if you have the <sys/types.h> header file. */
58+
#undef HAVE_SYS_TYPES_H
59+
60+
/* Define to 1 if you have the <unistd.h> header file. */
61+
#undef HAVE_UNISTD_H
62+
63+
/* Define to the address where bug reports for this package should be sent. */
64+
#undef PACKAGE_BUGREPORT
65+
66+
/* Define to the full name of this package. */
67+
#undef PACKAGE_NAME
68+
69+
/* Define to the full name and version of this package. */
70+
#undef PACKAGE_STRING
71+
72+
/* Define to the one symbol short name of this package. */
73+
#undef PACKAGE_TARNAME
74+
75+
/* Define to the home page for this package. */
76+
#undef PACKAGE_URL
77+
78+
/* Define to the version of this package. */
79+
#undef PACKAGE_VERSION
80+
81+
/* Define to 1 if you have the ANSI C header files. */
82+
#undef STDC_HEADERS
83+
84+
/* Define on OpenBSD to activate all library features */
85+
#undef _BSD_SOURCE
86+
87+
/* Define on Irix to enable u_int */
88+
#undef _BSD_TYPES
89+
90+
/* Define on Darwin to activate all library features */
91+
#undef _DARWIN_C_SOURCE
92+
93+
/* Define on Linux to activate all library features */
94+
#undef _GNU_SOURCE
95+
96+
/* Define on NetBSD to activate all library features */
97+
#undef _NETBSD_SOURCE
98+
99+
/* Define to activate features from IEEE Stds 1003.1-2008 */
100+
#undef _POSIX_C_SOURCE
101+
102+
/* Define to the level of X/Open that your system supports */
103+
#undef _XOPEN_SOURCE
104+
105+
/* Define to activate Unix95-and-earlier features */
106+
#undef _XOPEN_SOURCE_EXTENDED
107+
108+
/* Define on FreeBSD to activate all library features */
109+
#undef __BSD_VISIBLE

0 commit comments

Comments
 (0)