Set CIBUILDWHEEL environment variable to 1 during build

This commit is contained in:
mayeut
2017-08-29 18:18:40 +02:00
parent 9faa8f8728
commit 0a7a1b8fb3
4 changed files with 22 additions and 0 deletions
+11
View File
@@ -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` 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
- Create a `.travis.yml` file in your repo.
+4
View File
@@ -75,6 +75,10 @@ def main():
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:
project_setup_py = os.path.join(project_dir, 'setup.py')
name_output = subprocess.check_output([sys.executable, project_setup_py, '--name'],
+2
View File
@@ -111,6 +111,8 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be
docker_process = subprocess.Popen([
'docker',
'run',
'--env',
'CIBUILDWHEEL',
'--rm',
'-i',
'-v', '%s:/project' % os.path.abspath(project_dir),
+5
View File
@@ -1,5 +1,10 @@
import os
from setuptools import setup, Extension
if os.environ.get('CIBUILDWHEEL', '0') != '1':
raise Exception('CIBUILDWHEEL environment variable is not set to 1')
setup(
name="spam",
ext_modules=[Extension('spam', sources=['spam.c'])],