Skip to content

Commit

Permalink
Build for release when assembling Python release
Browse files Browse the repository at this point in the history
  • Loading branch information
badboy committed Jun 23, 2020
1 parent 9b2db3e commit f2df415
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 9 deletions.
22 changes: 18 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,15 @@ commands:
- run:
name: Build Windows glean_ffi.dll
command:
cargo build --target x86_64-pc-windows-gnu
cargo build --target x86_64-pc-windows-gnu --release
- run:
name: Build Windows wheel
command: |
cd glean-core/python
GLEAN_PYTHON_MINGW_X86_64_BUILD=1 .venv3.7/bin/python3 setup.py bdist_wheel
.venv3.7/bin/python3 setup.py bdist_wheel
environment:
GLEAN_PYTHON_MINGW_X86_64_BUILD: 1
GLEAN_BUILD_VARIANT: release

build-windows-i686-wheel:
steps:
Expand All @@ -146,12 +149,15 @@ commands:
- run:
name: Build Windows glean_ffi.dll
command:
RUSTFLAGS="-C panic=abort" cargo build --target i686-pc-windows-gnu
RUSTFLAGS="-C panic=abort" cargo build --target i686-pc-windows-gnu --release
- run:
name: Build Windows wheel
command: |
cd glean-core/python
GLEAN_PYTHON_MINGW_I686_BUILD=1 .venv3.7/bin/python3 setup.py bdist_wheel
.venv3.7/bin/python3 setup.py bdist_wheel
environment:
GLEAN_PYTHON_MINGW_I686_BUILD: 1
GLEAN_BUILD_VARIANT: release

install-python-windows-deps:
steps:
Expand Down Expand Up @@ -902,6 +908,8 @@ jobs:
name: Build Python extension
command: |
make build-python
environment:
GLEAN_BUILD_VARIANT: release
- run:
name: Build Linux wheel
command: |
Expand All @@ -911,6 +919,8 @@ jobs:
# Requires that the TWINE_USERNAME and TWINE_PASSWORD environment
# variables are configured in CircleCI's environment variables.
.venv3.7/bin/python3 -m twine upload wheelhouse/*
environment:
GLEAN_BUILD_VARIANT: release
- install-ghr-linux
- run:
name: Publish to Github
Expand All @@ -929,6 +939,8 @@ jobs:
name: Build and Test Python extension
command: |
make test-python
environment:
GLEAN_BUILD_VARIANT: release
- run:
name: Build macOS wheel
command: |
Expand All @@ -937,6 +949,8 @@ jobs:
# Requires that the TWINE_USERNAME and TWINE_PASSWORD environment
# variables are configured in CircleCI's environment variables.
.venv3.7/bin/python3 -m twine upload dist/*
environment:
GLEAN_BUILD_VARIANT: release
- install-ghr-darwin
- run:
name: Publish to Github
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

* General
* Add rate limiting capabilities to the upload manager. ([1543612](https://bugzilla.mozilla.org/show_bug.cgi?id=1543612))
* Python
* Python wheels are now shipped with Glean release builds, resulting in much smaller libraries ([#1002](https://github.com/mozilla/glean/pull/1002))

[Full changelog](https://github.com/mozilla/glean/compare/v31.1.2...main)

Expand Down
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ help:

GLEAN_PYENV := $(shell python3 -c "import sys; print('glean-core/python/.venv' + '.'.join(str(x) for x in sys.version_info[:2]))")
GLEAN_PYDEPS := ${GLEAN_PYDEPS}
# Read the `GLEAN_BUILD_VARIANT` variable, default to debug.
# If set it is passed as a flag to cargo, so we prefix it with `--`
ifeq ($(GLEAN_BUILD_VARIANT),)
GLEAN_BUILD_PROFILE :=
else ifeq ($(GLEAN_BUILD_VARIANT),debug)
# `--debug` is invalid and `--profile debug` is unstable.
GLEAN_BUILD_PROFILE :=
else
GLEAN_BUILD_PROFILE := --$(GLEAN_BUILD_VARIANT)
endif

# Setup environments

Expand All @@ -29,7 +39,7 @@ $(GLEAN_PYENV)/bin/python3:
build: build-rust

build-rust: ## Build all Rust code
cargo build --all
cargo build --all $(GLEAN_BUILD_PROFILE)

build-kotlin: ## Build all Kotlin code
./gradlew build -x test
Expand Down
12 changes: 8 additions & 4 deletions glean-core/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,15 @@

setup_requirements = ["cffi>=1.0.0"]

# The environment variable `GLEAN_BUILD_VARIANT` can be set to `debug` or `release`
buildvariant = os.environ.get("GLEAN_BUILD_VARIANT", "debug")

if mingw_arch == "i686":
shared_object_build_dir = "../../target/i686-pc-windows-gnu/debug/"
shared_object_build_dir = "../../target/i686-pc-windows-gnu"
elif mingw_arch == "x86_64":
shared_object_build_dir = "../../target/x86_64-pc-windows-gnu/debug/"
shared_object_build_dir = "../../target/x86_64-pc-windows-gnu"
else:
shared_object_build_dir = "../../target/debug/"
shared_object_build_dir = "../../target"


if platform == "linux":
Expand All @@ -73,6 +76,7 @@
else:
raise ValueError("The platform {} is not supported.".format(sys.platform))

shared_object_path = f"{shared_object_build_dir}/{buildvariant}/{shared_object}"

shutil.copyfile("../metrics.yaml", "glean/metrics.yaml")
shutil.copyfile("../pings.yaml", "glean/pings.yaml")
Expand All @@ -81,7 +85,7 @@
# circumstances, this will still show up as an error when running the `build`
# command as a missing `package_data` file.
try:
shutil.copyfile(shared_object_build_dir + shared_object, "glean/" + shared_object)
shutil.copyfile(shared_object_path, "glean/" + shared_object)
except FileNotFoundError:
pass

Expand Down

0 comments on commit f2df415

Please sign in to comment.