Skip to content

Commit

Permalink
Updates build & publish dependencies, adds Win ARM64 as build target,…
Browse files Browse the repository at this point in the history
… adds support for Python 3.10, makes Python source package work for all supported platforms
  • Loading branch information
bvobart committed Jun 20, 2022
1 parent f4f0def commit 10e79de
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 27 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
- "v*"

jobs:

build_golang:
name: Build and test mllint's Golang source code
runs-on: ubuntu-latest
Expand Down Expand Up @@ -40,7 +39,7 @@ jobs:
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build mllint & release to GitHub
uses: goreleaser/goreleaser-action@v2
uses: goreleaser/goreleaser-action@v3
with:
version: latest
args: release --rm-dist
Expand Down Expand Up @@ -71,7 +70,7 @@ jobs:
- uses: actions/checkout@v2

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==1.10.0
run: python -m pip install cibuildwheel==2.7.0

- name: Set MLLINT_VERSION
shell: bash
Expand Down
25 changes: 17 additions & 8 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ builds:
- windows
- darwin
ldflags:
- -s -w -X github.com/bvobart/mllint/commands.version={{.Version}} -X github.com/bvobart/mllint/commands.commit={{.Commit}} -X github.com/bvobart/mllint/commands.date={{.CommitDate}}
mod_timestamp: '{{ .CommitTimestamp }}'
- -s -w -X github.com/bvobart/mllint/commands.version={{.Version}} -X github.com/bvobart/mllint/commands.commit={{.Commit}} -X github.com/bvobart/mllint/commands.date={{.CommitDate}}
mod_timestamp: "{{ .CommitTimestamp }}"

# Build Docker containers of `mllint` for Python versions [3.6, 3.7, 3.8, 3.9]
# Build Docker containers of `mllint` for Python versions [3.6, 3.7, 3.8, 3.9, 3.10]
dockers:
- image_templates:
- bvobart/mllint:latest-py3.6
Expand Down Expand Up @@ -45,8 +45,6 @@ dockers:
use: buildx

- image_templates:
- bvobart/mllint:latest
- bvobart/mllint:{{.Version}}
- bvobart/mllint:latest-py3.9
- bvobart/mllint:{{.Version}}-py3.9
build_flag_templates:
Expand All @@ -55,14 +53,25 @@ dockers:
- build/requirements-tools.txt
use: buildx

- image_templates:
- bvobart/mllint:latest
- bvobart/mllint:{{.Version}}
- bvobart/mllint:latest-py3.10
- bvobart/mllint:{{.Version}}-py3.10
build_flag_templates:
- --build-arg=python_version=3.10
extra_files:
- build/requirements-tools.txt
use: buildx

archives:
- format: tar.gz
format_overrides:
- goos: windows
format: zip
- goos: windows
format: zip

checksum:
name_template: 'checksums.txt'
name_template: "checksums.txt"

changelog:
filters:
Expand Down
45 changes: 29 additions & 16 deletions build/setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import os
import platform
import shutil
from sys import argv

import setuptools

# If we're building a source package, then we need to include all mllint exes instead of just the one for this platform.
is_sdist = len(argv) > 1 and argv[1] == 'sdist'

version = os.getenv("MLLINT_VERSION", "dev-snapshot")
print(f'> Building mllint version {version}')
print(f'> Building mllint version {version} (as source package: {is_sdist})')

#-------------------------------------------------------------------------------

Expand All @@ -21,11 +25,14 @@ def get_mllint_exe() -> str:
return os.path.join('bin', 'mllint_windows_386', 'mllint.exe')
# Windows 64-bit x86
if system == 'Windows' and machine == 'AMD64':
return os.path.join('bin', 'mllint_windows_amd64', 'mllint.exe')
return os.path.join('bin', 'mllint_windows_amd64_v1', 'mllint.exe')
# Windows 64-bit ARM
if system == 'Windows' and machine == 'ARM64':
return os.path.join('bin', 'mllint_windows_arm64', 'mllint.exe')

# MacOS 64-bit x86
if system == 'Darwin' and machine == 'x86_64':
return os.path.join('bin', 'mllint_darwin_amd64', 'mllint')
return os.path.join('bin', 'mllint_darwin_amd64_v1', 'mllint')
# MacOS 64-bit ARM (aka Apple M1)
if system == 'Darwin' and machine == 'arm64':
return os.path.join('bin', 'mllint_darwin_arm64', 'mllint')
Expand All @@ -35,7 +42,7 @@ def get_mllint_exe() -> str:
return os.path.join('bin', 'mllint_linux_386', 'mllint')
# Linux 64-bit x86
if system == 'Linux' and machine == 'x86_64':
return os.path.join('bin', 'mllint_linux_amd64', 'mllint')
return os.path.join('bin', 'mllint_linux_amd64_v1', 'mllint')
# Linux 64-bit ARM
if system == 'Linux' and machine == 'arm64':
return os.path.join('bin', 'mllint_linux_arm64', 'mllint')
Expand All @@ -44,7 +51,7 @@ def get_mllint_exe() -> str:
print()
print('Sorry, your OS is not supported. mllint currently supports:')
print('- Linux (32 or 64-bit x86, or ARM64)')
print('- Windows (32 or 64-bit x86)')
print('- Windows (32 or 64-bit x86, or ARM64)')
print('- MacOS (64-bit x86, or ARM64 (Apple M1))')
print()
print(f'Your OS: {system} ({machine})')
Expand Down Expand Up @@ -100,15 +107,14 @@ def has_ext_modules(self):

# Copy mllint-exe into the package.
exe_path = get_mllint_exe()
if not os.path.exists(exe_path):
print()
print(f'Expected to find a compiled mllint binary at {exe_path} but it did not exist!')
print("> If you're manually compiling mllint from source, run 'build.sh' before running 'test.package.sh'")
print("> If you're installing mllint using 'pip install', then it seems pip downloaded the source package, instead of a platform-specific wheel.")
print()
raise Exception(f'Expected to find a compiled mllint binary at {exe_path} but it did not exist!')

shutil.copy2(exe_path, os.path.join('mllint', 'mllint-exe'))
if not is_sdist:
if os.path.exists(exe_path):
shutil.copy2(exe_path, os.path.join('mllint', 'mllint-exe'))
else:
print()
print(f'Expected to find a compiled mllint binary at {exe_path} but it did not exist!')
print()
raise Exception(f'Expected to find a compiled mllint binary at {exe_path} but it did not exist!')

# Include ReadMe as long description
with open("ReadMe.md", "r", encoding="utf-8") as fh:
Expand All @@ -117,12 +123,19 @@ def has_ext_modules(self):
with open("requirements-tools.txt", "r", encoding="utf-8") as fh:
tools_require = fh.read().splitlines()

# Include ReadMe.md in package_data, along with all or a specific mllint executable.
package_data = ['../ReadMe.md', '../requirements-tools.txt']
if is_sdist:
package_data.append('../bin/**/*')
else:
package_data.append('mllint-exe')

setuptools.setup(
name="mllint",
version=version,
author="Bart van Oort",
author_email="[email protected]",
description="Linter for Machine Learning projects",
description="Software Quality Linter for Machine Learning projects",
license='GPLv3',
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down Expand Up @@ -156,7 +169,7 @@ def has_ext_modules(self):
"Topic :: Software Development :: Version Control :: Git",
],
packages=['mllint'],
package_data={'mllint': ['mllint-exe']},
package_data={'mllint': package_data},
python_requires=">=3.6",
extras_require={'tools': tools_require},
entry_points={
Expand Down

0 comments on commit 10e79de

Please sign in to comment.