Skip to content

Add uv instructions to bindings/python/README.md #1514

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Fokko
Copy link
Contributor

@Fokko Fokko commented Jul 16, 2025

While building from a fresh setup, I noticed that uv is a requirement:

python3 -m hatch build    


╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /Users/fokko.driesprong/Library/Python/3.9/lib/python/site-packages/hatch/cli/__init__.py:221 in │
│ main                                                                                             │
│                                                                                                  │
│   218                                                                                            │
│   219 def main():  # no cov                                                                      │
│   220 │   try:                                                                                   │
│ ❱ 221 │   │   hatch(prog_name='hatch', windows_expand_args=False)                                │
│   222 │   except Exception:  # noqa: BLE001                                                      │
│   223 │   │   import sys                                                                         │
│   224                                                                                            │
│                                                                                                  │
│ /Users/fokko.driesprong/Library/Python/3.9/lib/python/site-packages/click/core.py:1161 in        │
│ __call__                                                                                         │
│                                                                                                  │
│ /Users/fokko.driesprong/Library/Python/3.9/lib/python/site-packages/click/core.py:1082 in main   │
│                                                                                                  │
│ /Users/fokko.driesprong/Library/Python/3.9/lib/python/site-packages/click/core.py:1697 in invoke │
│                                                                                                  │
│ /Users/fokko.driesprong/Library/Python/3.9/lib/python/site-packages/click/core.py:1443 in invoke │
│                                                                                                  │
│ /Users/fokko.driesprong/Library/Python/3.9/lib/python/site-packages/click/core.py:788 in invoke  │
│                                                                                                  │
│ /Users/fokko.driesprong/Library/Python/3.9/lib/python/site-packages/click/decorators.py:45 in    │
│ new_func                                                                                         │
│                                                                                                  │
│ /Users/fokko.driesprong/Library/Python/3.9/lib/python/site-packages/hatch/cli/build/__init__.py: │
│ 72 in build                                                                                      │
│                                                                                                  │
│    69 │   │   targets = ('sdist', 'wheel')                                                       │
│    70 │                                                                                          │
│    71 │   if app.project.metadata.build.build_backend != 'hatchling.build':                      │
│ ❱  72 │   │   for context in app.runner_context(['hatch-build']):                                │
│    73 │   │   │   context.add_shell_command(                                                     │
│    74 │   │   │   │   'build-sdist' if targets == ('sdist',) else 'build-wheel' if targets ==    │
│    75 │   │   │   )                                                                              │
│                                                                                                  │
│ /Users/fokko.driesprong/Library/Python/3.9/lib/python/site-packages/hatch/cli/application.py:224 │
│ in runner_context                                                                                │
│                                                                                                  │
│   221 │   │   │   │   context = ExecutionContext(environment)                                    │
│   222 │   │   │   │   yield context                                                              │
│   223 │   │   │   │                                                                              │
│ ❱ 224 │   │   │   │   self.prepare_environment(environment)                                      │
│   225 │   │   │   │   with EnvVars(context.env_vars):                                            │
│   226 │   │   │   │   │   self.run_shell_commands(context)                                       │
│   227                                                                                            │
│                                                                                                  │
│ /Users/fokko.driesprong/Library/Python/3.9/lib/python/site-packages/hatch/cli/application.py:111 │
│ in prepare_environment                                                                           │
│                                                                                                  │
│   108 │   │   │   self.env_metadata.reset(environment)                                           │
│   109 │   │   │                                                                                  │
│   110 │   │   │   with environment.app_status_creation():                                        │
│ ❱ 111 │   │   │   │   environment.create()                                                       │
│   112 │   │   │                                                                                  │
│   113 │   │   │   if not environment.skip_install:                                               │
│   114 │   │   │   │   if environment.pre_install_commands:                                       │
│                                                                                                  │
│ /Users/fokko.driesprong/Library/Python/3.9/lib/python/site-packages/hatch/env/virtual.py:157 in  │
│ create                                                                                           │
│                                                                                                  │
│   154 """                                                                                        │
│   155 │   │   │   │   )                                                                          │
│   156 │   │                                                                                      │
│ ❱ 157 │   │   with self.expose_uv():                                                             │
│   158 │   │   │   self.virtual_env.create(self.parent_python, allow_system_packages=self.confi   │
│   159 │                                                                                          │
│   160 │   def remove(self):                                                                      │
│                                                                                                  │
│ /Users/fokko.driesprong/Library/Python/3.9/lib/python/site-packages/hatch/utils/structures.py:38 │
│ in __enter__                                                                                     │
│                                                                                                  │
│   35 │                                                                                           │
│   36 │   def __enter__(self) -> None:                                                            │
│   37 │   │   os.environ.clear()                                                                  │
│ ❱ 38 │   │   os.environ.update(self)                                                             │
│   39 │                                                                                           │
│   40 │   def __exit__(                                                                           │
│   41 │   │   self, exc_type: type[BaseException] | None, exc_value: BaseException | None, tra    │
│                                                                                                  │
│ /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python │
│ 3.9/_collections_abc.py:942 in update                                                            │
│                                                                                                  │
│    939 │   │   '''                                                                               │
│    940 │   │   if isinstance(other, Mapping):                                                    │
│    941 │   │   │   for key in other:                                                             │
│ ❱  942 │   │   │   │   self[key] = other[key]                                                    │
│    943 │   │   elif hasattr(other, "keys"):                                                      │
│    944 │   │   │   for key in other.keys():                                                      │
│    945 │   │   │   │   self[key] = other[key]                                                    │
│                                                                                                  │
│ /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python │
│ 3.9/os.py:684 in __setitem__                                                                     │
│                                                                                                  │
│    681 │                                                                                         │
│    682 │   def __setitem__(self, key, value):                                                    │
│    683 │   │   key = self.encodekey(key)                                                         │
│ ❱  684 │   │   value = self.encodevalue(value)                                                   │
│    685 │   │   putenv(key, value)                                                                │
│    686 │   │   self._data[key] = value                                                           │
│    687                                                                                           │
│                                                                                                  │
│ /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python │
│ 3.9/os.py:756 in encode                                                                          │
│                                                                                                  │
│    753 │   │   encoding = sys.getfilesystemencoding()                                            │
│    754 │   │   def encode(value):                                                                │
│    755 │   │   │   if not isinstance(value, str):                                                │
│ ❱  756 │   │   │   │   raise TypeError("str expected, not %s" % type(value).__name__)            │
│    757 │   │   │   return value.encode(encoding, 'surrogateescape')                              │
│    758 │   │   def decode(value):                                                                │
│    759 │   │   │   return value.decode(encoding, 'surrogateescape')                              │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: str expected, not NoneType

While building from a fresh setup, I noticed that uv is a requirement:

```
python3 -m hatch build    


╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /Users/fokko.driesprong/Library/Python/3.9/lib/python/site-packages/hatch/cli/__init__.py:221 in │
│ main                                                                                             │
│                                                                                                  │
│   218                                                                                            │
│   219 def main():  # no cov                                                                      │
│   220 │   try:                                                                                   │
│ ❱ 221 │   │   hatch(prog_name='hatch', windows_expand_args=False)                                │
│   222 │   except Exception:  # noqa: BLE001                                                      │
│   223 │   │   import sys                                                                         │
│   224                                                                                            │
│                                                                                                  │
│ /Users/fokko.driesprong/Library/Python/3.9/lib/python/site-packages/click/core.py:1161 in        │
│ __call__                                                                                         │
│                                                                                                  │
│ /Users/fokko.driesprong/Library/Python/3.9/lib/python/site-packages/click/core.py:1082 in main   │
│                                                                                                  │
│ /Users/fokko.driesprong/Library/Python/3.9/lib/python/site-packages/click/core.py:1697 in invoke │
│                                                                                                  │
│ /Users/fokko.driesprong/Library/Python/3.9/lib/python/site-packages/click/core.py:1443 in invoke │
│                                                                                                  │
│ /Users/fokko.driesprong/Library/Python/3.9/lib/python/site-packages/click/core.py:788 in invoke  │
│                                                                                                  │
│ /Users/fokko.driesprong/Library/Python/3.9/lib/python/site-packages/click/decorators.py:45 in    │
│ new_func                                                                                         │
│                                                                                                  │
│ /Users/fokko.driesprong/Library/Python/3.9/lib/python/site-packages/hatch/cli/build/__init__.py: │
│ 72 in build                                                                                      │
│                                                                                                  │
│    69 │   │   targets = ('sdist', 'wheel')                                                       │
│    70 │                                                                                          │
│    71 │   if app.project.metadata.build.build_backend != 'hatchling.build':                      │
│ ❱  72 │   │   for context in app.runner_context(['hatch-build']):                                │
│    73 │   │   │   context.add_shell_command(                                                     │
│    74 │   │   │   │   'build-sdist' if targets == ('sdist',) else 'build-wheel' if targets ==    │
│    75 │   │   │   )                                                                              │
│                                                                                                  │
│ /Users/fokko.driesprong/Library/Python/3.9/lib/python/site-packages/hatch/cli/application.py:224 │
│ in runner_context                                                                                │
│                                                                                                  │
│   221 │   │   │   │   context = ExecutionContext(environment)                                    │
│   222 │   │   │   │   yield context                                                              │
│   223 │   │   │   │                                                                              │
│ ❱ 224 │   │   │   │   self.prepare_environment(environment)                                      │
│   225 │   │   │   │   with EnvVars(context.env_vars):                                            │
│   226 │   │   │   │   │   self.run_shell_commands(context)                                       │
│   227                                                                                            │
│                                                                                                  │
│ /Users/fokko.driesprong/Library/Python/3.9/lib/python/site-packages/hatch/cli/application.py:111 │
│ in prepare_environment                                                                           │
│                                                                                                  │
│   108 │   │   │   self.env_metadata.reset(environment)                                           │
│   109 │   │   │                                                                                  │
│   110 │   │   │   with environment.app_status_creation():                                        │
│ ❱ 111 │   │   │   │   environment.create()                                                       │
│   112 │   │   │                                                                                  │
│   113 │   │   │   if not environment.skip_install:                                               │
│   114 │   │   │   │   if environment.pre_install_commands:                                       │
│                                                                                                  │
│ /Users/fokko.driesprong/Library/Python/3.9/lib/python/site-packages/hatch/env/virtual.py:157 in  │
│ create                                                                                           │
│                                                                                                  │
│   154 """                                                                                        │
│   155 │   │   │   │   )                                                                          │
│   156 │   │                                                                                      │
│ ❱ 157 │   │   with self.expose_uv():                                                             │
│   158 │   │   │   self.virtual_env.create(self.parent_python, allow_system_packages=self.confi   │
│   159 │                                                                                          │
│   160 │   def remove(self):                                                                      │
│                                                                                                  │
│ /Users/fokko.driesprong/Library/Python/3.9/lib/python/site-packages/hatch/utils/structures.py:38 │
│ in __enter__                                                                                     │
│                                                                                                  │
│   35 │                                                                                           │
│   36 │   def __enter__(self) -> None:                                                            │
│   37 │   │   os.environ.clear()                                                                  │
│ ❱ 38 │   │   os.environ.update(self)                                                             │
│   39 │                                                                                           │
│   40 │   def __exit__(                                                                           │
│   41 │   │   self, exc_type: type[BaseException] | None, exc_value: BaseException | None, tra    │
│                                                                                                  │
│ /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python │
│ 3.9/_collections_abc.py:942 in update                                                            │
│                                                                                                  │
│    939 │   │   '''                                                                               │
│    940 │   │   if isinstance(other, Mapping):                                                    │
│    941 │   │   │   for key in other:                                                             │
│ ❱  942 │   │   │   │   self[key] = other[key]                                                    │
│    943 │   │   elif hasattr(other, "keys"):                                                      │
│    944 │   │   │   for key in other.keys():                                                      │
│    945 │   │   │   │   self[key] = other[key]                                                    │
│                                                                                                  │
│ /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python │
│ 3.9/os.py:684 in __setitem__                                                                     │
│                                                                                                  │
│    681 │                                                                                         │
│    682 │   def __setitem__(self, key, value):                                                    │
│    683 │   │   key = self.encodekey(key)                                                         │
│ ❱  684 │   │   value = self.encodevalue(value)                                                   │
│    685 │   │   putenv(key, value)                                                                │
│    686 │   │   self._data[key] = value                                                           │
│    687                                                                                           │
│                                                                                                  │
│ /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python │
│ 3.9/os.py:756 in encode                                                                          │
│                                                                                                  │
│    753 │   │   encoding = sys.getfilesystemencoding()                                            │
│    754 │   │   def encode(value):                                                                │
│    755 │   │   │   if not isinstance(value, str):                                                │
│ ❱  756 │   │   │   │   raise TypeError("str expected, not %s" % type(value).__name__)            │
│    757 │   │   │   return value.encode(encoding, 'surrogateescape')                              │
│    758 │   │   def decode(value):                                                                │
│    759 │   │   │   return value.decode(encoding, 'surrogateescape')                              │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: str expected, not NoneType
```
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.

1 participant