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.2

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.2
File Size Uploaded Provenance Actions
python_undef-1.4.2.tar.gz 13.9 kB Without provenance Details for python_undef-1.4.2.tar.gz

Built distribution (wheel)

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

Total release size: 21.0 kB

Release files / python_undef-1.4.2.tar.gz

Download URL python_undef-1.4.2.tar.gz
Size 13.9 kB
Tags Source
SHA-256 checksum
How to use checksums
4ae5ff0e6ea60058ea619a8b5055401df6c829dfde3d4173d886b000a01dbfa2
BLAKE2b-256 checksum
How to use checksums
e052dd8f8182061ab21ea1cd0efbcc0c490656cc3b28e1b450a49da5ee53b3a3
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.2-py3-none-any.whl

Download URL python_undef-1.4.2-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
95a4c74520bdda4312851512104e0585f495bc4652fee1ec0b2ce9222d265111
BLAKE2b-256 checksum
How to use checksums
051f3f559742f49cc2e7c22e1ceb032a58785cc4ed13a3d176cba58d8aee636c
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.2

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