pypa / pypa/setuptools

[BUG] Compiler commands are no longer logged in some cases

Open
#3,984 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Needs Triage upstream
Dominant language
Python
Stars
2.9k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
1

Description

setuptools version

65.6.0

Python version

Python 3.10

OS

Linux

Additional environment information

No response

Description

From setuptools 65.6.0 on, a python setup.py build_ext --inplace no longer logs the individual compiler commands that are executed when SETUPTOOLS_USE_DISTUTILS=local if distutils.core.setup is used. They were logged in setuptools 65.5.1, however, and are logged if setuptools.setup is used.

Expected behavior

Compiler commands should be logged by default, and setuptools.setup and distutils.core.setup should behave identically when SETUPTOOLS_USE_DISTUTILS=local

How to Reproduce
  1. Create a temp directory to work in: mkdir /tmp/setuptools_compiler_output
  2. cd /tmp/setuptools_compiler_output
  3. Create a sample setup.py and extension module:
$ cat >setup.py <<EOF
from distutils.core import Extension, setup

setup(
    name="foo",
    version="0.0.1",
    ext_modules=[
        Extension(name="foo", sources=["foo.c"]),
    ],
)
EOF
  1. Create a sample extension module:
$ cat >foo.c <<EOF
#define PY_SSIZE_T_CLEAN
#include <Python.h>

static PyMethodDef methods[] = {
    {NULL, NULL, 0, NULL}
};

static struct PyModuleDef module = {
    PyModuleDef_HEAD_INIT,
    "foo",
    NULL,
    -1,
    methods
};

PyMODINIT_FUNC
PyInit_foo(void)
{
    return PyModule_Create(&module);
}
EOF
  1. python3 -m venv venv
  2. . venv/bin/activate
  3. pip install -q setuptools==65.6.0
  4. SETUPTOOLS_USE_DISTUTILS=local python setup.py build_ext --inplace

Observe that no compiler/linker commands are printed.

  1. Clean up after the build: rm -rf build foo*.so
  2. pip install -q setuptools==65.5.1
  3. SETUPTOOLS_USE_DISTUTILS=local python setup.py build_ext --inplace

Observe that the compiler/linker commands are printed.

Output
$ mkdir /tmp/setuptools_compiler_output
$ cd /tmp/setuptools_compiler_output
$ cat >setup.py <<EOF
from distutils.core import Extension, setup

setup(
    name="foo",
    version="0.0.1",
    ext_modules=[
        Extension(name="foo", sources=["foo.c"]),
    ],
)
EOF
$ cat >foo.c <<EOF
#define PY_SSIZE_T_CLEAN
#include <Python.h>

static PyMethodDef methods[] = {
    {NULL, NULL, 0, NULL}
};

static struct PyModuleDef module = {
    PyModuleDef_HEAD_INIT,
    "foo",
    NULL,
    -1,
    methods
};

PyMODINIT_FUNC
PyInit_foo(void)
{
    return PyModule_Create(&module);
}
EOF
$ python3 -m venv venv
$ . venv/bin/activate
(venv) $ pip install -q setuptools==65.6.0
(venv) $ SETUPTOOLS_USE_DISTUTILS=local python setup.py build_ext --inplace
(venv) $ rm -rf build foo*.so
(venv) $ pip install -q setuptools==65.5.1
(venv) $ SETUPTOOLS_USE_DISTUTILS=local python setup.py build_ext --inplace
running build_ext
building 'foo' extension
creating build
creating build/temp.linux-x86_64-cpython-310
gcc <snip> -c foo.c -o build/temp.linux-x86_64-cpython-310/foo.o
creating build/lib.linux-x86_64-cpython-310
gcc <snip> build/temp.linux-x86_64-cpython-310/foo.o -o build/lib.linux-x86_64-cpython-310/foo.cpython-310-x86_64-linux-gnu.so
copying build/lib.linux-x86_64-cpython-310/foo.cpython-310-x86_64-linux-gnu.so ->
(venv) $

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the sample setup.py, foo.c extension, and SETUPTOOLS_USE_DISTUTILS=local command described in the report. Compare setuptools 65.6.0 with 65.5.1 and compare distutils.core.setup with setuptools.setup; done means compiler and linker commands are logged consistently by default.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.