Skip to content

Conversation

@thillux
Copy link
Contributor

@thillux thillux commented Aug 5, 2025

Closes #5038.

@thillux
Copy link
Contributor Author

thillux commented Aug 5, 2025

@arckoor

@thillux thillux force-pushed the mtheil/python-definitions branch 2 times, most recently from e4f0b30 to e7433da Compare August 5, 2025 10:35
@randombit
Copy link
Owner

So I'm open to this in general but I'm confused about how this, as it stands, would be used in practice. It seems like the pyproject.toml is not being installed anywhere, so how is the user expected to get it?

Also while I'm not sure where pyproject.toml should go, it should definitely not be in the top level directory.

@thillux
Copy link
Contributor Author

thillux commented Aug 5, 2025

I see multiple options here:

  1. This can probably be used to publish botan3 to PyPI IMHO. But this should be at your discretion. People already started to provide wrappers for botan there, as they can't find it. https://pypi.org/project/slh-dsa-botan3/
  2. I'll use this to add botan3 as python package to nixpkgs (current draft without open PR here: thillux/nixpkgs@135929c).

Regarding the position of the file in the repository: just tell me your preference, no fixed opinion on my side.

@thillux
Copy link
Contributor Author

thillux commented Aug 5, 2025

I'll test moving this file to src/python.

@thillux
Copy link
Contributor Author

thillux commented Aug 5, 2025

Moving pyproject.tomlto another path (src/python) does not work, as long as files above this path shall be referenced. In this case readme.rst and license.txt where not accessible.

        File "/tmp/nix-shell-26044-0/nix-shell-26201-0/pip-build-env-kmzfd5o0/overlay/lib/python3.13/site-packages/setuptools/config/expand.py", line 129, in <genexpr>
          if _assert_local(path, root_dir)
             ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
        File "/tmp/nix-shell-26044-0/nix-shell-26201-0/pip-build-env-kmzfd5o0/overlay/lib/python3.13/site-packages/setuptools/config/expand.py", line 149, in _assert_local
          raise DistutilsOptionError(msg)
      distutils.errors.DistutilsOptionError: Cannot access '/home/mtheil/Code/botan/src/python/../../readme.rst' (or anything outside '/home/mtheil/Code/botan/src/python')
      [end of output]

If these lines are removed, moving the file is possible.

$ pip wheel src/python --no-deps
Processing ./src/python
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: botan3
  Building wheel for botan3 (pyproject.toml) ... done
  Created wheel for botan3: filename=botan3-3.8.2.dev330+ge7433da4f.d19800101-py3-none-any.whl size=17415 sha256=e87f8d9759a026fb20abf4fc79c54497e8ad92e745557584bb8b6d9fc613057e
  Stored in directory: /tmp/nix-shell-26044-0/nix-shell-26201-0/pip-ephem-wheel-cache-t666_cmq/wheels/9d/76/33/70c4063eda8a042c9aa14ab1470b961a913b789ffc085ea1c5
Successfully built botan3

@coveralls
Copy link

coveralls commented Aug 5, 2025

Coverage Status

coverage: 90.676% (-0.004%) from 90.68%
when pulling a091aaa on thillux:mtheil/python-definitions
into feb9b3f on randombit:master.

This can be used to publish botan python bindings
to PyPI.

Signed-off-by: Markus Theil <[email protected]>
@thillux thillux force-pushed the mtheil/python-definitions branch from e7433da to 26a415c Compare August 5, 2025 12:20
@thillux
Copy link
Contributor Author

thillux commented Aug 5, 2025

@randombit moved to src/python and removed non-accessible references.

thillux added 2 commits August 5, 2025 14:32
- Only run on Linux, as pip is already pre-installed there
- Use clean venv and install botan to it from pyproject.toml
- Run small smoke test: check version, check hash

Signed-off-by: Markus Theil <[email protected]>
@thillux thillux force-pushed the mtheil/python-definitions branch from 26a415c to a091aaa Compare August 5, 2025 12:32
@acid-bong
Copy link

Implements #5038.

To make the issue close on merge, change the wording to fixes ### or closes ###

thillux added a commit to thillux/nixpkgs that referenced this pull request Aug 6, 2025
This adds a python package definition for botan 3.9.0.
The pyproject.toml can be removed later, as upstream support
is pending, see: randombit/botan#5040.

Co-authored-by: Acid Bong <[email protected]>
Signed-off-by: Markus Theil <[email protected]>
@arckoor
Copy link
Contributor

arckoor commented Aug 11, 2025

I would be in favor of placing the pyproject.toml in the top level. All the python scripts are to my knowledge completely hand-formatted, which makes them a bit of a mess. Placing the toml in the top level would allow configuring tools like black there.
I'm very fond of black as a formatter, it does default to a max line length of 88 though, which for me is a little short.
So with the toml one could do

[tool.black]
line-length = 120

MultisampledNight pushed a commit to MultisampledNight/nixpkgs that referenced this pull request Aug 20, 2025
This adds a python package definition for botan 3.9.0.
The pyproject.toml can be removed later, as upstream support
is pending, see: randombit/botan#5040.

Co-authored-by: Acid Bong <[email protected]>
Signed-off-by: Markus Theil <[email protected]>
@arckoor arckoor mentioned this pull request Sep 3, 2025
@reneme
Copy link
Collaborator

reneme commented Sep 3, 2025

@thillux @arckoor Do you think it would make sense to vendor a prebuilt botan3.so (and likewise for other platforms) within the python package? In the hope that pip install botan3 just sets everything up properly. Or is such a thing generally a bad idea?

If I understand the situation correctly, on Ubuntu I would otherwise have to pip install botan3 and also apt install botan. Only to realize that Ubuntu would likely ship a too-old version of the shared object.

@arckoor
Copy link
Contributor

arckoor commented Sep 5, 2025

For distribution via pip I think it would definitely make sense, but should somehow be optional? I.e. I consume basically all my python packages through nixpkgs, and there a prebuilt .so just won't work iiuc, so what's done there is the underlying botan derivation is built and that is passed to botan3.py. (Don't quote me on that, I've only consumed nixpkgs so far, I'm not that privy to its inner workings :p)

The lupa package has a similar usecase, and they include a prebuilt version in their wheel, so I think something like that would be the way to go here too?

@bkmgit
Copy link
Contributor

bkmgit commented Sep 19, 2025

A PyPI package is helpful. For distributions, being able to use the system provided botan shared library instead of creating another copy is better.

@thillux
Copy link
Contributor Author

thillux commented Sep 25, 2025

@reneme No hard opinion on the inclusion of botan as shared object. IMHO I'd prefer to get that from my Linux distribution outside of the pip package.

@bkmgit
Copy link
Contributor

bkmgit commented Nov 3, 2025

This is really helpful. Makes packaging for Fedora much better:
https://copr.fedorainfracloud.org/coprs/build/9760605

Have the pyproject.toml file at the top level is nice, but it is possible
to have configure.py
move files around and control creating a python wheel.

Rebased on current head of repository:
https://github.com/bkmgit/botan/tree/python-pyproject

Happy to add tooling to be able to publish to PyPI and produce wheels.

@bkmgit
Copy link
Contributor

bkmgit commented Nov 3, 2025

This would help resolve #5103

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.

Packaging botan3.py with pyproject.toml

7 participants