From 90b650748a7bb5c8d4306c38d04a9485f094cba4 Mon Sep 17 00:00:00 2001 From: Corran Webster Date: Tue, 18 Apr 2023 13:01:54 +0100 Subject: [PATCH 1/6] Add an action that builds wheels This will eventually be folded into the release action. --- .github/workflows/build-wheels.yml | 42 +++++++++ pyproject.toml | 7 ++ setup.py | 132 +++++++++++++++-------------- 3 files changed, 119 insertions(+), 62 deletions(-) create mode 100644 .github/workflows/build-wheels.yml diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml new file mode 100644 index 000000000..d6531a3e4 --- /dev/null +++ b/.github/workflows/build-wheels.yml @@ -0,0 +1,42 @@ + +# This workflow installs dependencies from main branch + +name: Build wheels + +on: + pull_request: + # Make it possible to manually trigger the workflow + workflow_dispatch: + +jobs: + test-ets: + strategy: + matrix: + os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] + + runs-on: ${{ matrix.os }} + steps: + - name: Check out the release commit + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: arm64 + if: runner.os == 'Linux' + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Build wheels + uses: pypa/cibuildwheel@v2.12.1 + + - name: Archive build + uses: actions/upload-artifact@v3 + with: + name: enable_wheels + path: wheelhouse + # don't need these kept for long + retention-days: 7 diff --git a/pyproject.toml b/pyproject.toml index 7e84b62f6..c478f8b47 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,10 @@ [build-system] requires = ["cython", "oldest-supported-numpy", "setuptools<65.2", "swig", "wheel"] build-backend = "setuptools.build_meta" + +[tool.cibuildwheel] +skip = 'pp* *-musllinux*' + +[tool.cibuildwheel.linux] +archs = ['auto', 'aarch64'] +before-all = "yum install -y mesa-libGL-devel" diff --git a/setup.py b/setup.py index de76a7fbe..2e479e9f5 100644 --- a/setup.py +++ b/setup.py @@ -453,45 +453,46 @@ def macos_extensions(): if sys.platform == 'darwin': ext_modules += macos_extensions() - setup(name='enable', - version=__version__, - author='Enthought, Inc', - author_email='info@enthought.com', - maintainer='ETS Developers', - maintainer_email='enthought-dev@enthought.com', - url='https://github.com/enthought/enable/', - # Note that this URL is only valid for tagged releases. - download_url=('https://github.com/enthought/enable/archive/' - '{0}.tar.gz'.format(__version__)), - license='BSD', - classifiers=[c.strip() for c in """\ - Development Status :: 5 - Production/Stable - Intended Audience :: Developers - Intended Audience :: Science/Research - License :: OSI Approved :: BSD License - Operating System :: MacOS - Operating System :: Microsoft :: Windows - Operating System :: OS Independent - Operating System :: POSIX - Operating System :: Unix - Programming Language :: C - Programming Language :: Python - Topic :: Scientific/Engineering - Topic :: Software Development - Topic :: Software Development :: Libraries - """.splitlines() if len(c.strip()) > 0], - platforms=['Windows', 'Linux', 'macOS', 'Unix', 'Solaris'], - description='low-level drawing and interaction', - long_description=long_description, - long_description_content_type="text/x-rst", - install_requires=__requires__, - extras_require=__extras_require__, - cmdclass={ - 'build': PatchedBuild, - 'install': PatchedInstall, - 'build_ext': build_ext, - }, - entry_points={ + setup( + name='enable', + version=__version__, + author='Enthought, Inc', + author_email='info@enthought.com', + maintainer='ETS Developers', + maintainer_email='enthought-dev@enthought.com', + url='https://github.com/enthought/enable/', + # Note that this URL is only valid for tagged releases. + download_url=('https://github.com/enthought/enable/archive/' + '{0}.tar.gz'.format(__version__)), + license='BSD', + classifiers=[c.strip() for c in """\ + Development Status :: 5 - Production/Stable + Intended Audience :: Developers + Intended Audience :: Science/Research + License :: OSI Approved :: BSD License + Operating System :: MacOS + Operating System :: Microsoft :: Windows + Operating System :: OS Independent + Operating System :: POSIX + Operating System :: Unix + Programming Language :: C + Programming Language :: Python + Topic :: Scientific/Engineering + Topic :: Software Development + Topic :: Software Development :: Libraries + """.splitlines() if len(c.strip()) > 0], + platforms=['Windows', 'Linux', 'macOS', 'Unix', 'Solaris'], + description='low-level drawing and interaction', + long_description=long_description, + long_description_content_type="text/x-rst", + install_requires=__requires__, + extras_require=__extras_require__, + cmdclass={ + 'build': PatchedBuild, + 'install': PatchedInstall, + 'build_ext': build_ext, + }, + entry_points={ 'enable.toolkits': [ 'null = enable.null.toolkit:toolkit', 'qt = enable.qt4.toolkit:toolkit', @@ -502,26 +503,33 @@ def macos_extensions(): 'enable_examples = enable.examples._etsdemo_info:info', 'kiva_examples = kiva.examples._etsdemo_info:info', ] - }, - ext_modules=ext_modules, - packages=find_packages(exclude=['ci', 'docs']), - package_data={ - '': ['*.zip', '*.svg', 'images/*'], - 'enable': ['tests/primitives/data/PngSuite/*.png'], - 'enable.examples': ['demo/*', - 'demo/*/*', - 'demo/*/*/*', - 'demo/*/*/*/*', - 'demo/*/*/*/*/*'], - 'enable.savage.trait_defs.ui.wx': ['data/*.svg'], - 'kiva': ['tests/agg/doubleprom_soho_full.jpg', - 'fonttools/data/*.ttf', - 'fonttools/tests/data/*.afm', - 'fonttools/tests/data/*.ttc', - 'fonttools/tests/data/*.ttf', - 'fonttools/tests/data/*.txt'], - 'kiva.examples': ['kiva/*', - 'kiva/*/*'], - }, - zip_safe=False, - ) + }, + ext_modules=ext_modules, + packages=find_packages(exclude=['ci', 'docs']), + package_data={ + '': ['*.zip', '*.svg', 'images/*'], + 'enable': ['tests/primitives/data/PngSuite/*.png'], + 'enable.examples': [ + 'demo/*', + 'demo/*/*', + 'demo/*/*/*', + 'demo/*/*/*/*', + 'demo/*/*/*/*/*', + ], + 'enable.savage.trait_defs.ui.wx': ['data/*.svg'], + 'kiva': [ + 'tests/agg/doubleprom_soho_full.jpg', + 'fonttools/data/*.ttf', + 'fonttools/tests/data/*.afm', + 'fonttools/tests/data/*.ttc', + 'fonttools/tests/data/*.ttf', + 'fonttools/tests/data/*.txt', + ], + 'kiva.examples': [ + 'kiva/*', + 'kiva/*/*', + ], + }, + zip_safe=False, + python_requires=">=3.7", + ) From f20da089acda481957178ebd95b258fa13cd8782 Mon Sep 17 00:00:00 2001 From: Corran Webster Date: Tue, 18 Apr 2023 13:23:00 +0100 Subject: [PATCH 2/6] Don't build Python 3.6 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c478f8b47..68a9afa09 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["cython", "oldest-supported-numpy", "setuptools<65.2", "swig", "whee build-backend = "setuptools.build_meta" [tool.cibuildwheel] -skip = 'pp* *-musllinux*' +skip = 'pp* *-musllinux* cp36-*' [tool.cibuildwheel.linux] archs = ['auto', 'aarch64'] From 6d8f7635b7ff735b1b48abf1547e5f066f3c677e Mon Sep 17 00:00:00 2001 From: Corran Webster Date: Tue, 18 Apr 2023 13:33:00 +0100 Subject: [PATCH 3/6] Don't build GL. --- setup.py | 144 +++++++++++++++++++++++++++---------------------------- 1 file changed, 72 insertions(+), 72 deletions(-) diff --git a/setup.py b/setup.py index 2e479e9f5..e99c34677 100644 --- a/setup.py +++ b/setup.py @@ -303,77 +303,77 @@ def base_extensions(): ] -def gl_extensions(): - kiva_gl_dir = os.path.join('kiva', 'gl') - agg_dir = os.path.join(kiva_gl_dir, 'src', 'agg') - - kiva_gl_libraries = [] - define_macros = [] - extra_compile_args = [] - extra_link_args = [] - include_dirs = [] - - if sys.platform == 'win32': - kiva_gl_libraries += ['opengl32', 'glu32'] - elif sys.platform == 'darwin': - # Options to make macOS link OpenGL - darwin_frameworks = ['ApplicationServices', 'OpenGL'] - for framework in darwin_frameworks: - extra_link_args.extend(['-framework', framework]) - - include_dirs += [ - '/System/Library/Frameworks/%s.framework/Versions/A/Headers' % x - for x in darwin_frameworks - ] - define_macros += [ - ('__DARWIN__', None), - # OpenGL is deprecated starting with macOS 10.14 and gone in 10.15 - # But that doesn't mean we want to hear about it. We know, Apple. - ('GL_SILENCE_DEPRECATION', None), - ] - extra_compile_args = [ - '-Wfatal-errors', - '-Wno-unused-function', - ] - else: - # This should work for most linux distributions - kiva_gl_libraries += ['GL', 'GLU'] - extra_compile_args = [ - '-Wfatal-errors', - '-Wno-unused-function', - ] - - kiva_gl_sources = [ - *glob.glob(os.path.join(kiva_gl_dir, 'src', 'kiva_gl_*.cpp')), - *glob.glob(os.path.join(agg_dir, '*.cpp')), - ] - include_dirs += [ - os.path.join(kiva_gl_dir, 'src'), - agg_dir, - numpy.get_include(), - ] - swig_opts = [ - '-I' + os.path.join(kiva_gl_dir, 'src', 'swig'), - '-I' + os.path.join(kiva_gl_dir, 'src'), - '-I' + agg_dir, - '-c++', - ] - - return [ - Extension( - 'kiva.gl._gl', - sources=[ - os.path.join(kiva_gl_dir, 'gl.i'), - ] + kiva_gl_sources, - swig_opts=swig_opts, - include_dirs=include_dirs, - extra_compile_args=extra_compile_args, - extra_link_args=extra_link_args, - define_macros=define_macros, - libraries=kiva_gl_libraries, - language='c++', - ), - ] +# def gl_extensions(): +# kiva_gl_dir = os.path.join('kiva', 'gl') +# agg_dir = os.path.join(kiva_gl_dir, 'src', 'agg') + +# kiva_gl_libraries = [] +# define_macros = [] +# extra_compile_args = [] +# extra_link_args = [] +# include_dirs = [] + +# if sys.platform == 'win32': +# kiva_gl_libraries += ['opengl32', 'glu32'] +# elif sys.platform == 'darwin': +# # Options to make macOS link OpenGL +# darwin_frameworks = ['ApplicationServices', 'OpenGL'] +# for framework in darwin_frameworks: +# extra_link_args.extend(['-framework', framework]) + +# include_dirs += [ +# '/System/Library/Frameworks/%s.framework/Versions/A/Headers' % x +# for x in darwin_frameworks +# ] +# define_macros += [ +# ('__DARWIN__', None), +# # OpenGL is deprecated starting with macOS 10.14 and gone in 10.15 +# # But that doesn't mean we want to hear about it. We know, Apple. +# ('GL_SILENCE_DEPRECATION', None), +# ] +# extra_compile_args = [ +# '-Wfatal-errors', +# '-Wno-unused-function', +# ] +# else: +# # This should work for most linux distributions +# kiva_gl_libraries += ['GL', 'GLU'] +# extra_compile_args = [ +# '-Wfatal-errors', +# '-Wno-unused-function', +# ] + +# kiva_gl_sources = [ +# *glob.glob(os.path.join(kiva_gl_dir, 'src', 'kiva_gl_*.cpp')), +# *glob.glob(os.path.join(agg_dir, '*.cpp')), +# ] +# include_dirs += [ +# os.path.join(kiva_gl_dir, 'src'), +# agg_dir, +# numpy.get_include(), +# ] +# swig_opts = [ +# '-I' + os.path.join(kiva_gl_dir, 'src', 'swig'), +# '-I' + os.path.join(kiva_gl_dir, 'src'), +# '-I' + agg_dir, +# '-c++', +# ] + +# return [ +# Extension( +# 'kiva.gl._gl', +# sources=[ +# os.path.join(kiva_gl_dir, 'gl.i'), +# ] + kiva_gl_sources, +# swig_opts=swig_opts, +# include_dirs=include_dirs, +# extra_compile_args=extra_compile_args, +# extra_link_args=extra_link_args, +# define_macros=define_macros, +# libraries=kiva_gl_libraries, +# language='c++', +# ), +# ] def macos_extensions(): @@ -449,7 +449,7 @@ def macos_extensions(): long_description = fp.read() # Collect extensions - ext_modules = base_extensions() + agg_extensions() + gl_extensions() + ext_modules = base_extensions() + agg_extensions() #+ gl_extensions() if sys.platform == 'darwin': ext_modules += macos_extensions() From 281c5b2a9c5408f309efe12a9e8ea6771abb2c0a Mon Sep 17 00:00:00 2001 From: Corran Webster Date: Thu, 20 Apr 2023 10:10:18 +0100 Subject: [PATCH 4/6] Add wheel building to publish workflow; update dependencies. --- .github/workflows/publish-on-pypi.yml | 43 ++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish-on-pypi.yml b/.github/workflows/publish-on-pypi.yml index 72ca43a89..dce289f06 100644 --- a/.github/workflows/publish-on-pypi.yml +++ b/.github/workflows/publish-on-pypi.yml @@ -6,17 +6,52 @@ on: types: [published] jobs: - build-and-upload: + build-wheels: + strategy: + matrix: + os: [windows-latest, macos-latest, ubuntu-latest] + + runs-on: ${{ matrix.os }} + + steps: + + - name: Check out the release commit + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: arm64 + if: runner.os == 'Linux' + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Build wheels + uses: pypa/cibuildwheel@v2.12.1 + + - name: Check and upload wheels + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python -m pip install twine + python -m twine check --strict wheelhouse/*.whl + python -m twine upload wheelhouse/*.whl + + build-sdist: runs-on: ubuntu-latest steps: - name: Check out the release commit - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: - python-version: '3.8' + python-version: '3.11' - name: Install Python packages needed for build and upload run: | From 080afba5cc81a8f37b92af99eb26a9704e23e9fd Mon Sep 17 00:00:00 2001 From: Corran Webster Date: Fri, 21 Apr 2023 09:53:50 +0100 Subject: [PATCH 5/6] Clean-up build wheel workflow: make it workflow dispatch only. --- .github/workflows/build-wheels.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index d6531a3e4..f01f33878 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -1,10 +1,6 @@ - -# This workflow installs dependencies from main branch - name: Build wheels on: - pull_request: # Make it possible to manually trigger the workflow workflow_dispatch: From 7732b7a17b77e21e82eb4086132e7f0363d515a6 Mon Sep 17 00:00:00 2001 From: Corran Webster Date: Fri, 21 Apr 2023 09:56:55 +0100 Subject: [PATCH 6/6] Fix wokflow name. --- .github/workflows/build-wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index f01f33878..74f773676 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -5,7 +5,7 @@ on: workflow_dispatch: jobs: - test-ets: + build-wheels: strategy: matrix: os: ['ubuntu-latest', 'macos-latest', 'windows-latest']