pypa / build

A simple, correct Python build frontend
https://build.pypa.io
MIT License
738 stars 121 forks source link

How to select compiler in build options? #533

Open eabase opened 1 year ago

eabase commented 1 year ago

I'm trying to convert the following into something that is compatible with python -m build ...format.

Following #202, and #517, I tried this:

# Convert any of these: 
python setup.py --no-user-cfg --verbose build --compiler=mingw32 --force   # with = 

# into this:
python -m build -n -w -C="--global-option=--no-user-cfg" -C="--global-option=--verbose" -C="--build-option=--compiler=mingw32" -C="--build-option=--force"

This fails with:

* Getting build dependencies for wheel...
C:\Python310\lib\site-packages\setuptools\config\pyprojecttoml.py:108: _BetaConfiguration: Support for `[tool.setuptools]` in `pyproject.toml` is still *beta*.
  warnings.warn(msg, _BetaConfiguration)
running egg_info
writing src\black_scholes.egg-info\PKG-INFO
writing dependency_links to src\black_scholes.egg-info\dependency_links.txt
writing top-level names to src\black_scholes.egg-info\top_level.txt
reading manifest file 'src\black_scholes.egg-info\SOURCES.txt'
adding license file 'LICENSE.md'
writing manifest file 'src\black_scholes.egg-info\SOURCES.txt'
* Building wheel...
C:\Python310\lib\site-packages\setuptools\config\pyprojecttoml.py:108: _BetaConfiguration: Support for `[tool.setuptools]` in `pyproject.toml` is still *beta*.
  warnings.warn(msg, _BetaConfiguration)
usage: _in_process.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: _in_process.py --help [cmd1 cmd2 ...]
   or: _in_process.py --help-commands
   or: _in_process.py cmd --help

error: option --compiler not recognized

ERROR Backend subprocess exited when trying to invoke build_wheel

I also tried without the =, that also works with setup.py.

python setup.py --no-user-cfg --verbose build --compiler mingw32 --force  # without =

But also failed.

Finally tried this: python -m build -n -w -C="--no-user-cfg" -C="--verbose" -C="--compiler=mingw32" -C="--force"

But that completely ignored the mingw32 compiler.

dlaugt commented 1 year ago

I've asked me the same question on how to pass --debug option to the backend build command to be able to compile in debug.

The following translation is working for me: python_d setup.py bdist_wheel build --debug into: python_d -m build --wheel --no-isolation -C--build-option="build --debug"

Perhaps, you can try the following: python -m build -C--global-option=--no-user-cfg -C--global-option=--verbose -C--build-option="build --compiler=mingw32 --force"

eabase commented 1 year ago

After a discussion here:

The best solution was to just copy (the now ignored) distutils.cfg into your projects folder and name it setup.cfg instead. (There is also another env variable solution, that I haven't tried yet.)

So no more dumb and contorted CLI option-option-options... 👍