1+ PROJECT_SOURCE_DIR ?= $(abspath ./)
2+ PROJECT_NAME ?= $(shell basename $(PROJECT_SOURCE_DIR ) )
3+ NUM_JOBS ?= 8
4+
15all :
26 @echo nothing special
37
@@ -11,19 +15,23 @@ lint:
1115 pre-commit run -a
1216lint_install :
1317 pre-commit install
18+ .PHONY : lint
1419
15- build :
16- mkdir -p build && cd build && \
17- cmake .. && make
18- .PHONY : build
20+ reset_submodules :
21+ git submodule update --init --recursive
22+
23+ pytest :
24+ python3 -m pip install pytest
25+ pytest tests # --capture=tee-sys
26+ .PHONY : test pytest
1927
2028docs_build :
2129 mkdocs build
2230docs_serve :
2331 mkdocs serve -a 0.0.0.0:8088
2432
2533DOCKER_TAG_WINDOWS ?= ghcr.io/cubao/build-env-windows-x64:v0.0.1
26- DOCKER_TAG_LINUX ?= ghcr.io/cubao/build-env-manylinux2014-x64:v0.0.1
34+ DOCKER_TAG_LINUX ?= ghcr.io/cubao/build-env-manylinux2014-x64:v0.0.4
2735DOCKER_TAG_MACOS ?= ghcr.io/cubao/build-env-macos-arm64:v0.0.1
2836
2937test_in_win :
@@ -33,19 +41,29 @@ test_in_mac:
3341test_in_linux :
3442 docker run --rm -w ` pwd` -v ` pwd` :` pwd` -v ` pwd` /build/linux:` pwd` /build -it $(DOCKER_TAG_LINUX ) bash
3543
44+ DEV_CONTAINER_NAME ?= $(USER ) _$(subst /,_,$(PROJECT_NAME ) ____$(PROJECT_SOURCE_DIR ) )
45+ DEV_CONTAINER_IMAG ?= $(DOCKER_TAG_LINUX )
46+ test_in_dev_container :
47+ docker ps | grep $(DEV_CONTAINER_NAME ) \
48+ && docker exec -it $(DEV_CONTAINER_NAME ) bash \
49+ || docker run --rm --name $(DEV_CONTAINER_NAME ) \
50+ --network host --security-opt seccomp=unconfined \
51+ -v ` pwd` :` pwd` -w ` pwd` -it $(DEV_CONTAINER_IMAG ) bash
52+
53+
3654PYTHON ?= python3
55+ build :
56+ $(PYTHON ) -m pip install scikit_build_core pyproject_metadata pathspec pybind11
57+ CMAKE_BUILD_PARALLEL_LEVEL=$(NUM_JOBS ) $(PYTHON ) -m pip install --no-build-isolation -Ceditable.rebuild=true -Cbuild-dir=build -ve.
3758python_install :
38- $(PYTHON ) setup.py install --force
39- python_build :
40- $(PYTHON ) setup.py bdist_wheel
59+ $(PYTHON ) -m pip install . --verbose
60+ python_wheel :
61+ $(PYTHON ) -m pip wheel . -w build --verbose
4162python_sdist :
42- $(PYTHON ) setup.py sdist
43- # tar -tvf dist/pybind11_rdp-*.tar.gz
44- python_test :
45- $(PYTHON ) -m pip install pytest rdp
46- $(PYTHON ) -c ' from pybind11_rdp import rdp; print(rdp([[1, 1], [2, 2], [3, 3], [4, 4]]))'
47- pytest tests
48- $(PYTHON ) test.py
63+ $(PYTHON ) -m pip install build
64+ $(PYTHON ) -m build --sdist --verbose
65+ python_test : pytest
66+ .PHONY : build
4967
5068# conda create -y -n py36 python=3.6
5169# conda create -y -n py37 python=3.7
@@ -65,23 +83,24 @@ python_build_py310:
6583 PYTHON=python conda run --no-capture-output -n py310 make python_build
6684python_build_all : python_build_py36 python_build_py37 python_build_py38 python_build_py39 python_build_py310
6785python_build_all_in_linux :
68- docker run --rm -w ` pwd` -v ` pwd` :` pwd` -v ` pwd` /build/win :` pwd` /build -it $(DOCKER_TAG_LINUX ) make python_build_all
86+ docker run --rm -w ` pwd` -v ` pwd` :` pwd` -v ` pwd` /build/linux :` pwd` /build -it $(DOCKER_TAG_LINUX ) make python_build_all
6987 make repair_wheels && rm -rf dist/* .whl && mv wheelhouse/* .whl dist && rm -rf wheelhouse
7088python_build_all_in_macos : python_build_py38 python_build_py39 python_build_py310
7189python_build_all_in_windows : python_build_all
7290
7391repair_wheels :
7492 python -m pip install auditwheel # sudo apt install patchelf
75- ls dist/* | xargs -n1 auditwheel repair --plat manylinux2014_x86_64
93+ ls dist/* -linux_x86_64.whl | xargs -n1 auditwheel repair --plat manylinux2014_x86_64
94+ rm -rf dist/* -linux_x86_64.whl && cp wheelhouse/* .whl dist && rm -rf wheelhouse
7695
7796pypi_remote ?= pypi
7897upload_wheels :
7998 python -m pip install twine
8099 twine upload dist/* .whl -r $(pypi_remote )
81100
82101tar.gz :
83- tar -cvz --exclude .git -f ../pybind11-rdp .tar.gz .
84- ls -alh ../pybind11-rdp .tar.gz
102+ tar -cvz --exclude .git -f ../$( PROJECT_NAME ) .tar.gz .
103+ ls -alh ../$( PROJECT_NAME ) .tar.gz
85104
86105# https://stackoverflow.com/a/25817631
87106echo-% : ; @echo -n $($* )
0 commit comments