Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

How can I pass arguments into setup.py? #1789

Closed
mcleantom opened this issue Mar 12, 2024 · 2 comments
Closed

How can I pass arguments into setup.py? #1789

mcleantom opened this issue Mar 12, 2024 · 2 comments

Comments

@mcleantom
Copy link

Description

A library I am trying to build wheels for, you need to pass in the boost root directory like so:

python3 setup.py build_ext --boost-root=/path/to/boost

I am adding boost by doing:

name: Upload test python package

on:
  push:
    branches:
      - master

env:
  CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8"

jobs:
  build_wheels:
    name: Build wheels on ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
       os: [ubuntu-20.04]
    steps:
      - name: Install boost
        if: ${{ runner.os == 'Windows' || runner.os == 'macOS' }}
        uses: MarkusJx/install-boost@v2.1.0
        id: install-boost
        with:
          boost_version: 1.79.0
          boost_install_dir: ${{ matrix.boost_install_dir }}
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v3
      - name: Install cibuildwheel
        run: python -m pip install cibuildwheel==2.14.1
      - name: Build wheels
        run: python -m cibuildwheel --output-dir wheelhouse
        env:
          CIBW_BEFORE_BUILD: python -m pip install cmake
          CIBW_BEFORE_BUILD_LINUX: echo $BOOST_ROOT
          COBW_BEFORE_ALL_LINUX: >
            yum install -y wget &&
            cd / && mkdir boost && cd boost &&
            wget --no-check-certificate 'https://sourceforge.net/projects/boost/files/boost/1.79.0/boost_1_79_0.tar.bz2' && 
            tar xf boost_1_79_0.tar.bz2 &&
            cd {package}
          CIBW_ENVIRONMENT_WINDOWS: BOOST_ROOT='${{ steps.install-boost.outputs.BOOST_ROOT }}'
          CIBW_ENVIRONMENT_MACOS: BOOST_ROOT='${{ steps.install-boost.outputs.BOOST_ROOT }}'
          CIBW_ENVRIONMENT_LINUX: PIP_GLOBAL_OPTION="--boost-root=/boost"
          CIBW_ENVIRONMENT_PASS_LINUX: BOOST_ROOT
      - uses: actions/upload-artifact@v3
        with:
          path: ./wheelhouse/*.whl

I think from the docs, this should pass in arguments:

CIBW_ENVRIONMENT_LINUX: PIP_GLOBAL_OPTION="--boost-root=/boost"

Is this correct? My version of cibuildwheel is not finding boost (or python, but that can be a separate issue)

        -- Could NOT find Python3 (missing: Python3_LIBRARIES Development Development.Embed) (found version "3.8.17")
        CMake Error at /opt/_internal/pipx/venvs/cmake/lib/python3.10/site-packages/cmake/data/share/cmake-3.26/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
          Could NOT find Boost (missing: Boost_INCLUDE_DIR) (Required is at least
          version "1.79")

Any help would be appreciated, thanks.

For reference, my repo is https://github.com/mcleantom/pangeo-pyinterp

Build log

https://github.com/mcleantom/pangeo-pyinterp/actions/runs/8254883117/job/22580063074

CI config

https://github.com/mcleantom/pangeo-pyinterp/blob/master/.github/workflows/pypipublishtest.yaml

@joerick
Copy link
Contributor

joerick commented Mar 13, 2024

There is a more modern way is to pass these flags via 'config-settings'. Perhaps that will work better, these kinds of options have been in flux lately.

CIBW_CONFIG_SETTINGS_LINUX: "--global-option=--boost-root=/boost"
# or, the correct option might be...
CIBW_CONFIG_SETTINGS_LINUX: "--build-option=--boost-root=/boost"

@joerick
Copy link
Contributor

joerick commented Mar 13, 2024

For the syntax to use here, it's not documented by setuptools, but this might be a useful reference: pypa/build#328 (comment)

@pypa pypa locked and limited conversation to collaborators Jun 30, 2024
@mayeut mayeut converted this issue into discussion #1905 Jun 30, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants