Skip to content

Commit

Permalink
add pip packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
zhixiong-tang committed Oct 1, 2022
1 parent 4dea5be commit 8ac19d2
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,5 @@ docs/python_api/
docs/conf.py
docs/Doxyfile
docs/getting_started.rst
docs/tensorboard.md
docs/tensorboard.md
wheels
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ if(NOT DEFINED Python3_FIND_REGISTRY)
# Only consider PATH variable on Windows by default
set(Python3_FIND_REGISTRY NEVER)
endif()
find_package(Python3 3.6...<3.10
find_package(Python3 3.6...<3.11
COMPONENTS Interpreter Development
)
if (Python3_FOUND)
Expand All @@ -244,7 +244,7 @@ if (Python3_FOUND)
"Deprecated path to the Python executable (for 3rdparty only)" FORCE)
else()
if (BUILD_PYTHON_MODULE)
message(FATAL_ERROR "BUILD_PYTHON_MODULE=ON requires Python 3.6-3.9. Please ensure it is in PATH.")
message(FATAL_ERROR "BUILD_PYTHON_MODULE=ON requires Python 3.6-3.10. Please ensure it is in PATH.")
endif()
endif()

Expand Down
58 changes: 58 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
PROJECT_SOURCE_DIR ?= $(abspath ./)
BUILD_DIR ?= $(PROJECT_SOURCE_DIR)/build
INSTALL_DIR ?= $(BUILD_DIR)/install
NUM_JOB ?= 8
PYTHON_EXECUTABLE ?= $(shell which python3.7)
WHEELS_DIR ?= $(PROJECT_SOURCE_DIR)/wheels

all:
@echo nothing special
clean:
rm -rf $(BUILD_DIR)
force_clean:
docker run --rm -v `pwd`:`pwd` -w `pwd` -it alpine/make make clean

CMAKE_ARGS ?= \
-DBUILD_EXAMPLES=OFF \
-DBUILD_FILAMENT_FROM_SOURCE=ON \
-DBUILD_GUI=OFF \
-DBUILD_PYTHON_MODULE=ON -DPYTHON_EXECUTABLE=$(PYTHON_EXECUTABLE) \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_WEBRTC=OFF \
-DCMAKE_INSTALL_PREFIX=$(INSTALL_DIR)
build:
mkdir -p $(WHEELS_DIR)
mkdir -p $(BUILD_DIR) && cd $(BUILD_DIR) && \
cmake $(CMAKE_ARGS) $(PROJECT_SOURCE_DIR) && \
make -j$(NUM_JOBS) && \
make install pip-package && \
cp lib/python_package/pip_package/*.whl $(WHEELS_DIR)

.PHONY: all clean force_clean build

build_py36_conda:
conda env list | grep '^py36 ' && PYTHON_EXECUTABLE=python BUILD_DIR=$(BUILD_DIR)/py36 conda run --no-capture-output -n py36 make build
build_py37_conda:
conda env list | grep '^py37 ' && PYTHON_EXECUTABLE=python BUILD_DIR=$(BUILD_DIR)/py37 conda run --no-capture-output -n py37 make build
build_py38_conda:
conda env list | grep '^py38 ' && PYTHON_EXECUTABLE=python BUILD_DIR=$(BUILD_DIR)/py38 conda run --no-capture-output -n py38 make build
build_py39_conda:
conda env list | grep '^py39 ' && PYTHON_EXECUTABLE=python BUILD_DIR=$(BUILD_DIR)/py39 conda run --no-capture-output -n py39 make build
build_py310_conda:
conda env list | grep '^py310 ' && PYTHON_EXECUTABLE=python BUILD_DIR=$(BUILD_DIR)/py310 conda run --no-capture-output -n py310 make build
build_wheels_for_conda: build_py36_conda build_py37_conda build_py38_conda build_py39_conda build_py310_conda
.PHONY: build_python_all build_py36 build_py37 build_py38 build_py39 build_py310

build_python_all: build_wheels_for_conda
.PHONY: build_python_all

upload_wheels:
python3 -m pip install twine
twine upload wheels/* -r local

# https://github.com/orgs/cubao/packages/container/package/build-env-manylinux2014-x64
MANYLINUX_TAG := ghcr.io/cubao/build-env-manylinux2014-x64:latest
test_in_manylinux:
docker run --rm -v `pwd`:`pwd` -w `pwd` -it $(MANYLINUX_TAG) bash
build_wheels_in_manylinux:
docker run --rm -v `pwd`:`pwd` -w `pwd` -it $(MANYLINUX_TAG) make build_python_all
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
> base on <https://gist.github.com/district10/c9d3e2a353b3435a5545b80bf7aba746>
## packaging pip wheels

interactive

```
make test_in_manylinux
make build_py36_conda
...
```

build all wheels

```
make build_wheels_in_manylinux
```

all wheels goes to `wheels/` dir.

---

<p align="center">
<img src="https://raw.githubusercontent.com/isl-org/Open3D/master/docs/_static/open3d_logo_horizontal.png" width="320" />
</p>
Expand Down

0 comments on commit 8ac19d2

Please sign in to comment.