Skip to content

Commit

Permalink
Fixes #153:
Browse files Browse the repository at this point in the history
* moved configuration from setup.py to setup.py.in and force Makefile to create setup.py
* removed hardcoding from setup and put it in Makedoc
* check for NumPy before building extensions that require it
* updated Makedoc to generate long description and packages
* only import peppy.* if wx is around -- there are things that don't require wx

svn-revision: r295
  • Loading branch information
robmcmullen committed Apr 5, 2007
1 parent 0512b84 commit 88ce9bb
Show file tree
Hide file tree
Showing 5 changed files with 183 additions and 132 deletions.
54 changes: 48 additions & 6 deletions Makedoc.py
Expand Up @@ -14,6 +14,8 @@
'author_email':None,
'url':None,
'description':None,
'long_description': None,
'packages': None,
'cvs_version':None,
'release_version':None,
'version':None,
Expand Down Expand Up @@ -44,6 +46,39 @@ def findChangeLogVersion():
namespace['version']=version
#print namespace

def findLongDescription():
# skip the opening one-line description and grab the first paragraph
# out of the module's docstring to use as the long description.
long_description = ''
lines = module.__doc__.splitlines()
for firstline in range(len(lines)):
# skip until we reach a blank line
if len(lines[firstline])==0 or lines[firstline].isspace():
break
if firstline<len(lines):
firstline+=1
for lastline in range(firstline,len(lines)):
# stop when we reach a blank line
if len(lines[lastline])==0 or lines[lastline].isspace():
break
long_description = " ".join(lines[firstline:lastline])
namespace['long_description'] = long_description

def findPackages():
packages = []

# find packages to be installed
path = os.path.dirname(module.__file__)
def addmodules(arg, dirname, names):
if '__init__.py' in names:
prefix = os.path.commonprefix((path, dirname))
mod = "%s%s" % (module.__name__, dirname[len(prefix):].replace(os.sep,'.'))
if mod not in packages:
packages.append(mod)
os.path.walk(path, addmodules, None)
print "packages = %s" % packages
namespace['packages'] = str(packages)

def findlatest():
files=os.listdir('archive')
timestamp=0
Expand All @@ -70,19 +105,26 @@ def findlatest():
def setnamespace():
if module:
defaults={
'prog':module.__name__,
'author':module.__author__,
'author_email':module.__author_email__,
'url':module.__url__,
'description':module.__description__,
'prog':'__name__',
'author':'__author__',
'author_email':'__author_email__',
'url':'__url__',
'download_url':'__download_url__',
'description':'__description__',
'license': '__license__',
'keywords': '__keywords__',
'coconuts': '__sir_not_appearing_in_this_film__',
}

for key,val in defaults.iteritems():
namespace[key]=val
if hasattr(module, val):
namespace[key]=getattr(module, val)
# print "%s=%s" % (key,val)

# findlatest()
findChangeLogVersion()
findLongDescription()
findPackages()

if int(namespace['yearstart'])<int(namespace['year']):
namespace['yearrange']=namespace['yearstart']+'-'+namespace['year']
Expand Down
14 changes: 8 additions & 6 deletions Makefile
Expand Up @@ -28,9 +28,8 @@ WINBATCH = peppy.bat
SCRIPTMAIN = scripts/peppy
DISTMAIN = peppy/__init__.py

