Skip to content

Add ability to skip compilation using PEP517 config settings#9

Merged
SomberNight merged 1 commit intospesmilo:masterfrom
bitcart:add-skip-build-param
Jul 11, 2025
Merged

Add ability to skip compilation using PEP517 config settings#9
SomberNight merged 1 commit intospesmilo:masterfrom
bitcart:add-skip-build-param

Conversation

@MrNaif2018
Copy link
Copy Markdown
Contributor

@MrNaif2018 MrNaif2018 commented Jul 11, 2025

Using env vars usually works fine, but when including electrum (so it pulls electrum-ecc) as a dependency, because on PyPI wheels aren't uploaded, it is not convenient to ask users to set this env var each time they install the project
This allows to install the package via pip install electrum-ecc -C electrum_ecc.dont_compile=true
Or in my case when I am using uv, I can just write in pyproject.toml:

[tool.uv]
config-settings = { "electrum_ecc.dont_compile" = "true" }

P.S. While I understand why this package may have wheels not uploaded, why does electrum-aionostr have no uploaded wheels if they should be universal like py3-any?

@SomberNight
Copy link
Copy Markdown
Member

I was just wondering -- how is the libsecp .so/.dll installed/found in your use case? Do you ask users to apt install it?

P.S. While I understand why this package may have wheels not uploaded, why does electrum-aionostr have no uploaded wheels if they should be universal like py3-any?

What's the upside of also distributing a wheel for it? The downside is that it's one more package to cross-check hashes for, that could be used to hide a backdoor in.

@MrNaif2018
Copy link
Copy Markdown
Contributor Author

MrNaif2018 commented Jul 11, 2025

Yes, we ask users to install via apt or whatever is the preferred method for their system (e.g. see here)
Otherwise we would need to provide even more instructions on installing compilers/etc for each platform
Or for example in CI it makes no sense to install build tools each time when we can just use the one installed via apt

As for the upside of distributing wheel, faster build times
If people don't want to use a wheel there is a flag for that, --no-binary I think
As for one more package to check hashes sure, but usually pip can do it automatically for example
Like if we do check hashes for .tar.gz, checking for .whl is just another filename+hash
And because it's universal wheel, no need to upload one for each platform

But don't merge this yet, I am having troubles passing this in my app, working on a workaround...

@MrNaif2018
Copy link
Copy Markdown
Contributor Author

Okay, it finally worked
Why a whole custom build backend is needed: pypa/setuptools#2491
This seems like the easiest solution, as it was done in pillow: python-pillow/Pillow#7171
Basically, we should be able to use --config-settings from https://peps.python.org/pep-0517/#config-settings directly
but setuptools is setuptools, so it doesn't pass it
In the first version of this PR I used to work around it via using their build-options, but then if this is passed to any other package, build will fail with error
invalid command name 'electrum_ecc.dont_compile'
(I hit it while building electrum-aionostr, that's why I added the question)
So this new approach is better because setuptools simply ignores those options, or more like, it parses them but doesn't pass to us
So using build backend we can actually access it
And in the pyproject.toml we can now just write this:

https://github.com/bitcart/bitcart/blob/8a84cee8f3f2e01c728e83686f42cc3a0ec012a0/pyproject.toml#L121

P.S. As another thing I noticed for both electrum-ecc and electrum-aionostr, setuptools is complaining

View warning log
DEBUG /Users/alex/.cache/uv/builds-v0/.tmpTlO040/lib/python3.11/site-packages/setuptools/config/_apply_pyprojecttoml.py:82: SetuptoolsDeprecationWarning: `project.license` as a TOML table is deprecated
DEBUG !!
DEBUG 
DEBUG         ********************************************************************************
DEBUG         Please use a simple string containing a SPDX expression for `project.license`. You can also use `project.license-files`. (Both options available on setuptools>=77.0.0).
DEBUG 
DEBUG         By 2026-Feb-18, you need to update your project and remove deprecated calls
DEBUG         or your builds will no longer be supported.
DEBUG 
DEBUG         See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details.
DEBUG         ********************************************************************************
DEBUG 
DEBUG !!
DEBUG   corresp(dist, value, root_dir)
DEBUG /Users/alex/.cache/uv/builds-v0/.tmpTlO040/lib/python3.11/site-packages/setuptools/config/_apply_pyprojecttoml.py:61: SetuptoolsDeprecationWarning: License classifiers are deprecated.
DEBUG !!
DEBUG 
DEBUG         ********************************************************************************
DEBUG         Please consider removing the following classifiers in favor of a SPDX license expression:
DEBUG 
DEBUG         License :: OSI Approved :: MIT License
DEBUG 
DEBUG         See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details.
DEBUG         ********************************************************************************
DEBUG 
DEBUG !!
DEBUG   dist._finalize_license_expression()
DEBUG /Users/alex/.cache/uv/builds-v0/.tmpTlO040/lib/python3.11/site-packages/setuptools/dist.py:759: SetuptoolsDeprecationWarning: License classifiers are deprecated.
DEBUG !!
DEBUG 
DEBUG         ********************************************************************************
DEBUG         Please consider removing the following classifiers in favor of a SPDX license expression:
DEBUG 
DEBUG         License :: OSI Approved :: MIT License
DEBUG 
DEBUG         See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details.
DEBUG         ********************************************************************************
DEBUG 
DEBUG !!
DEBUG   self._finalize_license_expression()

@MrNaif2018 MrNaif2018 requested a review from SomberNight July 11, 2025 13:05
@MrNaif2018 MrNaif2018 requested a review from SomberNight July 11, 2025 13:24
@MrNaif2018 MrNaif2018 requested a review from SomberNight July 11, 2025 14:11
@SomberNight
Copy link
Copy Markdown
Member

Ok. 2377ea2 looks good.
Could you please rebase and squash into a single commit?

@MrNaif2018 MrNaif2018 force-pushed the add-skip-build-param branch from 2377ea2 to b134e00 Compare July 11, 2025 15:44
@MrNaif2018
Copy link
Copy Markdown
Contributor Author

Rebased and squashed
(though there is a button in github for squash merge)

@SomberNight
Copy link
Copy Markdown
Member

(though there is a button in github for squash merge)

I saw you signed your git commits. I try not to invalidate commit signatures.

@SomberNight SomberNight merged commit 6a8489c into spesmilo:master Jul 11, 2025
5 checks passed
@SomberNight
Copy link
Copy Markdown
Member

Thanks.

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.

2 participants