10:06 AM
0
Q: Setuptools unable to read requirements.txt from pyproject.toml in python 3.12.x

Devarapalli VamsiI have a package structure as follows: program_root/ - src/ - tests/ - data/ - templates/ - docs/ - pyproject.toml - README - requirements.txt My pyproject.toml: [build-system] requires = ["setuptools==62.6.0", "wheel"] build-backend = "setup...

 
Is there any more traceback to this error? What is your build command?
Did you search for the error? Here's the first hit I got: stackoverflow.com/questions/77364550/…
 
I 've mentioned three errors. could you please mention which one you are referring to? I shall give you the traceback of that. my build command is: python -m build
 
Have you tried upgrading pip?
The first error; what's the full traceback for that?
 
@9769953 I did try upgrading the pip. but no use. Couldn't paste my traceback due to character limit. Any other way?
 
Show the first 10 lines and the last 50 or so lines (seems like a pip traceback; those are indeed long).
Is NumPy involved?
 
10:06 AM
@9769953 yes, Numpy is involved. but as per my prior reading of the same SO question you've mentioned, I've ensured it is >=1.26.4 BTW, Checkout the edit I made to add the traceback
 
Do you get the same error with an empty requirements file?
 
@9769953 Yep. Getting the same error even if requirements file is empty.(Checked it just now) Also,Pls checkout some links that I shall be adding at last in the question.
 
According to the issues at github.com/pypa/setuptools/issues/3935 , this was solved in setuptools 66.1. I justed your setup, and with 62.6.0 and 66.0 I can reproduce your error. With setuptools 66.1, I have no problems.
"UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte ": this error would have occurred if you would have had no problems with 62.6 as well; it's not likely to be a setuptools specific problem. Since you're on Windows, and this mentions UTF-8, I'm willing to hazard a guess that your Windows or editor encoding is Latin-1 or something, and not UTF-8.
 
@9769953, I did try just now with 66.1.0 but sorry, issue still persists. and you are right, now I am getting:UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
 
Yes, so the issue does not persist, you're just getting another error. AboutwWhich see also my previous comment. Or are you really getting two errors at once: the pkgutil error and the unicode error?
 
10:06 AM
@9769953 no not getting both of them at the same time. So yeah how can I deal with this considering encoding of the editor? (I am using pycharm)
@9769953 got this warning now(using 66.1.0) before traceback: _BetaConfiguration: Support for [tool.setuptools] in pyproject.toml is still beta. warnings.warn(msg, _BetaConfiguration)
 
For PyCharm, under settings -> Editor, check the "File Encodings" settings, then see if both Global and Project encoding are UTF-8 ("System Default: UTF-8" should also be fine). If they're different than UTF-8, that's the cause of your encoding problem.
The warning is just that, a warning: you're using configurations that are still in beta. It'll be probably work fine for you, but if you use it for anything older than Python 3.12, it may not.
 
@9769953 Nope, I tried everything you've mentioned: Initially, Global and project encodings were different. I've ensured both of them are UTF-8.
@9769953 I've made the Default encoding for properties file (at Editor -> File Encoding) to be UTF-8 and also Default Encoding at Editor -> General -> Console to be UTF-8
 
And you (re)saved the various files? Same error still?
 
@9769953 Yes I did resave the files and restarted PyCharm as well (just in case, for changes to be applied). But getting the same error.
@9769953 new: I tried to do this in VS code: I have requirements file opened and at the bottom, in blue bar, it says that the file is UTF-16LE I clicked on it and it gave two options, ReOpen with Encoding and Save with encoding. I've done : reopen with encoding and made it to UTF-8. Then my file got some unusual structure with all characters being separated by NULL and two ? characters at the beginning. now, when I build,I got: setuptools.extern.packaging.requirements.InvalidRequirement: Expected package name at the start of dependency specifier ��build==1.2.1
Hey Hi, This is what I've done:
1.I have removed all but first 2 lines and manually removed all those unconventional characters. This made the build possible.
2. I have copied the contents of the requirements file and saved it in other.txt in UTF-8 in using notepad.
3. Moved the above file to my directory structure and mentioned other.txt as the file containing requirements. This successfully built the package.
This confirms that the pip freeze > requirements.txt command is encoding the file not in UTF-8 (UTF -16 LE in my case).