SVN_LIST = $(shell svn ls -R)
#SVN_LIST = AUTHORS ChangeLog FAQ INSTALL.pre.in LICENSE Makedoc.py Makefile NEWS README.pre.in THANKS TODO demo/ demo/__init__.py demo/actions.py demo/auitest.py demo/ngmenu.py demo/samplewidgets.py docs/ docs/README docs/api/ peppy/ peppy/__init__.py peppy/actions/ peppy/actions/__init__.py peppy/actions/gotoline.py peppy/actions/minibuffer.py peppy/actions/pypefind.py peppy/buffers.py peppy/configprefs.py peppy/debug.py peppy/dialogs.py peppy/icons/ peppy/icons/application.png peppy/icons/application_xp_terminal.png peppy/icons/arrow_turn_left.png peppy/icons/arrow_turn_right.png peppy/icons/blank.ico peppy/icons/bug_add.png peppy/icons/cross.png peppy/icons/cut.png peppy/icons/disk.png peppy/icons/disk_edit.png peppy/icons/folder_image.png peppy/icons/folder_page.png peppy/icons/green.gif peppy/icons/html.png peppy/icons/image.png peppy/icons/map_magnify.png peppy/icons/page.png peppy/icons/page_copy.png peppy/icons/page_white.png peppy/icons/page_white_c.png peppy/icons/page_white_cplusplus.png peppy/icons/page_white_picture.png peppy/icons/page_white_text.png peppy/icons/page_white_tux.png peppy/icons/paste_plain.png peppy/icons/picture.png peppy/icons/py.ico peppy/icons/red.gif peppy/icons/text_indent_remove_rob.png peppy/icons/text_indent_rob.png peppy/icons/tux.png peppy/icons/world.png peppy/icons/yellow.gif peppy/iconstorage.py peppy/iofilter.py peppy/main.py peppy/major.py peppy/major_modes/ peppy/major_modes/__init__.py peppy/major_modes/fundamental.py peppy/major_modes/hexedit.py peppy/major_modes/image.py peppy/major_modes/python.py peppy/major_modes/shell.py peppy/menu.py peppy/minor.py peppy/minor_modes/ peppy/minor_modes/__init__.py peppy/minor_modes/funclist.py peppy/minor_modes/sizereporter.py peppy/nltk_lite/ peppy/nltk_lite/__init__.py peppy/nltk_lite/chat/ peppy/nltk_lite/chat/__init__.py peppy/nltk_lite/chat/eliza.py peppy/nltk_lite/chat/iesha.py peppy/nltk_lite/chat/nltk_lite/ peppy/nltk_lite/chat/nltk_lite/__init__.py peppy/nltk_lite/chat/nltk_lite/chat.py peppy/nltk_lite/chat/rude.py peppy/nltk_lite/chat/zen.py peppy/orderer.py peppy/plugins/ peppy/plugins/__init__.py peppy/plugins/about.py peppy/plugins/chatbots.py peppy/plugins/filebrowser.py peppy/plugins/openrecent.py peppy/plugins/pype_compat.py peppy/pype/ peppy/pype/__init__.py peppy/pype/browser.py peppy/pype/codetree.py peppy/pype/exparse.py peppy/pype/filehistory.py peppy/pype/findbar.py peppy/pype/parsers.py peppy/stcinterface.py peppy/trac/ peppy/trac/__init__.py peppy/trac/core.py peppy/wxemacskeybindings.py peppy.bat peppy.py setup.py tests/ tests/test_configprefs.py tests/test_iofilter.py tests/test_majormode.py tests/test_orderer.py
SVN_FILTER_OUT := README.pre.in INSTALL.pre.in Makefile Makedoc.py peppy.bat setup.py %/
SVN_LIST = $(shell python svn-ls.py)
SVN_FILTER_OUT := %.in Makefile Makedoc.py peppy.bat setup.py trac/% %/
SVN_FILTERED := $(filter-out $(SVN_FILTER_OUT),$(SVN_LIST))
DISTSRC := $(filter %.py,$(SVN_FILTERED))
DISTFILES := README INSTALL setup.py $(SVN_FILTERED)
Expand Down Expand Up @@ -81,15 +80,18 @@ dist: distdir
$(COMPRESS) $(distdir).tar
-rm -rf $(distdir)

