I don't know the reason why the build path changes. Unfortunately, I'm unable to replicate your experience. I created this dockerfile in an attempt to replacate:
FROM jaraco/multipy-tox
RUN pipx install httpie
RUN http GET https://files.pythonhosted.org/packages/a6/91/86a6eac449ddfae239e93ffc1918cf33fd9bab35c04d1e963b311e347a73/netifaces-0.11.0.tar.gz | tar xz
WORKDIR netifaces-0.11.0
RUN pip-run -q setuptools -- setup.py build > build1.txt
RUN pip-run -q setuptools -- setup.py build > build2.txt
CMD diff --unified build1.txt build2.txt
It produces this output:
$ docker run -it @$(docker build -q .)
--- build1.txt 2022-09-05 14:54:42.639229009 +0000
+++ build2.txt 2022-09-05 14:54:43.869229009 +0000
@@ -1,16 +1,12 @@
running build
running build_ext
-checking for getifaddrs...found.
-checking for getnameinfo...found.
-checking for IPv6 socket IOCTLs...not found.
-checking for optional header files...netash/ash.h netatalk/at.h netax25/ax25.h neteconet/ec.h netipx/ipx.h netpacket/packet.h netrose/rose.h linux/atm.h linux/llc.h linux/tipc.h linux/dn.h.
-checking whether struct sockaddr has a length field...no.
-checking which sockaddr_xxx structs are defined...at ax25 in in6 ipx un rose ash ec ll atmpvc atmsvc dn llc.
-checking for routing socket support...no.
-checking for sysctl(CTL_NET...) support...no.
-checking for netlink support...yes.
+checking for getifaddrs...found. (cached)
+checking for getnameinfo...found. (cached)
+checking for IPv6 socket IOCTLs...not found. (cached)
+checking for optional header files...netash/ash.h netatalk/at.h netax25/ax25.h neteconet/ec.h netipx/ipx.h netpacket/packet.h netrose/rose.h linux/atm.h linux/llc.h linux/tipc.h linux/dn.h. (cached)
+checking whether struct sockaddr has a length field...no. (cached)
+checking which sockaddr_xxx structs are defined...at ax25 in in6 ipx un rose ash ec ll atmpvc atmsvc dn llc. (cached)
+checking for routing socket support...no. (cached)
+checking for sysctl(CTL_NET...) support...no. (cached)
+checking for netlink support...yes. (cached)
will use netlink to read routing table
-building 'netifaces' extension
-aarch64-linux-gnu-gcc -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -DNETIFACES_VERSION=0.11.0 -DHAVE_GETIFADDRS=1 -DHAVE_GETNAMEINFO=1 -DHAVE_NETASH_ASH_H=1 -DHAVE_NETATALK_AT_H=1 -DHAVE_NETAX25_AX25_H=1 -DHAVE_NETECONET_EC_H=1 -DHAVE_NETIPX_IPX_H=1 -DHAVE_NETPACKET_PACKET_H=1 -DHAVE_NETROSE_ROSE_H=1 -DHAVE_LINUX_ATM_H=1 -DHAVE_LINUX_LLC_H=1 -DHAVE_LINUX_TIPC_H=1 -DHAVE_LINUX_DN_H=1 -DHAVE_SOCKADDR_AT=1 -DHAVE_SOCKADDR_AX25=1 -DHAVE_SOCKADDR_IN=1 -DHAVE_SOCKADDR_IN6=1 -DHAVE_SOCKADDR_IPX=1 -DHAVE_SOCKADDR_UN=1 -DHAVE_SOCKADDR_ROSE=1 -DHAVE_SOCKADDR_ASH=1 -DHAVE_SOCKADDR_EC=1 -DHAVE_SOCKADDR_LL=1 -DHAVE_SOCKADDR_ATMPVC=1 -DHAVE_SOCKADDR_ATMSVC=1 -DHAVE_SOCKADDR_DN=1 -DHAVE_SOCKADDR_LLC=1 -DHAVE_PF_NETLINK=1 -I/usr/include/python3.11 -c netifaces.c -o build/temp.linux-aarch64-cpython-311/netifaces.o
-creating build/lib.linux-aarch64-cpython-311
-aarch64-linux-gnu-gcc -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -g -fwrapv -O2 build/temp.linux-aarch64-cpython-311/netifaces.o -L/usr/lib/aarch64-linux-gnu -o build/lib.linux-aarch64-cpython-311/netifaces.cpython-311-aarch64-linux-gnu.so
If I remove the build file between builds, there's no diff.
The output path is determined by setuptools or possibly by distutils, but I also observe that netifaces has a giant setup.py file, so it's entirely possible the behavior affecting the output directory is there.
What I recommend is to:
- (a) Determine if the behavior you're observing is unique to netifaces or happens to other (simpler) packages with an extension module.
- (b) Using a simpler package with an extension module, create a set of steps that replicate the behavior you observe.
- (c) Put breakpoints or print statements at various points in the distutils/setuptools code to trace the behavior and determine where the output dir is set and how it changes.