Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New methods of building/installing PyThemis #1023

Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6ed9bc3
Add make target pythemis_make_wheel
iamnotacake Sep 22, 2023
47e1050
Extend CI for Python wrapper
iamnotacake Sep 25, 2023
215fee9
Extend CI for Python wrapper (fix)
iamnotacake Sep 25, 2023
f94ae6c
Update Makefile and PyThemis CI configuration
iamnotacake Sep 25, 2023
df7ae05
Rename pythemis_install -> pythemis_old_install
iamnotacake Sep 25, 2023
cfd531f
Fix PyThemis CI config
iamnotacake Sep 25, 2023
8538edc
Partially working debian pythemis package building
iamnotacake Sep 26, 2023
d55f2e2
deb packaging, CI job
iamnotacake Sep 27, 2023
297a4fd
Make target for .deb building and installing
iamnotacake Sep 27, 2023
d539d20
Fix make pythemis_deb
iamnotacake Sep 27, 2023
cea6064
Fix make pythemis_deb
iamnotacake Sep 27, 2023
f5d66e1
Update debian pythemis building
iamnotacake Sep 28, 2023
ef9fed1
Rename pythemis_old_install -> pythemis_install
iamnotacake Sep 28, 2023
d7d253e
Update Makefile and CI config
iamnotacake Sep 29, 2023
f9e16bb
Comment RHEL-related PyThemis installation
iamnotacake Sep 29, 2023
a8c9869
Fix Makefile
iamnotacake Oct 2, 2023
e11d5de
Fix Makefile
iamnotacake Oct 2, 2023
ec4a4ab
Merge branch 'master' into anatolii/T2771-update-pythemis-install
iamnotacake Oct 2, 2023
428aa41
Updates after review
iamnotacake Oct 4, 2023
bbb8c46
Enable rpm pythemis packaging, minor updates
iamnotacake Oct 5, 2023
c1a094a
Update rpm_python make target
iamnotacake Oct 6, 2023
21dc437
make/install libthemis deb in Python CI job
iamnotacake Oct 9, 2023
29040f6
make clean now cleans Python artifacts as well
iamnotacake Oct 11, 2023
1c1c04e
Fix conditional building of c++/java packages in deb target
iamnotacake Oct 11, 2023
e0bdada
Pin log dependency to 0.4.17
iamnotacake Oct 16, 2023
065809b
Pin byteorder version to 1.4.3
iamnotacake Oct 16, 2023
ab37c05
Merge branch 'master' into anatolii/T2771-update-pythemis-install
iamnotacake Nov 20, 2023
e3ef5e3
Merge branch 'master' into anatolii/T2771-update-pythemis-install
iamnotacake Nov 27, 2023
9307a9e
Update changelog [skip ci]
iamnotacake Nov 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/test-python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,69 @@ jobs:
- name: Run test suite
run: make test_python

unit-tests-venv:
name: Unit tests (virtualenv install)
# TODO: Switch to something more fresh, Ubuntu 22.04 or Debian Bookworm,
# after issue with deprecates in C++ tests is fixed
runs-on: ubuntu-20.04
steps:
- name: Install system dependencies
run: |
sudo sh -c 'echo "DEBIAN_FRONTEND=noninteractive" >> /etc/environment'
sudo apt update
sudo apt install --yes gcc make libssl-dev \
python3 python3-setuptools python3-pip python3-venv
- name: Check out code
uses: actions/checkout@v2
- name: Prepare Themis Core
run: |
make
sudo make install
make prepare_tests_all
- name: Create virtualenv
run: mkdir /tmp/test_venv && python3 -m venv /tmp/test_venv
- name: Install PyThemis into virtualenv
run: |
make pythemis_make_wheel
source /tmp/test_venv/bin/activate && make pythemis_install_wheel
- name: Run test suite
run: source /tmp/test_venv/bin/activate && make test_python
- name: Uninstall PyThemis
run: source /tmp/test_venv/bin/activate && pip uninstall -y pythemis

