chalk-diagrams / planar

Other
2 stars 0 forks source link

Use setuptools and push a release to PyPI #1

Closed pawamoy closed 4 months ago

pawamoy commented 4 months ago

I'm trying to install chalk-diagrams with uv, but it fails with this error:

error: Failed to download and build `planar==0.4`
  Caused by: Failed to build: `planar==0.4`
  Caused by: Build backend failed to determine extra requires with `build_wheel()` with exit status: 1
--- stdout:

--- stderr:
Traceback (most recent call last):
  File "<string>", line 11, in <module>
ImportError: cannot import name 'build_py_2to3' from 'distutils.command.build_py' (/media/data/.cache/uv/.tmpPGVy0E/.venv/lib/python3.11/site-packages/setuptools/_distutils/command/build_py.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 14, in <module>
  File "/media/data/.cache/uv/.tmpPGVy0E/.venv/lib/python3.11/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
    return self._get_build_requires(config_settings, requirements=['wheel'])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/media/data/.cache/uv/.tmpPGVy0E/.venv/lib/python3.11/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
    self.run_setup()
  File "/media/data/.cache/uv/.tmpPGVy0E/.venv/lib/python3.11/site-packages/setuptools/build_meta.py", line 487, in run_setup
    super().run_setup(setup_script=setup_script)
  File "/media/data/.cache/uv/.tmpPGVy0E/.venv/lib/python3.11/site-packages/setuptools/build_meta.py", line 311, in run_setup
    exec(code, locals())
  File "<string>", line 14, in <module>
ImportError: build_py_2to3 not found in distutils - it is required for Python 3.x

Looking at setup.py here, I see that it uses distutils, which IIUC is deprecated. The setup imports Extension, but doesn't use it. I don't see any C code in the sources, so I believe you could switch to from setuptools import setup.

Then if you push a release to PyPI.org you won't have to depend on planar using git+https://github.com/chalk-diagrams/planar in chalk-diagrams, which requires cloning and building from sources every time.

Happy to send a PR!

danoneata commented 4 months ago

Thanks for the report @pawamoy !

The issue was that the PyPi version of chalk depended on the original planar libary and not on this fork. I've now added the correct dependency in chalk's setup.py and I've also followed your advice and added the planar fork to PyPi. So

uv pip install chalk-diagrams

should work now.

pawamoy commented 4 months ago

Amazing, thank you so much @danoneata! I tried and it works perfectly, thanks!