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

Is it possible not to force dependency on Rust? #1405

Closed
barracuda156 opened this issue Oct 30, 2024 · 19 comments · Fixed by #1417
Closed

Is it possible not to force dependency on Rust? #1405

barracuda156 opened this issue Oct 30, 2024 · 19 comments · Fixed by #1417

Comments

@barracuda156
Copy link

Recent update pulled in Rust and a lot of related stuff as dependencies. This is undesirable both due to just being heavy and due to Rust being broken on some non-mainstream platforms (which makes it impossible to install this at all).

@barracuda156
Copy link
Author

UPD. I apologize, I should have checked README first. Apparently Rust can be disabled, and it is MacPorts fault not to consider that. I close this and will make a PR to MacPorts.

@barracuda156
Copy link
Author

@jelmer Sorry, I have to reopen this: Rust is unconditionally pulled in here:

from setuptools_rust import Binding, RustExtension

Or do I miss something? I think I passed --pure arg, but it still wants setuptools_rust.

@barracuda156 barracuda156 reopened this Oct 30, 2024
@barracuda156
Copy link
Author

--->  Building py312-dulwich
Executing:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_python_py-dulwich/py312-dulwich/work/dulwich-0.22.3" && /opt/local/Library/Frameworks/Python.framework/Versions/3.12/bin/python3.12 -m build --no-isolation --config-setting build-option=--pure --wheel --outdir /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_python_py-dulwich/py312-dulwich/work 
* Getting build dependencies for wheel...
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
    main()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyproject_hooks/_in_process/_in_process.py", line 373, in main
    json_out["return_val"] = hook(**hook_input["kwargs"])
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyproject_hooks/_in_process/_in_process.py", line 143, in get_requires_for_build_wheel
    return hook(config_settings)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/setuptools/build_meta.py", line 332, in get_requires_for_build_wheel
    return self._get_build_requires(config_settings, requirements=[])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/setuptools/build_meta.py", line 302, in _get_build_requires
    self.run_setup()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/setuptools/build_meta.py", line 318, in run_setup
    exec(code, locals())
  File "<string>", line 9, in <module>
ModuleNotFoundError: No module named 'setuptools_rust'

ERROR Backend subprocess exited when trying to invoke get_requires_for_build_wheel
Command failed:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_python_py-dulwich/py312-dulwich/work/dulwich-0.22.3" && /opt/local/Library/Frameworks/Python.framework/Versions/3.12/bin/python3.12 -m build --no-isolation --config-setting build-option=--pure --wheel --outdir /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_python_py-dulwich/py312-dulwich/work 
Exit code: 1
Error: Failed to build py312-dulwich: command execution failed

@jelmer
Copy link
Owner

jelmer commented Oct 30, 2024

That's just importing setuptools_rust, it's not actually running rust until the rust modules are built, which can be disabled with --pure or the PURE environment variable.

@barracuda156
Copy link
Author

Ok, got it, then I can perhaps can patch it out.

P. S. MacPorts requires Rust for setuptools-rust (which could be wrong, I have no idea).

Full Name: py312-setuptools-rust @1.9.0_0
Build Dependencies:   py312-setuptools_scm, py312-build, py312-installer,
                      py312-setuptools, py312-wheel
Library Dependencies: python312
Runtime Dependencies: py312-semantic_version, py312-typing_extensions, cargo,
                      rust

@jelmer
Copy link
Owner

jelmer commented Oct 30, 2024

python doesn't really have the concept of optional dependencies for setup.py, so on dulwich side we can't do much here. If you want to disable the rust extensions on Mac you could indeed just patch out the rust bits in setup.py.

