Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolves visual studio FileNotFoundError: [Errno 2] #1513

Closed
wants to merge 1 commit into from

Conversation

beekalam
Copy link

resolves visual studio FileNotFoundError: [Errno 2] No such file or directory:
'path_to_python_src\py\makeversionhdr.py/docs/conf.py'

this happens because of windows \ separators

…irectory:

'path_to_python_src\py\makeversionhdr.py/docs/conf.py'
this happens because of windows \ separators
@stinos
Copy link
Contributor

stinos commented Oct 16, 2015

Can you elaborate on the error a bit (when does it occur, what does VS have to do with it)

'path_to_python_src\py\makeversionhdr.py/docs/conf.py'
this happens because of windows \ separators

That seems unlikely - from that info the problem rather seems that a request is made to access the file conf.py in a directory 'somepath\py\makeversionhdr.py/docs', and that directory obviously does not exist. Moreover most programs on windows have no problems working with both '/' and '' slashes, and python is one of those. For example you can run python py/makeversionhdr.py path/to\file just as well as python py\makeversionhdr.py path\to/file

@beekalam
Copy link
Author

makeversionhdr.py is called in genhdr.targets(which visual studio calls at build time) at line 12 we have:
.... Exec Command="python $(PySrcDir)makeversionhdr.py $(TmpFile)" ...

the path to makeversionhdr.py is passed to python from visual studio like this:
drive:\path\to\file

then the line of code at(makversionhdr.py):

def get_version_info_from_docs_conf():
with open("%s/docs/conf.py" % sys.argv[0].rsplit("/", 2)[0]) as f:

tries to open the following file(which is the wrong path):
'D:\githubrepos\clone\micropython\py\makeversionhdr.py/docs/conf.py'

Although python is intelligent enough to distinguish path separators.But at the above line we are
using string functions.
This is the full traceback from my visual studio:
qstrdefs.h
1> Traceback (most recent call last):
1> File "D:\githubrepos\clone\micropython\py\makeversionhdr.py", line 113, in
1> make_version_header(sys.argv[1])
1> File "D:\githubrepos\clone\micropython\py\makeversionhdr.py", line 81, in make_version_header
1> info = get_version_info_from_docs_conf()
1> File "D:\githubrepos\clone\micropython\py\makeversionhdr.py", line 66, in get_version_info_from_docs_conf
1> with open("%s/docs/conf.py" % sys.argv[0].rsplit("/", 2)[0]) as f:
1> FileNotFoundError: [Errno 2] No such file or directory: 'D:\githubrepos\clone\micropython\py\makeversionhdr.py/docs/conf.py'
1>D:\githubrepos\clone\micropython\windows\msvc\genhdr.targets(39,5): error MSB3073: The command "python D:\githubrepos\clone\micropython\py\makeversionhdr.py D:\githubrepos\clone\micropython\windows\msvc\build\genhdr\mpversion.h.tmp" exited with code 1.

@pfalcon
Copy link
Contributor

pfalcon commented Oct 17, 2015

Ok, so the right fix is to use os.path.dirname() instead of str.rsplit().

@pfalcon
Copy link
Contributor

pfalcon commented Oct 30, 2015

This was handled as part of #1538.

@pfalcon pfalcon closed this Oct 30, 2015
tannewt pushed a commit to tannewt/circuitpython that referenced this pull request Feb 2, 2019
Add support for display rotation and raw commands
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants