You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the absolute path to an extension module source file is given to setuptools.Extension(), the build files are written to the same directory as the module source files. This clutters the source directory. In my project, I am giving an absolute path because my extension module source files are outside of the directory where setup.py is located.
In Python 3.12, this does not occur. The build files are written to build/temp.win-amd64-cpython-312 instead.
The difference in behavior is caused by a change to os.path.isabs() for Python 3.13 on Windows, where a path starting with a single slash is no longer considered an absolute path. Suppose that the source file is located at C:\projects\simpleext\simpleext.c. When this path is given to
Execute py -3.12 -m pip wheel .. Note that the build files are written to build/temp.win-amd64-cpython-312.
Execute py -3.13 -m pip wheel .. Note that the build files simpleext.cp313-win_amd64.exp, simpleext.cp313-win_amd64.lib, and simpleext.obj are now in the current directory.
Output
Output doesn't show the issue, but here it is.
For Python 3.13
Processing c:\users\adang\desktop\simpleext Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... doneBuilding wheels for collected packages: simpleext Building wheel for simpleext (pyproject.toml) ... done Created wheel for simpleext: filename=simpleext-0.0.1-cp313-cp313-win_amd64.whl size=5979 sha256=341e3d3e17f0c1ca17b27669320fa6c1c4650e14bde8e398ab9a2d36ab41a798 Stored in directory: C:\Users\adang\AppData\Local\Temp\pip-ephem-wheel-cache-xtr732o6\wheels\27\4c\a5\0e20b9c70908c623502130d90e6b09da62188f03c1f769fa03Successfully built simpleext
For Python 3.12
Processing c:\users\adang\desktop\simpleext Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... doneBuilding wheels for collected packages: simpleext Building wheel for simpleext (pyproject.toml) ... done Created wheel for simpleext: filename=simpleext-0.0.1-cp312-cp312-win_amd64.whl size=5980 sha256=03d7fcfca73e476b535fb2cf0db6e28a15e3d7903b8b49dd0e1277c9659d0a52 Stored in directory: C:\Users\adang\AppData\Local\Temp\pip-ephem-wheel-cache-_kwgidxz\wheels\11\8a\f0\d510945bc3d119d0d87da3bbd42b3d54dc616cf09200d05ae0Successfully built simpleext
The text was updated successfully, but these errors were encountered:
setuptools version
75.1.0
Python version
Python 3.13rc3
OS
Windows
Additional environment information
No response
Description
When the absolute path to an extension module source file is given to
setuptools.Extension()
, the build files are written to the same directory as the module source files. This clutters the source directory. In my project, I am giving an absolute path because my extension module source files are outside of the directory wheresetup.py
is located.In Python 3.12, this does not occur. The build files are written to
build/temp.win-amd64-cpython-312
instead.The difference in behavior is caused by a change to
os.path.isabs()
for Python 3.13 on Windows, where a path starting with a single slash is no longer considered an absolute path. Suppose that the source file is located atC:\projects\simpleext\simpleext.c
. When this path is given tosetuptools/setuptools/_distutils/ccompiler.py
Line 992 in 66a8aee
\projects\simpleext\simpleext.c
instead ofprojects\simpleext\simpleext.c
.I will submit a PR for this.
Expected behavior
Build files are written to the
build/
directory.How to Reproduce
On Windows, install Python 3.12 and Python 3.13, and ensure that Visual Studio is installed. Create a file
setup.py
with the following contents.In the same directory, create a file
simpleext.c
with the following contents.Execute
py -3.12 -m pip wheel .
. Note that the build files are written tobuild/temp.win-amd64-cpython-312
.Execute
py -3.13 -m pip wheel .
. Note that the build filessimpleext.cp313-win_amd64.exp
,simpleext.cp313-win_amd64.lib
, andsimpleext.obj
are now in the current directory.Output
Output doesn't show the issue, but here it is.
For Python 3.13
For Python 3.12
The text was updated successfully, but these errors were encountered: