Skip to main content

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 {header}_DONOTUNDEF_macro_name before include "Python_undef.h" to keep it. For example, this program on "pyconfig.h" needs Py_DONOTUNDEF_macro_name

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

Metadata

Release files for python-undef 1.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-undef 1.4.1
File Size Uploaded Provenance Actions
python_undef-1.4.1.tar.gz 13.9 kB Without provenance Details for python_undef-1.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for python-undef 1.4.1
File Interpreter ABI Platform Actions
python_undef-1.4.1-py3-none-any.whl Python 3 none any Details for python_undef-1.4.1-py3-none-any.whl

Total release size: 21.0 kB

Release files / python_undef-1.4.1.tar.gz

Download URL python_undef-1.4.1.tar.gz
Size 13.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a0f8c605b598cb75d82cb538d9d23a3507646744dce260421ea92ffb4ea90d34
BLAKE2b-256 checksum
How to use checksums
912a672800f8bf30492ce1e6e57014ecb85cb5861f0c3167f1df65637faa5aa6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / python_undef-1.4.1-py3-none-any.whl

Download URL python_undef-1.4.1-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
40eb4b0ea098aeb3247c99a6627d783aa09c53d5730508b7727ad7df92fdf8c5
BLAKE2b-256 checksum
How to use checksums
a844f70076ec6f18ef91972e1b9429c116d71dcbfefd10ac1496a39eb29c0e4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Security for python-undef 1.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page