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

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.0
File Size Uploaded Provenance Actions
python_undef-1.4.0.tar.gz 6.2 kB Without provenance Details for python_undef-1.4.0.tar.gz

Built distribution (wheel)

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

Total release size: 13.2 kB

Release files / python_undef-1.4.0.tar.gz

Download URL python_undef-1.4.0.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
8069fd5b0ebe7104fba944b92a16ce1bd6ca8fc8f06ff876d149a65ab0cc592f
BLAKE2b-256 checksum
How to use checksums
b9f895797671ec9289308e5ab3fc364f2d833f6e1d7113a348c685d58a0dfb9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

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

Download URL python_undef-1.4.0-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b0dcec7ed346a7145cfd2c832e412b658d48b8ba125cb0fe6d0e8ffd93c0d342
BLAKE2b-256 checksum
How to use checksums
6017468800853e172e107b2e0ba7575bc412d355ebf57df844d60ad878025114
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Security for python-undef 1.4.0

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