Skip to content

Commit

Permalink
feat: prepare to build wheels for windows and linux
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-vincent committed Dec 20, 2023
1 parent c099551 commit 9d48aac
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 27 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Endstone
3 changes: 3 additions & 0 deletions endstone_api/include/endstone/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

class PluginManager;

/**
* @brief Represents a server implementation.
*/
class Server {
public:
Server() = default;
Expand Down
1 change: 1 addition & 0 deletions endstone_python/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python/endstone/_version.py
7 changes: 5 additions & 2 deletions endstone_python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ target_link_libraries(endstone_python PRIVATE endstone::api)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
target_link_libraries(endstone_python PRIVATE "stdc++fs")
endif ()
set_target_properties(endstone_python PROPERTIES OUTPUT_NAME "endstone")
set_target_properties(endstone_python PROPERTIES OUTPUT_NAME "_api")

include(GNUInstallDirs)
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(TARGETS endstone_python
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
if (DEFINED SKBUILD_PROJECT_NAME)
install(TARGETS endstone_python DESTINATION ${SKBUILD_PROJECT_NAME} COMPONENT endstone_wheel OPTIONAL)
endif ()
5 changes: 5 additions & 0 deletions endstone_python/python/endstone/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from importlib import import_module

module = import_module(f"{__name__}._api")
globals().update(module.__dict__)
del module
2 changes: 2 additions & 0 deletions endstone_python/python/endstone/_bootstrap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def cli():
print("Hello cli")
6 changes: 6 additions & 0 deletions endstone_python/python/endstone/server.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Server:
"""
Represents a server implementation.
"""

...
2 changes: 1 addition & 1 deletion endstone_python/src/endstone_python/endstone_python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

namespace py = pybind11;

PYBIND11_MODULE(endstone, m)
PYBIND11_MODULE(_api, m)
{
py::class_<Server>(m, "Server");
}
11 changes: 11 additions & 0 deletions endstone_python/test/test_endstone.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import importlib


def test_import_endstone():
# import endstone
importlib.import_module("endstone")


def test_import_server():
# from endstone import Server
getattr(importlib.import_module("endstone"), "Server")
70 changes: 46 additions & 24 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["scikit-build-core", "conan"]
requires = ["scikit-build-core"]
build-backend = "scikit_build_core.build"

[project]
Expand All @@ -23,29 +23,51 @@ classifiers = [
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
]
#dependencies = [
# "click",
# "requests",
# "tomli",
# "tqdm",
# "packaging"
#]
dependencies = ["click", "requests", "rich", "tomli", "packaging"]
dynamic = ["version"]

[project.optional-dependencies]
pytest = ["pytest"]

#[project.scripts]
#endstone = "endstone.bootstrap.cli:cli"
#
#[tool.scikit-build]
#build-dir = "build/{wheel_tag}"
#cmake.build-type = "Release"
#cmake.verbose = true
#wheel.packages = ["python/endstone"]
#wheel.license-files = ["LICENSE"]
#metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"
#sdist.include = ["python/endstone/_version.py"]
#
#[tool.scikit-build.cmake.define]
#BUILD_TESTING = "OFF"
test = ["pytest"]

[project.urls]
#Changelog = "https://endstone.readthedocs.io/en/latest/changelog.html"
Discussions = "https://github.com/orgs/EndstoneMC/discussions"
Documentation = "https://endstone.readthedocs.io"
Homepage = "https://github.com/EndstoneMC/endstone"
Issues = "https://github.com/EndstoneMC/endstone/issues"

[project.scripts]
endstone = "endstone._bootstrap:cli"

[tool.scikit-build]
build-dir = "build/{wheel_tag}"
cmake.args = ["-G Ninja", "--preset conan-release"]
cmake.define = { BUILD_TESTING = "OFF" }
wheel.packages = ["endstone_python/python/endstone"]
wheel.license-files = ["LICENSE"]
install.components = ["endstone_wheel"]
metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"
sdist.include = ["endstone_python/python/endstone/_version.py"]

[tool.setuptools_scm]
write_to = "endstone_python/python/endstone/_version.py"

[tool.cibuildwheel]
build = ["cp*-win_amd64", "cp*-manylinux_x86_64"]
test-requires = "pytest"
test-command = "pytest {project}/endstone_python/test"

[tool.cibuildwheel.windows]
before-build = [
"pip install conan",
"conan profile detect --force",
"conan install . --build=missing -s compiler.cppstd=17 -c tools.cmake.cmaketoolchain:generator=Ninja",
".\\build\\Release\\generators\\conanbuild.bat"
]

[tool.cibuildwheel.linux]
before-build = [
"pip install conan ninja",
"conan profile detect --force",
"conan install . --build=missing -s compiler.cppstd=17 -c tools.cmake.cmaketoolchain:generator=Ninja"
]

0 comments on commit 9d48aac

Please sign in to comment.