pypa / build

A simple, correct Python build frontend

Home Page:https://build.pypa.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to access the "build" directory after build

szabolcsdombi opened this issue · comments

Hello,
I want to be able to access the build folder after running python -m build
I have also tried to use python -m build --no-isolation

The log says:

adding '_zengl.py'
adding 'zengl.cpython-310-x86_64-linux-gnu.so'
adding 'zengl-stubs/__init__.pyi'
adding 'zengl-1.18.0.dist-info/LICENSE'
adding 'zengl-1.18.0.dist-info/METADATA'
adding 'zengl-1.18.0.dist-info/WHEEL'
adding 'zengl-1.18.0.dist-info/top_level.txt'
adding 'zengl-1.18.0.dist-info/RECORD'
removing build/bdist.linux-x86_64/wheel
Successfully built zengl-1.18.0.tar.gz and zengl-1.18.0-cp310-cp310-linux_x86_64.whl

There is no build directory after running the build command.

I need the .gnco files for coverage, previously I could:

python setup.py build_ext --inplace && cp build/temp.*/zengl.gcno .

This copy is not necessary as gcovr will work just fine if build/temp.*/zengl.gcno exists.

Please introduce an option to prevent any kind of cleanups.

build does not delete the "build" folder. The output you are seeing is coming from setuptools.

Yes, that's definitely setuptools. So it can probably be controlled by tweaking MANIFEST.in and/or setup.py. I think this issue can be closed.

Setuptools usually don't completely delete the build directory (it might delete some parts of it, e.g. the directory that gets zip into the .whl file). I don't remember now if the temp directory also gets removed... It might be the case.

One thing to pay attention is that the recommended workflow for frontends is to build wheels from the sdists. This way build obtains a .tar.gz sdist, extracts it in a temporary directory and then it calls setuptools to build the .whl file on that temporary directory (if I am not mistaken)...

To skip the sdist phase and build the wheel directly, you can use python -m build --wheel.

Thank you @abravalheri!

Indeed python -m build --wheel --no-isolation produces the build directory.

So it seems the problem was that I expected the --no-isolation flag to use the cwd for build, which is not possible given the recommended workflow to build from the sdist.

FROM python:3.12.1 AS base
RUN pip download --no-binary=:all: zengl==2.2.0 && tar -zxf zengl-2.2.0.tar.gz && mv zengl-2.2.0 project
WORKDIR /project

FROM base AS v1
RUN python setup.py bdist_wheel

FROM base AS v2
RUN pip install build==1.0.3
RUN python -m build --no-isolation

FROM base
COPY --from=v1 /project /project-v1
COPY --from=v2 /project /project-v2
CMD diff -q /project-v1 /project-v2

It outputs:

Only in /project-v1: build
...

Changing the python -m build --no-isolation to include --wheel results in the desired folder structure.