Skip to content

Commit

Permalink
drop python module installer cuz it can't do what I want... use cmake…
Browse files Browse the repository at this point in the history
… instead
  • Loading branch information
zaufi committed Jun 10, 2012
1 parent c885fab commit 533786b
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 76 deletions.
28 changes: 2 additions & 26 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,27 +1,3 @@
*.py[co]

# Packages
*.egg
*.egg-info
dist
build
eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg

# Installer logs
pip-log.txt

# Unit test / coverage reports
.coverage
.tox

#Translations
*.mo

#Mr Developer
.mr.developer.cfg
*.expandc
*.kate-swp
35 changes: 35 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#
# Copyright 2012 by Alex Trubov <i.zaufi@gmail.com>
#

cmake_minimum_required(VERSION 2.6)
cmake_policy(SET CMP0002 OLD)

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})

project(kate-pate-plugins NONE)

find_package(PythonInterp REQUIRED)
include(PythonMacros)

if(INSTALL_TYPE STREQUAL "user")
set(CMAKE_INSTALL_PREFIX "~/.kde4/share/apps/kate/pate")
else()
set(CMAKE_INSTALL_PREFIX "/usr/share/apps/kate/pate")
endif()

set(LIBKATEPATE_DIR libkatepate)
set(LIBKATEPATE_SOURCES ${LIBKATEPATE_DIR}/__init__.py ${LIBKATEPATE_DIR}/ui.py)
python_install(${CMAKE_INSTALL_PREFIX}/${LIBKATEPATE_DIR} ${LIBKATEPATE_SOURCES})

set(PLUGIN_SOURCES format.py block.py commentar.py expand/expand.py)
python_install(${CMAKE_INSTALL_PREFIX} ${PLUGIN_SOURCES})

set(EXPAND_DIR libkatepate)
set(EXPAND_SOURCES expand/text_x-c++src.expand)
python_install(${CMAKE_INSTALL_PREFIX}/${EXPAND_DIR} ${EXPAND_SOURCES})

install(
FILES expand/text_x-c++hdr.expand expand/text_x-chdr.expand
DESTINATION ${CMAKE_INSTALL_PREFIX}/${EXPAND_DIR}
)
5 changes: 0 additions & 5 deletions MANIFEST.in

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ How to install

To install Pâté plugins system-wide:

sudo easy_install kate-pate-plugins
$ cmake && sudo make install

or

easy_install kate-pate-plugins --user=~/.kde4/share/apps/kate/pate
$ cmake -DINSTALL_TYPE=user && make install

to install into your home directory. Do not forget to enable the Pâté plugin
in Kate settings.
4 changes: 4 additions & 0 deletions cmake/PythonCompile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# By Simon Edwards <simon@simonzone.com>
# This file is in the public domain.
import py_compile
py_compile.main()
71 changes: 71 additions & 0 deletions cmake/PythonMacros.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Python macros
# ~~~~~~~~~~~~~
# Copyright (c) 2007, Simon Edwards <simon@simonzone.com>
# Copyright (c) 2012, Alex Turbov <i.zaufi@gmail.com>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
# This file defines the following macros:
#
# python_install(DESINATION_DIR SOURCE_FILE0[ SOURCE_FILE1[ ... [SOURCE_FILEn]]])
# Install source files, which is a Python .py files, into the
# destination directory during install. The file will be byte compiled
# and both the .py file and .pyc file will be installed.
#
# Changelog:
# Mon Jun 11 02:49:02 MSK 2012, by Alex Turbov
# Refactoring to support variadic number of source files
# Prevent excecution w/ incorrect arguments count
#

get_filename_component(PYTHON_MACROS_MODULE_PATH ${CMAKE_CURRENT_LIST_FILE} PATH)

macro(python_install DESINATION_DIR)
set(SOURCE_FILES ${ARGN})

# Make sure that we have smth to do...
if(${ARGC} LESS 2)
message(FATAL_ERROR "At least one source file required for python_install()")
return()
endif()

add_custom_target(compile_python_files ALL)

# Install the source files.
install(FILES ${SOURCE_FILES} DESTINATION ${DESINATION_DIR})

foreach(_py_file ${SOURCE_FILES})
# Byte compile and install the .pyc file.
get_filename_component(_absfilename ${_py_file} ABSOLUTE)
get_filename_component(_filename ${_py_file} NAME)
get_filename_component(_filenamebase ${_py_file} NAME_WE)
get_filename_component(_basepath ${_py_file} PATH)
get_filename_component(_ext ${_py_file} EXT)
set(_bin_py ${CMAKE_CURRENT_BINARY_DIR}/${_basepath}/${_filename})
set(_bin_pyc ${CMAKE_CURRENT_BINARY_DIR}/${_basepath}/${_filenamebase}${_ext}c)

file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${_basepath})

get_filename_component(_abs_bin_py ${_bin_py} ABSOLUTE)
# Don't copy the file onto itself.
if(_abs_bin_py STREQUAL ${_absfilename})
add_custom_command(
TARGET compile_python_files
COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_MACROS_MODULE_PATH}/PythonCompile.py ${_bin_py}
DEPENDS ${_absfilename}
COMMENT "Byte-compiling ${_py_file}"
)
else()
add_custom_command(
TARGET compile_python_files
COMMAND ${CMAKE_COMMAND} -E copy ${_absfilename} ${_bin_py}
COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_MACROS_MODULE_PATH}/PythonCompile.py ${_bin_py}
DEPENDS ${_absfilename}
COMMENT "Byte-compiling ${_py_file}"
)
endif()
install(FILES ${_bin_pyc} DESTINATION ${DESINATION_DIR})
endforeach()

endmacro(python_install)
3 changes: 0 additions & 3 deletions setup.cfg

This file was deleted.

40 changes: 0 additions & 40 deletions setup.py

This file was deleted.

0 comments on commit 533786b

Please sign in to comment.