Skip to content

Compilation Failures with Py_DEBUG enabled #419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
skadz opened this issue Feb 9, 2023 · 9 comments
Closed

Compilation Failures with Py_DEBUG enabled #419

skadz opened this issue Feb 9, 2023 · 9 comments

Comments

@skadz
Copy link

skadz commented Feb 9, 2023

Py_DEBUG and Py_LIMITED_API are not compatible, so compilation fails when Py_DEBUG is enabled.

We should add a check for Py_DEBUG and make sure we do not use the limited api if it is in place.

@asottile
Copy link
Member

asottile commented Feb 9, 2023

no we shouldn't

@asottile asottile closed this as completed Feb 9, 2023
@skadz
Copy link
Author

skadz commented Feb 9, 2023

So, you would rather your library not work with Py_DEBUG or are you telling me there is a better fix that you would like to implement?

@asottile
Copy link
Member

asottile commented Feb 9, 2023

it works fine for me -- please describe your actual use case instead of jumping to a solution

@skadz
Copy link
Author

skadz commented Feb 9, 2023

gcc -Wno-unused-result -Wsign-compare -g -Og -Wall -fPIC -DPy_LIMITED_API -I./libsass/include -I/usr/local/include/python3.8d -c _sass.c -o build/temp.linux-aarch64-cpython-38-pydebug/_sass.o -fPIC -std=gnu++0x -Wall -Wno-parentheses -Werror=switch -DLIBSASS_VERSION=\"3.6.5\"
        cc1: warning: command-line option '-std=gnu++11' is valid for C++/ObjC++ but not for C
        In file included from /usr/local/include/python3.8d/Python.h:88,
                         from _sass.c:1:
        /usr/local/include/python3.8d/object.h:63:2: error: #error Py_LIMITED_API is incompatible with Py_DEBUG, Py_TRACE_REFS, and Py_REF_DEBUG
           63 | #error Py_LIMITED_API is incompatible with Py_DEBUG, Py_TRACE_REFS, and Py_REF_DEBUG
              |  ^~~~~
        /tmp/pip-build-env-h82wsj1h/overlay/lib/python3.8/site-packages/setuptools/config/setupcfg.py:520: SetuptoolsDeprecationWarning: The license_file parameter is deprecated, use license_files instead.
          warnings.warn(msg, warning_class)
        error: command '/usr/bin/gcc' failed with exit code 1
        [end of output]

    note: This error originates from a subprocess, and is likely not a problem with pip.
    ERROR: Failed building wheel for libsass
  Failed to build libsass
  ERROR: Could not build wheels for libsass, which is required to install pyproject.toml-based projects

@asottile
Copy link
Member

asottile commented Feb 9, 2023

please describe your actual use case

@skadz
Copy link
Author

skadz commented Feb 9, 2023

I moved to a debug version of python to debug some code by compiling with --with-pydebug. When I did, libsass failed to compile when I ran poetry install for my application with the error above. I am unable to run my application without it, which means I cannot do the debugging I need to do, which is blocking me from doing my job. I was able to fix this issue with the PR I submitted.

I am running the latest release of Python 3.8 on Alpine Linux.

@asottile
Copy link
Member

asottile commented Feb 9, 2023

you're free to fork 👍

this isn't a problem in python3.10+ so I don't want to carry code specifically for old pythons

@skadz
Copy link
Author

skadz commented Feb 9, 2023

There are still almost 2 years of support for Python 3.8 and another year past that for 3.9 and your library works with neither under pydebug, so it's disappointing that you are cutting off support for versions that are supported for a long time. Especially when it's a 4 line change (one being a comment). I've updated my change to look for versions now too, so it will work the way you want under 3.10 and will now work under pydebug under 3.9 and below, which will help folks who aren't bleeding edge (like most companies in the world), but it sounds as if that is not important to you.

# Py_LIMITED_API does not work for Py_DEBUG either in versions less than 3.10
if distutils.sysconfig.get_config_var('Py_DEBUG') == 1 and sys.version_info < (3,10):
    py_limited_api = False
    define_macros = []

@asottile
Copy link
Member

asottile commented Feb 9, 2023

it's not "just a 4 line change" -- you're introducing a deprecated library for a niche-at-best use case that we don't test and don't support. your attitude is not appreciated and additionally, neither you nor your company are sponsoring development

@sass sass locked as too heated and limited conversation to collaborators Feb 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants