Mercurial > cpython-lru_cache-weakref
annotate Include/moduleobject.h @ 73323:dad02a080bbc
Improve byte-compilation in packaging to be independent of -O or -B.
The code I fixed to comply with PEP 3147 still had one bug: When run
under python -O, some paths for pyc files would be pyo, because I called
imp.cache_from_source without explicit debug_override argument in some
places, and under -O that would return .pyo (this is well explained in
the imp docs). Now all code (util.byte_compile, build_py, install_lib)
can create .pyo files according to options given by users,
without interference from the calling Python’s own optimize mode.
On a related topic, I also removed the code that prevented byte
compilation under python -B. The rationale is that packaging gives
control over the creation of pyc files to the user with its own explicit
option, and the behavior should not be changed if the calling Python
happens to run with -B for whatever reason. I will argue that this is a
bug fix and ask to be allowed to backport this change to distutils.
Finally, I moved one nugget of information about the --compile and
--optimize options from the source into the doc. It clears up a
misunderstanding that I (and maybe other people) had.
| author | Éric Araujo <merwok@netwok.org> |
|---|---|
| date | Thu, 03 Nov 2011 05:08:28 +0100 |
| parents | 50b38e4b0231 |
| children |
| rev | line source |
|---|---|
| 145 | 1 |
| 6 | 2 /* Module object interface */ |
| 3 | |
|
13445
091ca6b9348f
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
4 #ifndef Py_MODULEOBJECT_H |
|
091ca6b9348f
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
5 #define Py_MODULEOBJECT_H |
|
091ca6b9348f
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
6 #ifdef __cplusplus |
|
091ca6b9348f
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
7 extern "C" { |
|
091ca6b9348f
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
8 #endif |
|
091ca6b9348f
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
9 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
19894
diff
changeset
|
10 PyAPI_DATA(PyTypeObject) PyModule_Type; |
| 6 | 11 |
|
19832
00d80947d817
PyModule_Check() now checks for subtype of module, as it should.
Guido van Rossum <guido@python.org>
parents:
14375
diff
changeset
|
12 #define PyModule_Check(op) PyObject_TypeCheck(op, &PyModule_Type) |
|
44351
86a2679dca46
#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents:
42845
diff
changeset
|
13 #define PyModule_CheckExact(op) (Py_TYPE(op) == &PyModule_Type) |
| 6 | 14 |
|
68228
50b38e4b0231
Issue #3080: Add PyModule_NewObject() function
Victor Stinner <victor.stinner@haypocalc.com>
parents:
68111
diff
changeset
|
15 PyAPI_FUNC(PyObject *) PyModule_NewObject( |
|
50b38e4b0231
Issue #3080: Add PyModule_NewObject() function
Victor Stinner <victor.stinner@haypocalc.com>
parents:
68111
diff
changeset
|
16 PyObject *name |
|
50b38e4b0231
Issue #3080: Add PyModule_NewObject() function
Victor Stinner <victor.stinner@haypocalc.com>
parents:
68111
diff
changeset
|
17 ); |
|
68109
ec3c06761856
Issue #3080: document encoding used by import functions
Victor Stinner <victor.stinner@haypocalc.com>
parents:
66664
diff
changeset
|
18 PyAPI_FUNC(PyObject *) PyModule_New( |
|
ec3c06761856
Issue #3080: document encoding used by import functions
Victor Stinner <victor.stinner@haypocalc.com>
parents:
66664
diff
changeset
|
19 const char *name /* UTF-8 encoded string */ |
|
ec3c06761856
Issue #3080: document encoding used by import functions
Victor Stinner <victor.stinner@haypocalc.com>
parents:
66664
diff
changeset
|
20 ); |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
19894
diff
changeset
|
21 PyAPI_FUNC(PyObject *) PyModule_GetDict(PyObject *); |
|
68111
f2edaf62d823
Issue #3080: Add PyModule_GetNameObject()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
68109
diff
changeset
|
22 PyAPI_FUNC(PyObject *) PyModule_GetNameObject(PyObject *); |
|
42845
3152df70517a
Get rid of more uses of string and use const in a few places.
Neal Norwitz <nnorwitz@gmail.com>
parents:
42334
diff
changeset
|
23 PyAPI_FUNC(const char *) PyModule_GetName(PyObject *); |
|
3152df70517a
Get rid of more uses of string and use const in a few places.
Neal Norwitz <nnorwitz@gmail.com>
parents:
42334
diff
changeset
|
24 PyAPI_FUNC(const char *) PyModule_GetFilename(PyObject *); |
|
64138
ee765a67c0b1
Issue #9425: Create PyModule_GetFilenameObject() function
Victor Stinner <victor.stinner@haypocalc.com>
parents:
47580
diff
changeset
|
25 PyAPI_FUNC(PyObject *) PyModule_GetFilenameObject(PyObject *); |
|
66664
62b61abd02b8
Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents:
66218
diff
changeset
|
26 #ifndef Py_LIMITED_API |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
19894
diff
changeset
|
27 PyAPI_FUNC(void) _PyModule_Clear(PyObject *); |
|
66664
62b61abd02b8
Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents:
66218
diff
changeset
|
28 #endif |
|
47580
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
29 PyAPI_FUNC(struct PyModuleDef*) PyModule_GetDef(PyObject*); |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
30 PyAPI_FUNC(void*) PyModule_GetState(PyObject*); |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
31 |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
32 typedef struct PyModuleDef_Base { |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
33 PyObject_HEAD |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
34 PyObject* (*m_init)(void); |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
35 Py_ssize_t m_index; |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
36 PyObject* m_copy; |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
37 } PyModuleDef_Base; |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
38 |
|
66218
d8cc95d7de62
Issue #9518: Extend the PyModuleDef_HEAD_INIT macro to explicitly
David Malcolm <dmalcolm@redhat.com>
parents:
64138
diff
changeset
|
39 #define PyModuleDef_HEAD_INIT { \ |
|
d8cc95d7de62
Issue #9518: Extend the PyModuleDef_HEAD_INIT macro to explicitly
David Malcolm <dmalcolm@redhat.com>
parents:
64138
diff
changeset
|
40 PyObject_HEAD_INIT(NULL) \ |
|
d8cc95d7de62
Issue #9518: Extend the PyModuleDef_HEAD_INIT macro to explicitly
David Malcolm <dmalcolm@redhat.com>
parents:
64138
diff
changeset
|
41 NULL, /* m_init */ \ |
|
d8cc95d7de62
Issue #9518: Extend the PyModuleDef_HEAD_INIT macro to explicitly
David Malcolm <dmalcolm@redhat.com>
parents:
64138
diff
changeset
|
42 0, /* m_index */ \ |
|
d8cc95d7de62
Issue #9518: Extend the PyModuleDef_HEAD_INIT macro to explicitly
David Malcolm <dmalcolm@redhat.com>
parents:
64138
diff
changeset
|
43 NULL, /* m_copy */ \ |
|
d8cc95d7de62
Issue #9518: Extend the PyModuleDef_HEAD_INIT macro to explicitly
David Malcolm <dmalcolm@redhat.com>
parents:
64138
diff
changeset
|
44 } |
|
47580
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
45 |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
46 typedef struct PyModuleDef{ |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
47 PyModuleDef_Base m_base; |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
48 const char* m_name; |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
49 const char* m_doc; |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
50 Py_ssize_t m_size; |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
51 PyMethodDef *m_methods; |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
52 inquiry m_reload; |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
53 traverseproc m_traverse; |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
54 inquiry m_clear; |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
55 freefunc m_free; |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
56 }PyModuleDef; |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
57 |
|
1329
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
58 |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
59 #ifdef __cplusplus |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
60 } |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
61 #endif |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
62 #endif /* !Py_MODULEOBJECT_H */ |
