Repository: openvinotoolkit/datumaro

Issue:
Error installing via pip
Greetings.
recently I tried to install datumaro via pip on Windows 10. 
I tried to do it on two devices and in both cases an error occured during installation due to encoding issues.

`       ...File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\encodings\cp1251.py", line 23, in decode
          return codecs.charmap_decode(input,self.errors,decoding_table)[0]
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 3870: character maps to <undefined>
      [end of output]`

I tried to change encoding settings in PyCharm but it brought no results. I also tried to install different versions of datumaro (default, headless, versions), updated pip and used pip3. Python version is 3.11 hovewer I doubt it is involved.
Obviously it is Windows encoding issue, but I failed to find any related issues concerning the problem. Had someone seen the same error? 





Discussion:
Hi @Votun,
Thanks for your interests on our project.
Could you please provide the full stacktrace?
We face this kind of problem firstly because our CI also tests on Windows, but there has not been this problem.

Or would you try this?
https://stackoverflow.com/a/70923999
Sure. 

`Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com
Collecting datumaro
  Downloading datumaro-1.3.2.tar.gz (451 kB)
     -------------------------------------- 451.4/451.4 kB 1.9 MB/s eta 0:00:00
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'error'

  error: subprocess-exited-with-error
  
  Getting requirements to build wheel did not run successfully.
  exit code: 1
  
  [21 lines of output]
  Traceback (most recent call last):
    File "C:\Users\Vitec\Desktop\nsf\endofarm\ml_service\venv\Lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 351, in <module>
      main()
    File "C:\Users\Vitec\Desktop\nsf\endofarm\ml_service\venv\Lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 333, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Vitec\Desktop\nsf\endofarm\ml_service\venv\Lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 118, in get_requires_for_build_wheel
      return hook(config_settings)
             ^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Vitec\AppData\Local\Temp\pip-build-env-0h1s3iqw\overlay\Lib\site-packages\setuptools\build_meta.py", line 341, in get_requires_for_build_wheel
      return self._get_build_requires(config_settings, requirements=['wheel'])
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Vitec\AppData\Local\Temp\pip-build-env-0h1s3iqw\overlay\Lib\site-packages\setuptools\build_meta.py", line 323, in _get_build_requires
      self.run_setup()
    File "C:\Users\Vitec\AppData\Local\Temp\pip-build-env-0h1s3iqw\overlay\Lib\site-packages\setuptools\build_meta.py", line 338, in run_setup
      exec(code, locals())
    File "<string>", line 58, in <module>
    File "C:\Users\Vitec\AppData\Local\Programs\Python\Python311\Lib\encodings\cp1251.py", line 23, in decode
      return codecs.charmap_decode(input,self.errors,decoding_table)[0]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 3870: character maps to <undefined>
  [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

Getting requirements to build wheel did not run successfully.
exit code: 1

See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

[notice] A new release of pip available: 22.3.1 -> 23.2.1
[notice] To update, run: python.exe -m pip install --upgrade pip`
> Hi @Votun, Thanks for your interests on our project. Could you please provide the full stacktrace? We face this kind of problem firstly because our CI also tests on Windows, but there has not been this problem.
> 
> Or would you try this? https://stackoverflow.com/a/70923999

Actually, the last stackoverflow answer helped. Though I did it in quite ugly style)
Closing issue?
> > Hi @Votun, Thanks for your interests on our project. Could you please provide the full stacktrace? We face this kind of problem firstly because our CI also tests on Windows, but there has not been this problem.
> > Or would you try this? https://stackoverflow.com/a/70923999
> 
> Actually, the last stackoverflow answer helped. Though I did it in quite ugly style) Closing issue?

Good to hear that!

I think there is something to fix on our side. I'll close this ticket if we finish that work.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -19,7 +19,7 @@ def find_version(project_dir=None):
 
     file_path = osp.join(project_dir, "datumaro", "version.py")
 
-    with open(file_path, "r") as version_file:
+    with open(file_path, "r", encoding="utf-8") as version_file:
         version_text = version_file.read()
 
     # PEP440:
@@ -39,7 +39,7 @@ def find_version(project_dir=None):
 
 
 def parse_requirements(filename=CORE_REQUIREMENTS_FILE):
-    with open(filename) as fh:
+    with open(filename, "r", encoding="utf-8") as fh:
         return fh.readlines()
 
 
@@ -51,7 +51,7 @@ def parse_requirements(filename=CORE_REQUIREMENTS_FILE):
 
 DEFAULT_REQUIREMENTS = parse_requirements(DEFAULT_REQUIREMENTS_FILE)
 
-with open("README.md", "r") as fh:
+with open("README.md", "r", encoding="utf-8") as fh:
     long_description = fh.read()
 
 ext_modules = [


Test patch: