Skip to content

Commit

Permalink
fix(build): fix build dependencies and CI (canonical#2137)
Browse files Browse the repository at this point in the history
  • Loading branch information
lengau authored Feb 5, 2025
1 parent e880b4b commit 197d536
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/qa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ jobs:
# Self-hosted Jammy and Noble runners, GH-hosted macos and Windows runners.
# Limiting to amd64 is a workaround for https://github.com/canonical/charmcraft/issues/2018
fast-test-platforms: '[["jammy", "amd64"], ["noble", "amd64"], "macos-13", "macos-14-large", "windows-2019", "windows-2022"]'
fast-test-python-versions: '["3.10", "3.12"]'
# Slow tests run on noble to avoid an issue with old skopeo versions.
slow-test-platforms: '["noble", "macos-14-large"]'
slow-test-python-versions: '["3.10", "3.12"]'
# Switch to just noble when we fix #2018
lowest-python-platform: self-hosted-linux-amd64-noble-large
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ jobs:
uses: astral-sh/setup-uv@v5
- name: Install dependencies
run: |
uv sync --no-dev
uv sync --no-dev --python=3.12
uv pip install pyinstaller
- name: Build
run: |
Expand Down
60 changes: 48 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,57 @@ publish-pypi: clean package-pip lint-twine ##- Publish Python packages to pypi
setup: install-uv setup-precommit ## Set up a development environment
uv sync --frozen $(SETUP_TESTS_EXTRA_ARGS) --extra docs --extra lint --extra types

# Find dependencies that need installing
APT_PACKAGES :=
ifeq ($(wildcard /usr/share/doc/libapt-pkg-dev/copyright),)
APT_PACKAGES += libapt-pkg-dev
endif
ifeq ($(wildcard /usr/share/doc/libffi-dev/copyright),)
APT_PACKAGES += libffi-dev
endif
ifeq ($(wildcard /usr/share/doc/libgit2-dev/copyright),)
APT_PACKAGES += libgit2-dev
endif
ifeq ($(wildcard /usr/include/libxml2/libxml/xpath.h),)
APT_PACKAGES += libxml2-dev
endif
ifeq ($(wildcard /usr/include/libxslt/xslt.h),)
APT_PACKAGES += libxslt1-dev
endif
ifeq ($(wildcard /usr/share/doc/libyaml-dev/copyright),)
APT_PACKAGES += libyaml-dev
endif
ifeq ($(wildcard /usr/share/doc/python3-dev/copyright),)
APT_PACKAGES += python3-dev
endif
ifeq ($(wildcard /usr/share/doc/python3-pip/copyright),)
APT_PACKAGES += python3-pip
endif
ifeq ($(wildcard /usr/share/doc/python3-setuptools/copyright),)
APT_PACKAGES += python3-setuptools
endif
ifeq ($(wildcard /usr/share/doc/python3-venv/copyright),)
APT_PACKAGES += python3-venv
endif
ifeq ($(wildcard /usr/share/doc/python3-wheel/copyright),)
APT_PACKAGES += python3-wheel
endif
ifeq ($(shell which skopeo),)
APT_PACKAGES += skopeo
endif

# Used for installing build dependencies in CI.
.PHONY: install-build-deps
install-build-deps: install-linux-build-deps install-macos-build-deps install-lint-build-deps
install-build-deps: install-linux-build-deps install-macos-build-deps
# Ensure the system pip is new enough. If we get an error about breaking system packages, it is.
sudo pip install 'pip>=22.2' || true
sudo pip install 'pip>=22.2' 2> /dev/null || true
ifeq ($(APT_PACKAGES),)
else ifeq ($(shell which apt-get),)
$(warning Cannot install build dependencies without apt.)
$(warning Please ensure the equivalents to these packages are installed: $(APT_PACKAGES))
else
sudo $(APT) install $(APT_PACKAGES)
endif

.PHONY: install-lint-build-deps
install-lint-build-deps:
Expand All @@ -55,18 +101,8 @@ endif

.PHONY: install-linux-build-deps
install-linux-build-deps:
ifneq ($(OS),Linux)
else ifeq ($(shell which apt-get),)
$(warning apt-get not found. Please install dependencies yourself.)
else
sudo $(APT) install skopeo
# Needed for integration testing the charm plugin.
sudo $(APT) install libyaml-dev python3-dev python3-pip python3-setuptools python3-venv python3-wheel
endif
ifneq ($(shell which snap),)
sudo snap install lxd
endif
ifneq ($(shell which lxd),)
sudo lxd init --auto
endif

Expand Down

0 comments on commit 197d536

Please sign in to comment.