Skip to content

Commit

Permalink
Making sure pypi is less of a mess
Browse files Browse the repository at this point in the history
  • Loading branch information
philkr committed Aug 22, 2019
1 parent 4a00bcc commit 40a7dd6
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 152 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ if (NOT SERVER_ONLY)
add_subdirectory("${PROJECT_SOURCE_DIR}/lib/libpng")
include_directories("${PROJECT_SOURCE_DIR}/lib/libpng")

set(PNG_PNG_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/lib/libpng/")
set(PNG_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/lib/libpng/")
set(PNG_LIBRARY png_static)

add_subdirectory("${PROJECT_SOURCE_DIR}/lib/jpeglib")
Expand Down
3 changes: 1 addition & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
include *.txt *.md *.cmake
recursive-include src *.cpp *.h *.hpp
recursive-include pystk *.cpp *.h *.hpp *.py
recursive-include pystk_cpp *.cpp *.h *.hpp
recursive-include lib *.cpp *.c *.h *.hpp *.inl *.txt *.cmake *.in *.cmakein README *.md LICENSE* *.prebuilt
recursive-include stk-assets *
recursive-include examples *.py
recursive-include docs *.rst Makefile conf.py
recursive-include data *
Expand Down
2 changes: 1 addition & 1 deletion docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Using pip

.. code-block:: bash
pip install pystk
pip install PySuperTuxKart
From source
-----------
Expand Down
77 changes: 0 additions & 77 deletions lib/freetype/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,6 @@ set(VERSION_PATCH "0")
set(LIBRARY_VERSION "6.16.0")
set(LIBRARY_SOVERSION "6")

# These options mean "require x and complain if not found". They'll get
# optionally found anyway. Use `-DCMAKE_DISABLE_FIND_PACKAGE_x=TRUE` to disable
# searching for a packge entirely (x is the CMake package name, so "BZip2"
# instead of "BZIP2").
option(FT_WITH_ZLIB "Use system zlib instead of internal library." OFF)
option(FT_WITH_BZIP2 "Support bzip2 compressed fonts." OFF)
option(FT_WITH_PNG "Support PNG compressed OpenType embedded bitmaps." OFF)
option(FT_WITH_HARFBUZZ "Improve auto-hinting of OpenType fonts." OFF)


# Disallow in-source builds
if ("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
Expand Down Expand Up @@ -184,31 +175,6 @@ if (BUILD_FRAMEWORK)
endif ()


# Find dependencies
if (FT_WITH_HARFBUZZ)
find_package(HarfBuzz 1.3.0 REQUIRED)
else ()
find_package(HarfBuzz 1.3.0)
endif ()

if (FT_WITH_PNG)
find_package(PNG REQUIRED)
else ()
find_package(PNG)
endif ()

if (FT_WITH_ZLIB)
find_package(ZLIB REQUIRED)
else ()
find_package(ZLIB)
endif ()

if (FT_WITH_BZIP2)
find_package(BZip2 REQUIRED)
else ()
find_package(BZip2)
endif ()

# Create the configuration file
if (UNIX)
check_include_file("unistd.h" HAVE_UNISTD_H)
Expand Down Expand Up @@ -245,26 +211,6 @@ file(WRITE "${PROJECT_BINARY_DIR}/include/freetype/config/ftconfig.h"
# Create the options file
file(READ "${PROJECT_SOURCE_DIR}/include/freetype/config/ftoption.h"
FTOPTION_H)
if (ZLIB_FOUND)
string(REGEX REPLACE
"/\\* +(#define +FT_CONFIG_OPTION_SYSTEM_ZLIB) +\\*/" "\\1"
FTOPTION_H "${FTOPTION_H}")
endif ()
if (BZIP2_FOUND)
string(REGEX REPLACE
"/\\* +(#define +FT_CONFIG_OPTION_USE_BZIP2) +\\*/" "\\1"
FTOPTION_H "${FTOPTION_H}")
endif ()
if (PNG_FOUND)
string(REGEX REPLACE
"/\\* +(#define +FT_CONFIG_OPTION_USE_PNG) +\\*/" "\\1"
FTOPTION_H "${FTOPTION_H}")
endif ()
if (HARFBUZZ_FOUND)
string(REGEX REPLACE
"/\\* +(#define +FT_CONFIG_OPTION_USE_HARFBUZZ) +\\*/" "\\1"
FTOPTION_H "${FTOPTION_H}")
endif ()
file(WRITE "${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h"
"${FTOPTION_H}")

Expand Down Expand Up @@ -392,29 +338,6 @@ endif ()

set(PKG_CONFIG_REQUIRED_PRIVATE "")

if (ZLIB_FOUND)
target_link_libraries(freetype PRIVATE ${ZLIB_LIBRARIES})
target_include_directories(freetype PRIVATE ${ZLIB_INCLUDE_DIRS})
list(APPEND PKG_CONFIG_REQUIRED_PRIVATE zlib)
endif ()
if (BZIP2_FOUND)
target_link_libraries(freetype PRIVATE ${BZIP2_LIBRARIES})
target_include_directories(freetype PRIVATE ${BZIP2_INCLUDE_DIR}) # not BZIP2_INCLUDE_DIRS
list(APPEND PKG_CONFIG_REQUIRED_PRIVATE bzip2)
endif ()
if (PNG_FOUND)
target_link_libraries(freetype PRIVATE ${PNG_LIBRARIES})
target_compile_definitions(freetype PRIVATE ${PNG_DEFINITIONS})
target_include_directories(freetype PRIVATE ${PNG_INCLUDE_DIRS})
list(APPEND PKG_CONFIG_REQUIRED_PRIVATE libpng)
endif ()
if (HARFBUZZ_FOUND)
target_link_libraries(freetype PRIVATE ${HARFBUZZ_LIBRARIES})
target_include_directories(freetype PRIVATE ${HARFBUZZ_INCLUDE_DIRS})
list(APPEND PKG_CONFIG_REQUIRED_PRIVATE harfbuzz)
endif ()


# Installation
include(GNUInstallDirs)

Expand Down
4 changes: 1 addition & 3 deletions lib/irrlicht/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# CMakeLists.txt for Irrlicht in STK
if(NOT SERVER_ONLY)
find_package(PNG REQUIRED)
find_package(JPEG REQUIRED)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include/"
"${JPEG_INCLUDE_DIR}"
"${PNG_INCLUDE_DIRS}"
"${PNG_INCLUDE_DIR}"
"${ZLIB_INCLUDE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/../../src")
include_directories("${CMAKE_CURRENT_BINARY_DIR}/../zlib/") # For zconf.h on WIN32
Expand Down
61 changes: 0 additions & 61 deletions lib/zlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,65 +145,4 @@ if(MINGW)
set(ZLIB_SRCS ${ZLIB_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
endif(MINGW)

add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
set_target_properties(zlib PROPERTIES SOVERSION 1)

if(NOT CYGWIN)
# This property causes shared libraries on Linux to have the full version
# encoded into their final filename. We disable this on Cygwin because
# it causes cygz-${ZLIB_FULL_VERSION}.dll to be created when cygz.dll
# seems to be the default.
#
# This has no effect with MSVC, on that platform the version info for
# the DLL comes from the resource file win32/zlib1.rc
set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION})
endif()

if(UNIX)
# On unix-like platforms the library is almost always called libz
set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z)
# set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/zlib.map")
elseif(BUILD_SHARED_LIBS AND WIN32)
# Creates zlib1.dll when building shared library version
set_target_properties(zlib PROPERTIES SUFFIX "1.dll")
endif()

if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
install(TARGETS zlib zlibstatic
RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
endif()
if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION "${INSTALL_INC_DIR}")
endif()
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
install(FILES zlib.3 DESTINATION "${INSTALL_MAN_DIR}/man3")
endif()
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
install(FILES ${ZLIB_PC} DESTINATION "${INSTALL_PKGCONFIG_DIR}")
endif()

#============================================================================
# Example binaries
#============================================================================

#add_executable(example test/example.c)
#target_link_libraries(example zlib)
#add_test(example example)

#add_executable(minigzip test/minigzip.c)
#target_link_libraries(minigzip zlib)

#if(HAVE_OFF64_T)
# add_executable(example64 test/example.c)
# target_link_libraries(example64 zlib)
# set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
# add_test(example64 example64)

# add_executable(minigzip64 test/minigzip.c)
# target_link_libraries(minigzip64 zlib)
# set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
#endif()
11 changes: 9 additions & 2 deletions pystk_cpp/binding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ using namespace pybind11::literals;

PYBIND11_MAKE_OPAQUE(std::vector<PySTKPlayerConfig>);


void path_and_init(const PySTKGraphicsConfig & config) {
auto sys = py::module::import("sys"), os = py::module::import("os");
auto path = os.attr("path"), environ = os.attr("environ");
auto module_path = path.attr("join")(path.attr("dirname")(path.attr("abspath")(sys.attr("modules")["pystk"].attr("__file__"))), "pystk_data");
// Give supertuxkart a hint where the assets are
environ["SUPERTUXKART_DATADIR"] = module_path;
PySTKRace::init(config);
}
PYBIND11_MODULE(pystk, m) {
m.doc() = "Python SuperTuxKart interface";

Expand Down Expand Up @@ -183,7 +190,7 @@ PYBIND11_MODULE(pystk, m) {
m.def("list_karts", &PySTKRace::listKarts, "Return a list of karts to play as (possible values for PlayerConfig.kart");

// Initialize SuperTuxKart
m.def("init", &PySTKRace::init, py::arg("config"), "Initialize Python SuperTuxKart. Only call this function once per process. Calling it twice will cause a crash.");
m.def("init", &path_and_init, py::arg("config"), "Initialize Python SuperTuxKart. Only call this function once per process. Calling it twice will cause a crash.");
m.def("clean", &PySTKRace::clean, "Free Python SuperTuxKart, call this once at exit (optional). Will be called atexit otherwise.");

auto atexit = py::module::import("atexit");
Expand Down
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ def ignore(base, entries):


setup(
name='pystk',
version='1.0',
name='PySuperTuxKart',
version='1.0a1',
author='Philipp Krähenbühl',
author_email='philkr@utexas.edu',
description='Python SuperTuxKart inferface',
Expand All @@ -171,9 +171,9 @@ def ignore(base, entries):

# tell setuptools that all packages will be under the 'src' directory
# and nowhere else
packages=['.'],
package_dir={'': '.'},
package_data={'': ['*.md', 'docs/*', 'examples/*.py']},
packages=['pystk_data'],
package_dir={'pystk_data': '.'},
package_data={'pystk_data': ['*.md', 'docs/*', 'examples/*.py']},
# TODO: Add more
#install_requires=['cmake'],
python_requires='>=3.6',
Expand Down

0 comments on commit 40a7dd6

Please sign in to comment.