Skip to main content

Python_undef

This is a Python script that generates the header file "Python_undef.h" and "Python_keep.h" which undefine many macros in "pyconfig.h" that doesn't match the rule that "should start with PY_".

Why

The "pyconfig.h" defines 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>

If you don't want to see the long tips, you can use -q or --quiet option (add in 1.4.3):

python -m python_undef --generate -q

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

Command

After 1.4.3, you can use python-undef as the command straightly:

python-undef --generate
python-undef --generate --output <path>
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_tips=False  # Add in version 1.4.3
):
    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.3

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.3
File Size Uploaded Provenance Actions
python_undef-1.4.3.tar.gz 14.2 kB Without provenance Details for python_undef-1.4.3.tar.gz

Built distribution (wheel)

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

Total release size: 21.8 kB

Release files / python_undef-1.4.3.tar.gz

Download URL python_undef-1.4.3.tar.gz
Size 14.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1b771e8a97f2c4444cd80749ecd380c67e56bc0c08d604d1c5c4eeca591f33e3
BLAKE2b-256 checksum
How to use checksums
0bebfc52f824c91f6eca9fefc3320212a97e58636e21f6500a6aa28cadc7d606
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.3-py3-none-any.whl

Download URL python_undef-1.4.3-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3d6b04749da683b1cb93defabc36a91cb7edfdafe22d1c199b0890724e80502e
BLAKE2b-256 checksum
How to use checksums
13b3c72db241afffd39b0242f85fc693dee9dbc45bac9c5b692a9a1349f0bcff
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.3

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