Set CIBUILDWHEEL environment variable to 1 during build
This commit is contained in:
@@ -31,6 +31,17 @@ Usage
|
|||||||
|
|
||||||
`cibuildwheel` is not intended to run on your development machine. It will try to install packages globally; this is no good. Travis CI and Appveyor run their builds in isolated environments, so are ideal for this kind of script.
|
`cibuildwheel` is not intended to run on your development machine. It will try to install packages globally; this is no good. Travis CI and Appveyor run their builds in isolated environments, so are ideal for this kind of script.
|
||||||
|
|
||||||
|
`cibuildwheel` defines the environment variable `CIBUILDWHEEL` to the value `1` allowing projects for which the C extension is optional to make it mandatory when building wheels.
|
||||||
|
An easy way to do it in Python 3 is through the `optional` named argument of `Extension` constructor in your `setup.py`:
|
||||||
|
```python
|
||||||
|
myextension = Extension(
|
||||||
|
"myextension",
|
||||||
|
["myextension.c"],
|
||||||
|
optional=os.environ.get('CIBUILDWHEEL', '0') != '1',
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### Minimal setup
|
### Minimal setup
|
||||||
|
|
||||||
- Create a `.travis.yml` file in your repo.
|
- Create a `.travis.yml` file in your repo.
|
||||||
|
|||||||
@@ -75,6 +75,10 @@ def main():
|
|||||||
|
|
||||||
skip = BuildSkipper(skip_config)
|
skip = BuildSkipper(skip_config)
|
||||||
|
|
||||||
|
# Add CIBUILDWHEEL environment variable
|
||||||
|
# This needs to be passed on to the docker container in linux.py
|
||||||
|
os.environ['CIBUILDWHEEL'] = '1'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
project_setup_py = os.path.join(project_dir, 'setup.py')
|
project_setup_py = os.path.join(project_dir, 'setup.py')
|
||||||
name_output = subprocess.check_output([sys.executable, project_setup_py, '--name'],
|
name_output = subprocess.check_output([sys.executable, project_setup_py, '--name'],
|
||||||
|
|||||||
@@ -111,6 +111,8 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be
|
|||||||
docker_process = subprocess.Popen([
|
docker_process = subprocess.Popen([
|
||||||
'docker',
|
'docker',
|
||||||
'run',
|
'run',
|
||||||
|
'--env',
|
||||||
|
'CIBUILDWHEEL',
|
||||||
'--rm',
|
'--rm',
|
||||||
'-i',
|
'-i',
|
||||||
'-v', '%s:/project' % os.path.abspath(project_dir),
|
'-v', '%s:/project' % os.path.abspath(project_dir),
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
from setuptools import setup, Extension
|
from setuptools import setup, Extension
|
||||||
|
|
||||||
|
if os.environ.get('CIBUILDWHEEL', '0') != '1':
|
||||||
|
raise Exception('CIBUILDWHEEL environment variable is not set to 1')
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="spam",
|
name="spam",
|
||||||
ext_modules=[Extension('spam', sources=['spam.c'])],
|
ext_modules=[Extension('spam', sources=['spam.c'])],
|
||||||
|
|||||||
Reference in New Issue
Block a user