-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates build & publish dependencies, adds Win ARM64 as build target,…
… adds support for Python 3.10, makes Python source package work for all supported platforms
- Loading branch information
Showing
3 changed files
with
48 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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})') | ||
|
||
#------------------------------------------------------------------------------- | ||
|
||
|
@@ -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') | ||
|
@@ -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') | ||
|
@@ -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})') | ||
|
@@ -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: | ||
|
@@ -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", | ||
|
@@ -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={ | ||
|