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

Release files for python-undef 1.3.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.3.1
File Size Uploaded
python_undef-1.3.1.tar.gz 6.1 kB Details

Built distribution (wheel)

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

Total release size: 13.0 kB

Release files / python_undef-1.3.1.tar.gz

Download URL python_undef-1.3.1.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
f33fdec9f740722823ed592abb9633cf867d8d558bf6602565235fa7409e3a72
BLAKE2b-256 checksum
How to use checksums
37b64cca637a51b7d88b7942fc254151fd4c83315961c66c732b4eadf758e686
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / python_undef-1.3.1-py2.py3-none-any.whl

Download URL python_undef-1.3.1-py2.py3-none-any.whl
Size 6.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
eaa929ded35fd2e8d1d54382a914518fda5a612f13dbccc598a6d257bb64fb6c
BLAKE2b-256 checksum
How to use checksums
f492583f8d4c4c9e7dade9a8dd5975a5069b37eb906be2570a5937737ccfed5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release history Release notifications | RSS feed

This release

1.3.1 This release

2 release files

1.3.0

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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