unit-tests-deb-pkg:
name: Unit tests (deb package)
# TODO: Switch to something more fresh, Ubuntu 22.04 or Debian Bookworm,
# after issue with deprecates in C++ tests is fixed
runs-on: ubuntu-20.04
steps:
- name: Install system dependencies
run: |
sudo sh -c 'echo "DEBIAN_FRONTEND=noninteractive" >> /etc/environment'
sudo apt update
sudo apt install --yes gcc make libssl-dev \
python3 python3-setuptools \
ruby
sudo gem install fpm
- name: Check out code
uses: actions/checkout@v2
- name: Prepare Themis Core
run: |
make
sudo make install
make prepare_tests_all
- name: Install libthemis deb
run: |
make deb WITHOUT_THEMISPP=1 WITHOUT_JAVA=1
sudo apt install ./build/deb/libthemis_*.deb
- name: Install PyThemis (deb package)
run: |
sudo make pythemis_install_deb
- name: Run test suite
run: make test_python
- name: Uninstall PyThemis
run: sudo apt remove -y python3-pythemis

examples:
name: Code examples
runs-on: ubuntu-20.04
Expand Down
92 changes: 89 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ $(BUILD_PATH)/configure.mk:
# then increment LIBRARY_SO_VERSION as well, and update package names.
VERSION := $(shell test -d .git && git describe --tags || cat VERSION)
LIBRARY_SO_VERSION = 0
# Version in format X.Y.Z, without build number and commit hash
VERSION_SHORT := $(shell cat VERSION)

#----- Toolchain ---------------------------------------------------------------

Expand Down Expand Up @@ -607,6 +609,25 @@ endif
@echo -n "pythemis install "
@$(BUILD_CMD_)

pythemis_make_wheel: CMD = cd src/wrappers/themis/python/ && python3 setup.py bdist_wheel
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

last comment. can we clean generated artifacts with clean target? this command creates new folder with source codes and wheel. or if we can specify destination folder, let's use $(BIN_PATH). It's already mentioned in the clean target

pythemis_make_wheel:
ifeq ($(PYTHON3_VERSION),)
@echo "python3 not found"
@exit 1
endif
@echo -n "pythemis make wheel "
@$(BUILD_CMD_)
@echo Result: src/wrappers/themis/python/dist/pythemis-$(VERSION_SHORT)-py2.py3-none-any.whl

pythemis_install_wheel: CMD = pip install src/wrappers/themis/python/dist/pythemis-$(VERSION_SHORT)-py2.py3-none-any.whl
pythemis_install_wheel:
ifeq ($(PYTHON3_VERSION),)
@echo "python3 not found"
@exit 1
endif
@echo -n "pythemis install wheel "
@$(BUILD_CMD_)

########################################################################
#
# Packaging Themis Core: Linux distributions
Expand Down Expand Up @@ -729,7 +750,7 @@ deb: PREFIX = /usr
deb: libdir = $(PREFIX)$(DEB_LIBDIR)
deb: jnidir = $(PREFIX)$(DEB_LIBDIR)/jni

deb: install themispp_install themis_jni_install
deb: install $(if $(WITHOUT_THEMISPP), , themispp_install) $(if $(WITHOUT_JAVA), , themis_jni_install)
@printf "ldconfig" > $(POST_INSTALL_SCRIPT)
@printf "ldconfig" > $(POST_UNINSTALL_SCRIPT)

Expand All @@ -750,6 +771,7 @@ deb: install themispp_install themis_jni_install
--after-install $(POST_INSTALL_SCRIPT) \
--after-remove $(POST_UNINSTALL_SCRIPT) \
--category $(PACKAGE_CATEGORY) \
--force \
$(foreach file,$(DEV_PACKAGE_FILES),$(DESTDIR)/$(file)=$(file))

@fpm --input-type dir \
Expand All @@ -767,9 +789,11 @@ deb: install themispp_install themis_jni_install
--after-remove $(POST_UNINSTALL_SCRIPT) \
--deb-priority optional \
--category $(PACKAGE_CATEGORY) \
--force \
$(foreach file,$(LIB_PACKAGE_FILES),$(DESTDIR)/$(file)=$(file))

