This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: FileNotFoundError in distutils\file_util.py copy_tree
Type: crash Stage: resolved
Components: Distutils Versions: Python 3.9
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: christian.heimes, dstufft, eric.araujo, knzivid, steve.dower
Priority: normal Keywords:

Created on 2021-01-27 11:20 by knzivid, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
scratch_4.txt knzivid, 2021-01-27 11:20 distutils verbose logs
Messages (7)
msg385758 - (view) Author: Karthik Nishanth (knzivid) Date: 2021-01-27 11:20
I am making a bdist_wheel for a private python binary module.

`python setup.py bdist_wheel` fails on a very specific windows VM repeatedly. This works fine on both a regular windows machine & linux machines.

Attached the complete distutils verbose logs.

Stacktrace for quick search:
---------------------------------------------

     File "C:\Program Files\Python39\lib\site-packages\setuptools\__init__.py", line 165, in setup
       return distutils.core.setup(**attrs)
     File "C:\Program Files\Python39\lib\distutils\core.py", line 148, in setup
       dist.run_commands()
     File "C:\Program Files\Python39\lib\distutils\dist.py", line 966, in run_commands
       self.run_command(cmd)
     File "C:\Program Files\Python39\lib\distutils\dist.py", line 985, in run_command
       cmd_obj.run()
     File "C:\Program Files\Python39\lib\site-packages\wheel\bdist_wheel.py", line 335, in run
       self.run_command('install')
     File "C:\Program Files\Python39\lib\distutils\cmd.py", line 313, in run_command
       self.distribution.run_command(command)
     File "C:\Program Files\Python39\lib\distutils\dist.py", line 985, in run_command
       cmd_obj.run()
     File "C:\Program Files\Python39\lib\site-packages\setuptools\command\install.py", line 61, in run
       return orig.install.run(self)
     File "C:\Program Files\Python39\lib\distutils\command\install.py", line 558, in run
       self.run_command(cmd_name)
     File "C:\Program Files\Python39\lib\distutils\cmd.py", line 313, in run_command
       self.distribution.run_command(command)
     File "C:\Program Files\Python39\lib\distutils\dist.py", line 985, in run_command
       cmd_obj.run()
     File "C:\Program Files\Python39\lib\site-packages\setuptools\command\install_lib.py", line 12, in run
       outfiles = self.install()
     File "C:\Program Files\Python39\lib\distutils\command\install_lib.py", line 111, in install
       outfiles = self.copy_tree(self.build_dir, self.install_dir)
     File "C:\Program Files\Python39\lib\site-packages\setuptools\command\install_lib.py", line 95, in copy_tree
       return orig.install_lib.copy_tree(self, infile, outfile)
     File "C:\Program Files\Python39\lib\distutils\cmd.py", line 354, in copy_tree
       return dir_util.copy_tree(infile, outfile, preserve_mode,
     File "C:\Program Files\Python39\lib\distutils\dir_util.py", line 157, in copy_tree
       copy_tree(src_name, dst_name, preserve_mode,
     File "C:\Program Files\Python39\lib\distutils\dir_util.py", line 161, in copy_tree
       copy_file(src_name, dst_name, preserve_mode,
     File "C:\Program Files\Python39\lib\distutils\file_util.py", line 151, in copy_file
       _copy_file_contents(src, dst)
     File "C:\Program Files\Python39\lib\distutils\file_util.py", line 43, in _copy_file_contents
       raise DistutilsFileError(
   distutils.errors.DistutilsFileError: could not create 'build\bdist.win-amd64\wheel\internal_pkgname-2.3.0_pre_alpha_1_c8273a4c_1_preview.data\purelib\mydeviceapi\mydeviceapi.cp39-win_amd64.pyd': No such file or directory

---------------------------------------------

I may get an [Errno 2] on open(dst, 'wb') if dst has a directory component that does not exist. But distutils logs already say 

> creating dir1
> creating dir1/dir2
> creating dir1/dir2/dir3

so I assume the directories must have been created before calling open().
msg385759 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2021-01-27 11:29
distutils is a legacy package. setuptools is the successor of distutils. Could you please try again with setuptools?
msg385760 - (view) Author: Karthik Nishanth (knzivid) Date: 2021-01-27 11:31
Sorry, I did use the `setup` function from

`from setuptools import setup` 

I marked the component as Distutils because I noticed setuptools called distutils internally in the stacktrace
msg385761 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2021-01-27 11:36
It looks like you version number is confusing setuptools and distutils. Setuptools even warns you about the invalid version number:

UserWarning: The version specified ('2.3.0-pre-alpha-1+c8273a4c-1-preview') is an invalid version, this may not work as expected with newer versions of setuptools, pip, and PyPI. Please see PEP 440 for more details.
msg385763 - (view) Author: Karthik Nishanth (knzivid) Date: 2021-01-27 11:42
I use the same version of python on my local windows machine and in the VM. Since I am not explicitly upgrading setuptools in my scripts, I should expect the same error on my windows machine too, right?

This also works on linux.

The stacktrace also says the correct directories (with an invalid version) are created before `open` fails.
msg385775 - (view) Author: Karthik Nishanth (knzivid) Date: 2021-01-27 14:17
I made my version PEP440 (local version) compliant. Now I get an error in a different place and it makes more sense.

[WinError 206] The filename or extension is too long: 'build\\bdist.win-amd64\\wheel\\...\\purelib\\pkg..-2.3.0+b0105812.1.preview-py3.9.egg-info'

Is there a pythonic way of enabling long paths on windows?
msg386224 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-02-03 18:01
Distutils is now deprecated (see PEP 632) and all tagged issues are being closed. From now until removal, only release blocking issues will be considered for distutils.

If this issue does not relate to distutils, please remove the component and reopen it. If you believe it still requires a fix, most likely the issue should be re-reported at https://github.com/pypa/setuptools
History
Date User Action Args
2022-04-11 14:59:40adminsetgithub: 87201
2021-02-03 18:01:15steve.dowersetstatus: open -> closed

nosy: + steve.dower
messages: + msg386224

resolution: out of date
stage: resolved
2021-01-27 14:17:05knzividsetmessages: + msg385775
2021-01-27 11:42:35knzividsetmessages: + msg385763
2021-01-27 11:36:06christian.heimessetmessages: + msg385761
2021-01-27 11:31:14knzividsetmessages: + msg385760
2021-01-27 11:29:33christian.heimessetnosy: + christian.heimes
messages: + msg385759
2021-01-27 11:20:36knzividcreate