I think setuptools_rust should probably not have a hard dependency on rust, but a recommends or something like that (I'm not sure if macports has that concept)

@barracuda156
Copy link
Author

Ok, perhaps I got it working. Needed to patch pyproject.toml as well.

36-14% port -v installed py312-dulwich
The following ports are currently installed:
  py312-dulwich @0.21.7_0 requested_variants='' platform='darwin 10' archs='ppc' date='2024-06-18T06:19:03+0800'
  py312-dulwich @0.22.3_0 (active) requested_variants='' platform='darwin 10' archs='ppc' date='2024-10-31T07:00:31+0800'
36-14% port contents py312-dulwich
Port py312-dulwich @0.22.3_0 contains:
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/bin/dul-receive-pack
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/bin/dul-upload-pack
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/bin/dulwich
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich-0.22.3.dist-info/COPYING
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich-0.22.3.dist-info/METADATA
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich-0.22.3.dist-info/RECORD
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich-0.22.3.dist-info/WHEEL
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich-0.22.3.dist-info/entry_points.txt
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich-0.22.3.dist-info/top_level.txt
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__init__.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__main__.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/__init__.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/__init__.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/__main__.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/__main__.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/archive.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/archive.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/bundle.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/bundle.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/cli.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/cli.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/client.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/client.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/config.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/config.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/credentials.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/credentials.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/diff_tree.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/diff_tree.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/errors.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/errors.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/fastexport.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/fastexport.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/file.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/file.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/graph.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/graph.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/greenthreads.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/greenthreads.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/hooks.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/hooks.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/ignore.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/ignore.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/index.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/index.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/lfs.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/lfs.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/line_ending.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/line_ending.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/log_utils.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/log_utils.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/lru_cache.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/lru_cache.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/mailmap.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/mailmap.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/object_store.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/object_store.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/objects.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/objects.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/objectspec.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/objectspec.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/pack.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/pack.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/patch.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/patch.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/porcelain.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/porcelain.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/protocol.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/protocol.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/reflog.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/reflog.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/refs.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/refs.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/repo.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/repo.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/server.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/server.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/stash.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/stash.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/submodule.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/submodule.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/walk.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/walk.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/web.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/__pycache__/web.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/archive.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/bundle.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/cli.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/client.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/cloud/__init__.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/cloud/__pycache__/__init__.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/cloud/__pycache__/__init__.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/cloud/__pycache__/gcs.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/cloud/__pycache__/gcs.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/cloud/gcs.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/config.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/contrib/__init__.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/contrib/__pycache__/__init__.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/contrib/__pycache__/__init__.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/contrib/__pycache__/diffstat.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/contrib/__pycache__/diffstat.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/contrib/__pycache__/paramiko_vendor.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/contrib/__pycache__/paramiko_vendor.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/contrib/__pycache__/release_robot.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/contrib/__pycache__/release_robot.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/contrib/__pycache__/requests_vendor.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/contrib/__pycache__/requests_vendor.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/contrib/__pycache__/swift.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/contrib/__pycache__/swift.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/contrib/diffstat.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/contrib/paramiko_vendor.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/contrib/release_robot.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/contrib/requests_vendor.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/contrib/swift.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/credentials.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/diff_tree.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/errors.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/fastexport.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/file.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/graph.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/greenthreads.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/hooks.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/ignore.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/index.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/lfs.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/line_ending.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/log_utils.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/lru_cache.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/mailmap.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/object_store.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/objects.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/objectspec.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/pack.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/patch.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/porcelain.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/protocol.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/py.typed
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/reflog.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/refs.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/repo.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/server.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/stash.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/stdint.h
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/submodule.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/tests/__init__.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/tests/__pycache__/__init__.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/tests/__pycache__/__init__.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/tests/__pycache__/test_object_store.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/tests/__pycache__/test_object_store.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/tests/__pycache__/utils.cpython-312.opt-1.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/tests/__pycache__/utils.cpython-312.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/tests/test_object_store.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/tests/utils.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/walk.py
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dulwich/web.py
  /opt/local/bin/dul-receive-pack-3.12
  /opt/local/bin/dul-upload-pack-3.12
  /opt/local/bin/dulwich-3.12

Does it make sense to restore C extensions (on legacy systems where Rust is broken)?

@jelmer
Copy link
Owner

jelmer commented Oct 30, 2024

What platform are you using? rust should in general work fine on Mac OS X.

@barracuda156
Copy link
Author

barracuda156 commented Oct 30, 2024

What platform are you using? rust should in general work fine on Mac OS X.

Not on PowerPC. (At least not until mrustc and GCC backend work.)

Early x86 systems also have troubles with Rust.

P. S. I think Rust is also broken on ppc on OpenBSD, unless something changed very recently.

@jelmer
Copy link
Owner

jelmer commented Oct 30, 2024

Ah, I see :-(

Unfortunately maintaining two sets of extensions is too much of a pain, and since the extensions are optional I'm afraid I'd rather recommend people disable them on those platforms.

I'd also accept PRs to automatically enable pure mode on platforms that won't support building the extensions.

@jelmer
Copy link
Owner

jelmer commented Oct 30, 2024

Closing this for now; please do comment/reopen if you have more concerns.

@jelmer jelmer closed this as completed Oct 30, 2024
@barracuda156
Copy link
Author

Thank you. Yes, it is very much understandable that maintaining a separate C implementation is a burden, especially given that user impact is small.

@grobian
Copy link

grobian commented Nov 5, 2024

I ran into this too. setuptools_rust requires a rust to be installed. The only way to resolve it was to drop the setuptools_rust require and the RustExtensions usage.

It is not a matter of the system being capable to run Rust or not, it is the ability to install dulwich as Pure Python code from source on a system not having Rust.

@jelmer
Copy link
Owner

jelmer commented Nov 5, 2024

Setuptools_rust shouldn't depend on rust - that might be a choice of your package manager.

@eli-schwartz
Copy link
Contributor

Setuptools_rust shouldn't depend on rust - that might be a choice of your package manager.

In fact it should depend on rust, because that's the only way to use setuptools_rust. Optional dependencies don't help because then no nothing can actually depend on something that is merely optional.

The issue here is that dulwich conditionally uses RustExtension but doesn't conditionally import it.

python doesn't really have the concept of optional dependencies for setup.py, so on dulwich side we can't do much here. If you want to disable the rust extensions on Mac you could indeed just patch out the rust bits in setup.py.

It is absolutely possible to have optional dependencies for setup.py, since setup.py can augment pyproject.toml. In fact there are several build backends, such as meson-python and scikit-build-core, that natively do things like dynamically add additional build-requires if you don't yet have a system C++ level installation of cmake or ninja. The pyproject.toml specification shipped from day one with an accompanying hook for the specific use case of allowing build backends to specify additional build-requires.

If I recall correctly, specifying setup requires in setup.py itself gets passed through to that hook, which means setuptools_rust would only be installed when the environment variable to disable it isn't defined.

@jelmer
Copy link
Owner

jelmer commented Nov 5, 2024

Setuptools_rust shouldn't depend on rust - that might be a choice of your package manager.

In fact it should depend on rust, because that's the only way to use setuptools_rust. Optional dependencies don't help because then no nothing can actually depend on something that is merely optional.

I'd agree that it isn't particularly helpful without pulling in rust, but setuptools_rust itself is perfectly importable without having rust installed. Having a hard dependency on rust is a choice on the macports side.

The issue here is that dulwich conditionally uses RustExtension but doesn't conditionally import it.

python doesn't really have the concept of optional dependencies for setup.py, so on dulwich side we can't do much here. If you want to disable the rust extensions on Mac you could indeed just patch out the rust bits in setup.py.

It is absolutely possible to have optional dependencies for setup.py, since setup.py can augment pyproject.toml. In fact there are several build backends, such as meson-python and scikit-build-core, that natively do things like dynamically add additional build-requires if you don't yet have a system C++ level installation of cmake or ninja. The pyproject.toml specification shipped from day one with an accompanying hook for the specific use case of allowing build backends to specify additional build-requires.e

If I recall correctly, specifying setup requires in setup.py itself gets passed through to that hook, which means setuptools_rust would only be installed when the environment variable to disable it isn't defined.

At a glance I don't see how that would address the issue; we need to import from setuptools_rust before calling setup() and if we stopped specifying a build-requires on setuptools_rust, then we'd presumably need to call setup() to declare the dependency on setuptools_rust.

Happy to be convinced that I'm wrong and open to PRs - so long as that doesn't mean switching to a completely different build system.

eli-schwartz added a commit to eli-schwartz/dulwich that referenced this issue Nov 5, 2024
When a pure build is requested, no compiled extensions are produced. The
setuptools_rust dependency ends up imported-but-not-used. Teach
setuptools to avoid build-requiring it in this case.

Unfortunately, setuptools deprecated the setup_requires keyword which is
intended to do this and replaced it with confusing advice that users
should implement their own build backend that subclasses setuptools.
It's a bit more busywork to do as the setuptools documentation suggests
but at least the result is as expected.

Closes: jelmer#1405
Bug: pypa/setuptools#2854
Buggy: pypa/setuptools#2897
eli-schwartz added a commit to eli-schwartz/dulwich that referenced this issue Nov 5, 2024
When a pure build is requested, no compiled extensions are produced. The
setuptools_rust dependency ends up imported-but-not-used. Teach
setuptools to avoid build-requiring it in this case.

Closes: jelmer#1405
jelmer added a commit that referenced this issue Nov 5, 2024
When a pure build is requested, no compiled extensions are produced. The
setuptools_rust dependency ends up imported-but-not-used. Teach
setuptools to avoid build-requiring it in this case.

Closes: #1405
@eli-schwartz
Copy link
Contributor

@grobian this is fixed in the linked PR, thanks for the commits to dev-python/dulwich that made me notice this. :) We can remove our hacks in a bit, I guess.

@barracuda156
Copy link
Author

Could you say how to pass --pure correctly so that it works? I have applied 9fea5e3 on top of 0.22.3, but getting:

--->  Building py311-dulwich
Executing:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_python_py-dulwich/py311-dulwich/work/dulwich-0.22.3" && /opt/local/Library/Frameworks/Python.framework/Versions/3.11/bin/python3.11 -m build --no-isolation --config-setting build-option=--pure --wheel --outdir /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_python_py-dulwich/py311-dulwich/work 
* Getting build dependencies for wheel...

ERROR Missing dependencies:
	setuptools_rust
Command failed:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_python_py-dulwich/py311-dulwich/work/dulwich-0.22.3" && /opt/local/Library/Frameworks/Python.framework/Versions/3.11/bin/python3.11 -m build --no-isolation --config-setting build-option=--pure --wheel --outdir /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_python_py-dulwich/py311-dulwich/work 
Exit code: 1

@eli-schwartz
Copy link
Contributor

In general, passing options on the command line to setuptools is "hard" unless you avoid pep 517 and invoke python setup.py build && python setup.py install yourself. I used the environment variable for my own testing.

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 a pull request may close this issue.

4 participants