@fpm --input-type dir \
@$(if $(WITHOUT_THEMISPP), false, true) && \
fpm --input-type dir \
--output-type deb \
--name $(DEB_THEMISPP_PACKAGE_NAME) \
--license $(LICENSE_NAME) \
Expand All @@ -784,9 +808,11 @@ deb: install themispp_install themis_jni_install
--after-install $(POST_INSTALL_SCRIPT) \
--after-remove $(POST_UNINSTALL_SCRIPT) \
--category $(PACKAGE_CATEGORY) \
--force \
$(foreach file,$(THEMISPP_PACKAGE_FILES),$(DESTDIR)/$(file)=$(file))

@fpm --input-type dir \
@$(if $(WITHOUT_JAVA), false, true) && \
fpm --input-type dir \
--output-type deb \
--name $(JNI_PACKAGE_NAME) \
--license $(LICENSE_NAME) \
Expand All @@ -801,10 +827,43 @@ deb: install themispp_install themis_jni_install
--after-remove $(POST_UNINSTALL_SCRIPT) \
--deb-priority optional \
--category $(PACKAGE_CATEGORY) \
--force \
$(foreach file,$(JNI_PACKAGE_FILES),$(DESTDIR)/$(file)=$(file))

@find $(BIN_PATH) -name \*.deb

# Use builtin feature of fpm to create a .deb package from a Python package dir.
# Dependencies are automatically added, i.e. PyThemis depends on `six`, so fpm will add `python3-six` to deps.
deb_python: DEB_ARCHITECTURE = all
deb_python: DESTDIR = $(BIN_PATH)/deb/pythemis_root
deb_python:
@mkdir -p $(BIN_PATH)/deb
@fpm --input-type python \
--output-type deb \
--python-bin=python3 \
--python-package-name-prefix=python3 \
--name python3-pythemis \
--license $(LICENSE_NAME) \
--url '$(COSSACKLABS_URL)' \
--description '$(SHORT_DESCRIPTION)' \
--maintainer $(MAINTAINER) \
--package $(BIN_PATH)/deb/python3-pythemis_$(NAME_SUFFIX) \
--architecture $(DEB_ARCHITECTURE) \
--version $(VERSION)+$(OS_CODENAME) \
--depends python3 --depends libthemis \
--deb-priority optional \
--category $(PACKAGE_CATEGORY) \
--force \
src/wrappers/themis/python

@echo $(BIN_PATH)/deb/python3-pythemis_$(NAME_SUFFIX)

# Using `apt` since it could install dependencies (we depend on python3-six),
# while dpkg would just complain about missing dependency and fail
pythemis_install_deb: DEB_ARCHITECTURE = all
pythemis_install_deb: deb_python
apt install ./$(BIN_PATH)/deb/python3-pythemis_$(NAME_SUFFIX)

rpm: MODE_PACKAGING = 1
rpm: DESTDIR = $(BIN_PATH)/rpm/root
rpm: PREFIX = /usr
Expand Down Expand Up @@ -882,6 +941,33 @@ rpm: install themispp_install themis_jni_install

@find $(BIN_PATH) -name \*.rpm

rpm_python: ARCHITECTURE = all
rpm_python:
@mkdir -p $(BIN_PATH)/rpm
@fpm --input-type python \
--output-type rpm \
--python-bin=python3 \
--python-package-name-prefix=python3 \
--name python3-pythemis \
--license $(LICENSE_NAME) \
--url '$(COSSACKLABS_URL)' \
--description '$(SHORT_DESCRIPTION)' \
--rpm-summary '$(RPM_SUMMARY)' \
--maintainer $(MAINTAINER) \
--package $(BIN_PATH)/rpm/python3-pythemis_$(NAME_SUFFIX) \
--version $(RPM_VERSION) \
--depends python3 --depends libthemis \
--category $(PACKAGE_CATEGORY) \
--force \
src/wrappers/themis/python

@echo $(BIN_PATH)/rpm/python3-pythemis_$(NAME_SUFFIX)

pythemis_install_rpm: ARCHITECTURE = all
pythemis_install_rpm: rpm_python
yum install ./$(BIN_PATH)/rpm/python3-pythemis_$(NAME_SUFFIX)


########################################################################
#
# Packaging Themis Core: Windows (NSIS)
Expand Down
Loading