* Python: Deploy Windows wheels

* Just hardcode all the tags -- Windows uses a different matching algorithm

* Run Windows wheel publishing only on releases

* Add CHANGELOG

* Fix Ruby config
This commit is contained in:
Michael Droettboom 2020-01-09 22:13:13 +05:30 коммит произвёл GitHub
Родитель e50b4bb80f
Коммит 1191831bcb
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 63 добавлений и 18 удалений

Просмотреть файл

@ -778,6 +778,43 @@ jobs:
# variables are configured in CircleCI's environment variables.
.venv/bin/python3 -m twine upload dist/*
pypi-windows-release:
docker:
- image: circleci/python:3.7.6
steps:
- install-rustup
- setup-rust-toolchain
- run:
name: Setup mingw toolchain
command: |
# Install mingw target for rust
rustup target install x86_64-pc-windows-gnu
# Install mingw Debian packages
sudo apt install mingw-w64
# Set the linker to use for Rust/mingw
echo '[target.x86_64-pc-windows-gnu]' >> ~/.cargo/config
echo 'linker = "/usr/bin/x86_64-w64-mingw32-gcc"' >> ~/.cargo/config
# Copy a working crt2.o from Debian to the Rust toolchain
cp /usr/x86_64-w64-mingw32/lib/crt2.o ~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/
cp /usr/x86_64-w64-mingw32/lib/dllcrt2.o ~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/
- checkout
- run:
name: Install Python development tools for host
command:
make python-setup
- run:
name: Build Windows glean_ffi.dll
command:
cargo build --target x86_64-pc-windows-gnu
- run:
name: Build Windows wheel
command: |
cd glean-core/python
GLEAN_PYTHON_MINGW_BUILD=1 .venv/bin/python3 setup.py bdist_wheel
# Requires that the TWINE_USERNAME and TWINE_PASSWORD environment
# variables are configured in CircleCI's environment variables.
.venv/bin/python3 -m twine upload dist/*
workflows:
version: 2
check-formating:
@ -852,6 +889,10 @@ workflows:
requires:
- Python 3_7 tests
filters: *release-filters
- pypi-windows-release:
requires:
- Python 3_7 tests
filters: *release-filters
- iOS build and test:
filters: *release-filters
- Carthage release:

Просмотреть файл

@ -13,7 +13,8 @@
* The code for migrating data from Glean SDK before version 19 was removed.
* Python:
* The Python bindings now support Python 3.5 - 3.7.
* The Python bindings are now distributed as a wheel on both Linux and macOS.
* The Python bindings are now distributed as a wheel on Linux, macOS and
Windows.
# v23.0.1 (2020-01-08)

Просмотреть файл

@ -13,6 +13,11 @@ from setuptools.command.install import install
import wheel.bdist_wheel
platform = sys.platform
if os.environ.get("GLEAN_PYTHON_MINGW_BUILD") or platform.startswith("win"):
platform = "windows"
if sys.version_info < (3, 5):
print("glean requires at least Python 3.5", file=sys.stderr)
sys.exit(1)
@ -38,11 +43,16 @@ requirements = ["cffi==1.13.1", "glean_parser==1.15.5", "inflection==0.3.1"]
setup_requirements = []
if sys.platform == "linux":
shared_object_build_dir = "../../target/debug/"
if os.environ.get("GLEAN_PYTHON_MINGW_BUILD"):
shared_object_build_dir = "../../target/x86_64-pc-windows-gnu/debug/"
if platform == "linux":
shared_object = "libglean_ffi.so"
elif sys.platform == "darwin":
elif platform == "darwin":
shared_object = "libglean_ffi.dylib"
elif sys.platform.startswith("win"):
elif platform == "windows":
shared_object = "glean_ffi.dll"
else:
raise ValueError("The platform {} is not supported.".format(sys.platform))
@ -51,7 +61,7 @@ else:
shutil.copyfile("../ffi/glean.h", "glean/glean.h")
shutil.copyfile("../metrics.yaml", "glean/metrics.yaml")
shutil.copyfile("../pings.yaml", "glean/pings.yaml")
shutil.copyfile("../../target/debug/" + shared_object, "glean/" + shared_object)
shutil.copyfile(shared_object_build_dir + shared_object, "glean/" + shared_object)
class BinaryDistribution(Distribution):
@ -70,19 +80,12 @@ class BinaryDistribution(Distribution):
# simple that only handles the cases we need.
class bdist_wheel(wheel.bdist_wheel.bdist_wheel):
def get_tag(self):
if sys.platform == "linux":
plat_name = "linux1_x86_64"
elif sys.platform == "darwin":
plat_name = "macosx_10_7_x86_64"
# This should be the minimum Python version supported
impl = "cp35"
# Since we don't actually compile against libpython.so, but use cffi,
# just specify that anything with the stable Python 3.x ABI will work.
abi_tag = "abi3"
return (impl, abi_tag, plat_name)
if platform == "linux":
return ("cp35", "abi3", "linux_x86_64")
elif platform == "darwin":
return ("cp35", "abi3", "macosx_10_7_x86_64")
elif platform == "windows":
return ("py3", "none", "win_amd64")
class InstallPlatlib(install):