Python keep header and undefined header in pyconfig.h
Project description
Python_undef
This is a Python script that generates a header file "Python_undef.h" which undefine many macros in "pyconfig.h" that doesn't match the rule that "should start with PY_".
Why
The "pyconfig.h" continue many macros that doesn't math the rule that "should start with PY_" which may cause the comflict with the other projects. This project undefines them.
Download
pip install python_undef
Usage
Generate
This command under will create the file "Python_undef.h"
python -m python_undef --generate
It defaults output the file "Python_undef.h" and "Python_keep.h" in the package directory.
You can use the --output option to specify the output file:
python -m python_undef --generate --output <path>
Include
The command under will output the include path of "Python_undef.h" and "Python_keep.h":.
You can use this command in your C/C++ project such as "cmake", "gyp" and so on.
If hadn't run python -m python_undef --generate it will exit with code 1.
python -m python_undef --include
Using it in your code
You can include the "Python_undef.h" file in your project:
#include <Python_keep.h>
#include <Python.h>
#include <Python_undef.h>
#include <other_header.h>
The "pyconfig.h" continue many macros that doesn't math the rule that "should start with PY_". This file undefine them.
If you want to save the macro, use #define DONOTUNDEF_macro_name before include "Python_undef.h" to keep it.
Generate for your project config.h (Add in version 1.1.0)
You can use this python code to generate it:
import python_undef
if python_undef.generate_python_undef_header(
"path_to_your_project_config.h",
output_path="path/to/your/project/include",
project_name="your_project",
main_header_macro="YOUR_PROJECT_H",
main_header_name="your_project.h",
macro_need_header="YOUR_PROJECT",
is_standard_macro_rule=your_function,
inside_project=True # Add in version 1.2.0
):
print("Generate your_project_undef.h and your_project_keep.h success")
else:
print("Generate your_project_undef.h and your_project_keep.h failed")
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_undef-1.3.0.tar.gz.
File metadata
- Download URL: python_undef-1.3.0.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a90c88266d44ee3dfcb55a39752bd62090478825249397cfa9a6d0c27f94ba6
|
|
| MD5 |
a09a087d52ad0d54a392b6a9a49f96c3
|
|
| BLAKE2b-256 |
a9ca779078afb68539dc172b8fc63b3d0e5e98fbedd3319d9a48ce4ba93b1724
|
File details
Details for the file python_undef-1.3.0-py2.py3-none-any.whl.
File metadata
- Download URL: python_undef-1.3.0-py2.py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ede64c88cf24ba3a60f4aac50a2707da2d394190efcb2c8ade22810aa175d29
|
|
| MD5 |
431f3723adda84d15ec1eae9bf6688aa
|
|
| BLAKE2b-256 |
460b2340341d3ef54f3a073497499bce371e79093c4061598678f0e0c9dc4758
|