distdir: $(DISTFILES)
distdir:
-rm -rf $(distdir)
mkdir $(distdir)
-chmod 777 $(distdir)
tar cf - $(DISTFILES) | (cd $(distdir); tar xf -)
chmod 644 $(distdir)/tests/*.py
./Makedoc.py -m peppy -o $(distdir)/setup.py setup.py.in
rm $(distdir)/$(DISTMAIN)
./Makedoc.py -m peppy -d -o /tmp/makedoc.tmp $(DISTMAIN)
sed -e "s/svn-devel/$(VERSION)/" /tmp/makedoc.tmp > $(distdir)/$(DISTMAIN)
./Makedoc.py -m peppy -d -o $(distdir)/$(DISTMAIN).tmp $(DISTMAIN)
sed -e "s/svn-devel/$(VERSION)/" $(distdir)/$(DISTMAIN).tmp > $(distdir)/$(DISTMAIN)
rm $(distdir)/$(DISTMAIN).tmp

mkdir $(distdir)/scripts
cp $(distdir)/$(APPMAIN) $(distdir)/$(SCRIPTMAIN)
cp $(WINBATCH) $(distdir)/scripts
Expand Down
47 changes: 28 additions & 19 deletions peppy/__init__.py
Expand Up @@ -45,24 +45,33 @@
__keywords__ = "text editor, wxwindows, scintilla"
__license__ = "GPL"

# Define the common global classes that plugins and extensions should
# need to use
from peppy.buffers import Buffer, BufferHooks, BufferFrame, BufferApp
from peppy.configprefs import *
from peppy.debug import debuglog, dprint, debugmixin
from peppy.major import MajorMode, BufferModificationAction
from peppy.minor import MinorMode, IMinorModeProvider, \
MinorModeIncompatibilityError
__have_wx = True
try:
import wx
except:
# Don't have wx. Still allow peppy to be imported, because there
# are some classes that don't depend on wx
__have_wx = False

from peppy.lib.iconstorage import *
if __have_wx:
# If we have wx, define the common global classes that plugins and
# extensions should need to use
from peppy.buffers import Buffer, BufferHooks, BufferFrame, BufferApp
from peppy.configprefs import *
from peppy.debug import debuglog, dprint, debugmixin
from peppy.major import MajorMode, BufferModificationAction
from peppy.minor import MinorMode, IMinorModeProvider, \
MinorModeIncompatibilityError

__all__ = [
'Buffer', 'BufferHooks', 'BufferFrame', 'BufferApp',
'HomeConfigDir', 'GlobalSettings', 'ClassSettings',
'getSubclassHierarchy',
'debuglog','dprint','debugmixin',
'getIconStorage','getIconBitmap',
'MajorMode', 'BufferModificationAction',
'MinorMode', 'IMinorModeProvider', 'MinorModeIncompatibilityError',
]
#print __all__
from peppy.lib.iconstorage import *

__all__ = [
'Buffer', 'BufferHooks', 'BufferFrame', 'BufferApp',
'HomeConfigDir', 'GlobalSettings', 'ClassSettings',
'getSubclassHierarchy',
'debuglog','dprint','debugmixin',
'getIconStorage','getIconBitmap',
'MajorMode', 'BufferModificationAction',
'MinorMode', 'IMinorModeProvider', 'MinorModeIncompatibilityError',
]
#print __all__
101 changes: 0 additions & 101 deletions setup.py

This file was deleted.

99 changes: 99 additions & 0 deletions setup.py.in
@@ -0,0 +1,99 @@
#!/usr/bin/env python

# Relatively generic setup.py that should be easily tailorable to
# other python modules. It gets most of the parameters from the
# packaged module itself, so this file shouldn't have to be changed
# much.

import os,sys,distutils, glob
from distutils.core import setup, Extension

if sys.version < '2.3':
raise SystemExit('Sorry, peppy requires at least Python 2.3 because wxPython does.')

# ignore a warning about large int constants in Python 2.3.*
if sys.version >= '2.3' and sys.version < '2.4':
import warnings
warnings.filterwarnings('ignore', "hex/oct constants", FutureWarning)


# use windows batch files if we're on windows
scripts = ['scripts/peppy']
from distutils import util
if util.get_platform()[:3] == 'win':
scripts = [script + '.bat' for script in scripts]

# set up extension modules
ext_modules = []
include_dirs = []

# check NumPy support for building the hsi extension module
HAVE_NUMPY=False
try:
import numpy
HAVE_NUMPY=True

# Function to find numpy's include directory
def get_numpy_include():
for directory in sys.path:
d = os.walk(directory)
for i in d:
if 'numpy' in i[0]:
if 'core' in i[0]:
if 'include' in i[0]:
return i[0]
return '.'

numpy_include = get_numpy_include()
print 'numpy include = %s' % numpy_include
if numpy_include =='.':
print "numpy headers were not found! Fast array support will not be enabled."
HAVE_NUMPY=False
else:
include_dirs.append(numpy_include)
numarray_compat = os.path.join(os.path.dirname(os.path.dirname(numpy_include)),'numarray','numpy')
include_dirs.append(numarray_compat)
except ImportError:
pass

if HAVE_NUMPY:
ext_modules.append(Extension('peppy.hsi._utils',
sources = ['peppy/hsi/_utils.c'],
include_dirs = include_dirs,
))

setup(name = '$prog',
version = '$version',
description = '$description',
long_description = '$long_description',
keywords = '$keywords',
license = '$license',
author = '$author',
author_email = '$author_email',
url = '$url',
download_url = '$download_url',
platforms='any',
scripts=scripts,
packages = $packages,
package_data={'peppy': ['icons/*'],
},
ext_modules = ext_modules,

classifiers=['Development Status :: 3 - Alpha',
'Environment :: MacOS X',
'Environment :: Win32 (MS Windows)',
'Environment :: X11 Applications',
'Intended Audience :: Developers',
'Framework :: Trac',
'License :: OSI Approved :: GNU General Public License (GPL)',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Operating System :: POSIX :: Linux',
'Operating System :: Unix',
'Programming Language :: Python',
'Topic :: Software Development :: Documentation',
'Topic :: Text Editors',
'Topic :: Text Editors :: Documentation',
]
)

0 comments on commit 88ce9bb

Please sign in to comment.