Browse files

drop python module installer cuz it can't do what I want... use cmake…

… instead
  • Loading branch information...
1 parent c885fab commit 533786b23327208431f2af25fe029a4cde209925 @zaufi committed Jun 10, 2012
Showing with 114 additions and 76 deletions.
  1. +2 −26 .gitignore
  2. +35 −0 CMakeLists.txt
  3. +0 −5 MANIFEST.in
  4. +2 −2 README.md
  5. +4 −0 cmake/PythonCompile.py
  6. +71 −0 cmake/PythonMacros.cmake
  7. +0 −3 setup.cfg
  8. +0 −40 setup.py
View
28 .gitignore
@@ -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
View
35 CMakeLists.txt
@@ -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}
+ )
View
5 MANIFEST.in
@@ -1,5 +0,0 @@
-include README.md
-include CHANGES.md
-include *.py
-recursive-include expand *.py
-recursive-include expand *.expand
View
4 README.md
@@ -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.
View
4 cmake/PythonCompile.py
@@ -0,0 +1,4 @@
+# By Simon Edwards <simon@simonzone.com>
+# This file is in the public domain.
+import py_compile
+py_compile.main()
View
71 cmake/PythonMacros.cmake
@@ -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)
View
3 setup.cfg
@@ -1,3 +0,0 @@
-[install]
-install-lib=/usr/share/apps/kate/pate
-install-data=/usr/share/doc/kate-pate-plugins
View
40 setup.py
@@ -1,40 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright (c) 2012 by Alex Turbov <i.zaufi@gmail.com>
-#
-# This software is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This software is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this software. If not, see <http://www.gnu.org/licenses/>.
-
-from setuptools import setup
-
-setup(
- name = 'kate-pate-plugins'
- , version = '0.5'
- , description = 'Kate+Pâté plugins (mostly for C++)'
- , author = 'Alex Turbov'
- , author_email = 'i.zaufi@gmail.com'
- , url = 'https://github.com/zaufi/kate-pate-plugins/'
- , license = 'GPL-3'
- , keywords = ['kate', 'pate']
- , packages = ['libkatepate']
- , py_modules = ['format', 'commentar', 'block']
- , data_files = ['README.md', 'CHANGES.md']
- , requires = ['kate']
- , classifiers = [
- "Development Status :: 4 - Beta"
- , "Environment :: Plugins"
- , "Intended Audience :: Developers"
- , "Natural Language :: English"
- , "Programming Language :: Python :: 2.7"
- , "Topic :: Software Development"
- ]
- )

0 comments on commit 533786b

Please sign in to comment.