Title: Source and editable installs fail in some locales · Issue #1747 · gitpython-developers/GitPython · GitHub
Open Graph Title: Source and editable installs fail in some locales · Issue #1747 · gitpython-developers/GitPython
X Title: Source and editable installs fail in some locales · Issue #1747 · gitpython-developers/GitPython
Description: Methods of installing GitPython that run code from setup.py fail in some locales. This does not affect installing from a wheel, but it does affect installing from an sdist, or installing from a local directory, including the editable ins...
Open Graph Description: Methods of installing GitPython that run code from setup.py fail in some locales. This does not affect installing from a wheel, but it does affect installing from an sdist, or installing from a loc...
X Description: Methods of installing GitPython that run code from setup.py fail in some locales. This does not affect installing from a wheel, but it does affect installing from an sdist, or installing from a loc...
Opengraph URL: https://github.com/gitpython-developers/GitPython/issues/1747
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Source and editable installs fail in some locales","articleBody":"Methods of installing GitPython that run code from `setup.py` fail in some locales. This does not affect installing from a wheel, but it does affect installing from an sdist, or installing from a local directory, including the editable install procedure recommended for development in the readme. The same problem happens when building GitPython. Building or installing using the old method of running `setup.py` directly is also affected. The error is of this form, though the codec will not always be `gbk`:\r\n\r\n```text\r\nUnicodeDecodeError: 'gbk' codec can't decode byte 0xa6 in position 473: illegal multibyte sequence\r\n```\r\n\r\nI am unsure if this ever happens in practice on Unix-like systems, whose locales are usually UTF-8. However, it happens on Windows systems in which `README.md` cannot be decoded using the system's active ANSI code page. This is a rarely-changed systemwide setting, so changing the user preferred languages, display language, or input method are not workarounds. I discovered this on a Simplified Chinese (zh-CN) build of Windows Server 2022 while using it to test some WSL-related test helper logic in #1745. Such a system uses ANSI code page 936. `README.md` is UTF-8, but it currently happens that it can be decoded with code page 1252, which Windows builds for Western European languages use as their ANSI code page. I expect encodings other than cp936 to fail as well.\r\n\r\nWith the PyPI sdist for GitPython 3.1.40 (on Python 3.12 x86-64, though I expect all supported versions to be affected):\r\n\r\n```text\r\n(.venv) C:\\Users\\Administrator\\gptest\u003e pip install --no-binary GitPython GitPython\r\nCollecting GitPython\r\n Using cached GitPython-3.1.40.tar.gz (200 kB)\r\n Installing build dependencies ... done\r\n Getting requirements to build wheel ... error\r\n error: subprocess-exited-with-error\r\n\r\n × Getting requirements to build wheel did not run successfully.\r\n │ exit code: 1\r\n ╰─\u003e [18 lines of output]\r\n Traceback (most recent call last):\r\n File \"C:\\Users\\Administrator\\gptest\\.venv\\Lib\\site-packages\\pip\\_vendor\\pyproject_hooks\\_in_process\\_in_process.py\", line 353, in \u003cmodule\u003e\r\n main()\r\n File \"C:\\Users\\Administrator\\gptest\\.venv\\Lib\\site-packages\\pip\\_vendor\\pyproject_hooks\\_in_process\\_in_process.py\", line 335, in main\r\n json_out['return_val'] = hook(**hook_input['kwargs'])\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"C:\\Users\\Administrator\\gptest\\.venv\\Lib\\site-packages\\pip\\_vendor\\pyproject_hooks\\_in_process\\_in_process.py\", line 118, in get_requires_for_build_wheel\r\n return hook(config_settings)\r\n ^^^^^^^^^^^^^^^^^^^^^\r\n File \"C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-build-env-8j1uxmuv\\overlay\\Lib\\site-packages\\setuptools\\build_meta.py\", line 325, in get_requires_for_build_wheel\r\n return self._get_build_requires(config_settings, requirements=['wheel'])\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-build-env-8j1uxmuv\\overlay\\Lib\\site-packages\\setuptools\\build_meta.py\", line 295, in _get_build_requires\r\n self.run_setup()\r\n File \"C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-build-env-8j1uxmuv\\overlay\\Lib\\site-packages\\setuptools\\build_meta.py\", line 311, in run_setup\r\n exec(code, locals())\r\n File \"\u003cstring\u003e\", line 20, in \u003cmodule\u003e\r\n UnicodeDecodeError: 'gbk' codec can't decode byte 0xa6 in position 473: illegal multibyte sequence\r\n [end of output]\r\n\r\n note: This error originates from a subprocess, and is likely not a problem with pip.\r\nerror: subprocess-exited-with-error\r\n\r\n× Getting requirements to build wheel did not run successfully.\r\n│ exit code: 1\r\n╰─\u003e See above for output.\r\n\r\nnote: This error originates from a subprocess, and is likely not a problem with pip.\r\n```\r\n\r\nA workaround is to pass `-X utf8` to `python`. For example, `python -X utf8 -m pip install ...` can be used for installation.\r\n\r\nThe fix should be straightforward. Importing `setup.py` confirms that the specific cause is reading `README.md`:\r\n\r\n```text\r\n(.venv) C:\\Users\\Administrator\\repos\\GitPython [main ≡]\u003e python -c 'import setup'\r\nTraceback (most recent call last):\r\n File \"\u003cstring\u003e\", line 1, in \u003cmodule\u003e\r\n File \"C:\\Users\\Administrator\\repos\\GitPython\\setup.py\", line 20, in \u003cmodule\u003e\r\n long_description = rm_file.read()\r\n ^^^^^^^^^^^^^^\r\nUnicodeDecodeError: 'gbk' codec can't decode byte 0xa6 in position 477: illegal multibyte sequence\r\n```\r\n\r\nIt can be fixed by passing `encoding=\"utf-8\"`. **I have proposed this change in #1748.**\r\n\r\ngitdb and smmap are unaffected, because [gitdb does not open files to read those data in `setup.py`](https://github.com/gitpython-developers/gitdb/blob/ec58b7e55c8fec2479290a22faa293799f6805fc/setup.py#L24), while [smmap does open `README.md` but passes `encoding=\"utf-8\"`](https://github.com/gitpython-developers/smmap/blob/f1ace75be355fdec927793e462b9b12bf6ec9520/setup.py#L14).","author":{"url":"https://github.com/EliahKagan","@type":"Person","name":"EliahKagan"},"datePublished":"2023-11-28T23:15:50.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/1747/GitPython/issues/1747"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e899c2b8-2e77-c693-e316-9c85901f06bd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8EB8:AB0F3:104A2CF:15C9D67:69684AEC |
| html-safe-nonce | 70b76ef161afd67e9cf63173d3de4df1a12c5a94fc1be95a9fa29a2d880c7083 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RUI4OkFCMEYzOjEwNEEyQ0Y6MTVDOUQ2Nzo2OTY4NEFFQyIsInZpc2l0b3JfaWQiOiI1NDM4OTYzMzE0ODczMzU0OTg4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 33b1c71c7a6ce509337bf6f2b302e9e05e21350d8bf0d3707b514e7a02cab909 |
| hovercard-subject-tag | issue:2015479682 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/gitpython-developers/GitPython/1747/issue_layout |
| twitter:image | https://opengraph.githubassets.com/11d72653710355436811149eb1a685b1d136eacde2ae44ad9c8fe5d7dcf56068/gitpython-developers/GitPython/issues/1747 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/11d72653710355436811149eb1a685b1d136eacde2ae44ad9c8fe5d7dcf56068/gitpython-developers/GitPython/issues/1747 |
| og:image:alt | Methods of installing GitPython that run code from setup.py fail in some locales. This does not affect installing from a wheel, but it does affect installing from an sdist, or installing from a loc... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | EliahKagan |
| hostname | github.com |
| expected-hostname | github.com |
| None | f16c57f41ed243e5b4dfe9b9bcd6828bd83080b1b6dbb4ff239bbe9745f12e0c |
| turbo-cache-control | no-preview |
| go-import | github.com/gitpython-developers/GitPython git https://github.com/gitpython-developers/GitPython.git |
| octolytics-dimension-user_id | 503709 |
| octolytics-dimension-user_login | gitpython-developers |
| octolytics-dimension-repository_id | 1126087 |
| octolytics-dimension-repository_nwo | gitpython-developers/GitPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1126087 |
| octolytics-dimension-repository_network_root_nwo | gitpython-developers/GitPython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | cfa7062cc6d4fe8fcb156bd33f4c97bd3b2470af |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width