Created
December 27, 2012 13:51
-
-
Save okossuth/4388507 to your computer and use it in GitHub Desktop.
Setup.py and recipe.sh for mechanize
These files can be used when trying to execute ./distribute.sh -m "mechanize kivy" to avoid the lib-dynload/_io.so error
more info here: http://kivy.org/docs/guide/packaging-android.html#packaging-android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
recipe.sh | |
#!/bin/bash | |
VERSION_mechanize= | |
URL_mechanize=http://pypi.python.org/packages/source/m/mechanize/mechanize-0.2.5.tar.gz | |
MD5_mechanize= | |
BUILD_mechanize=$BUILD_PATH/mechanize/$(get_directory $URL_mechanize) | |
RECIPE_mechanize=$RECIPES_PATH/mechanize | |
function prebuild_mechanize() { | |
true | |
} | |
function build_mechanize() { | |
if [ -d "$BUILD_PATH/python-install/lib/python2.7/site-packages/mechanize" ]; then | |
#return | |
true | |
fi | |
cd $BUILD_mechanize | |
push_arm | |
export LDFLAGS="$LDFLAGS -L$LIBS_PATH" | |
export LDSHARED="$LIBLINK" | |
# fake try to be able to cythonize generated files | |
$BUILD_PATH/python-install/bin/python.host setup.py build_ext --inplace --debug | |
try find . -iname '*.pyx' -exec cython {} \; | |
try $BUILD_PATH/python-install/bin/python.host setup.py build_ext -v --inplace --debug | |
try $BUILD_PATH/python-install/bin/python.host setup.py install -O2 #--debug | |
unset LDSHARED | |
pop_arm | |
} | |
function postbuild_mechanize() { | |
true | |
} | |
setup.py: | |
#!/usr/bin/env python | |
# $Id: setup.py 7446 2012-06-17 20:47:10Z grubert $ | |
# Copyright: This file has been placed in the public domain. | |
import sys | |
import os | |
import glob | |
try: | |
from distutils.core import setup, Command | |
from distutils.command.build import build | |
from distutils.command.build_py import build_py | |
from distutils.command.install_data import install_data | |
from distutils.util import convert_path | |
from distutils import log | |
except ImportError: | |
print ('Error: The "distutils" standard module, which is required for the ') | |
print ('installation of mechanize, could not be found. You may need to ') | |
print ('install a package called "python-devel" (or similar) on your ') | |
print ('system using your package manager.') | |
sys.exit(1) | |
class smart_install_data(install_data): | |
# From <http://wiki.python.org/moin/DistutilsInstallDataScattered>, | |
# by Pete Shinners. | |
def run(self): | |
#need to change self.install_dir to the library dir | |
install_cmd = self.get_finalized_command('install') | |
self.install_dir = getattr(install_cmd, 'install_lib') | |
return install_data.run(self) | |
class build_data(Command): | |
def initialize_options(self): | |
pass | |
def finalize_options(self): | |
pass | |
def run(self): | |
build_py = self.get_finalized_command('build_py') | |
#data_files = self.distribution.data_files | |
#for f in data_files: | |
# dir = convert_path(f[0]) | |
# dir = os.path.join(build_py.build_lib, dir) | |
# self.mkpath(dir) | |
# for data in f[1]: | |
# data = convert_path(data) | |
# self.copy_file(data, dir) | |
# let our build_data run | |
build.sub_commands.append(('build_data', lambda *a: True)) | |
def do_setup(): | |
kwargs = package_data.copy() | |
kwargs['classifiers'] = classifiers | |
# Install data files properly. | |
kwargs['cmdclass'] = {'build_data': build_data, | |
'install_data': smart_install_data} | |
# Auto-convert source code for Python 3 | |
#if sys.version_info >= (3,): | |
# kwargs['cmdclass']['build_py'] = copy_build_py_2to3 | |
#else: | |
kwargs['cmdclass']['build_py'] = build_py | |
dist = setup(**kwargs) | |
return dist | |
#s5_theme_files = [] | |
#for dir in glob.glob('docutils/writers/s5_html/themes/*'): | |
# if os.path.isdir(dir): | |
# theme_files = glob.glob('%s/*' % dir) | |
# s5_theme_files.append((dir, theme_files)) | |
package_data = { | |
'name': 'mechanize', | |
'description': 'Mechanize -- Python Mechanize Web Crawler', | |
'long_description': """\ | |
Mechanize is a Python library for web crawling purposes.""", # wrap at col 60 | |
'url':'http://wwwsearch.sourceforge.net/mechanize/', | |
'version': '0.2.5', | |
'author': 'John J.Lee', | |
'author_email': 'jjl@pobox.com', | |
'license': 'public domain, Python, 2-Clause BSD, GPL 3 (see COPYING.txt)', | |
'platforms': 'OS-independent', | |
# 'package_dir': {'docutils': 'docutils', | |
# 'docutils.tools': 'tools'}, | |
'packages': ['mechanize', | |
],} | |
"""Distutils setup parameters.""" | |
classifiers = [ | |
'Development Status :: 5 - Production/Stable', | |
'Intended Audience :: Developers', | |
'Intended Audience :: System Administrators', | |
'License :: OSI Approved :: BSD License', | |
'Natural Language :: English', | |
'Operating System :: OS Independent', | |
'Programming Language :: Python', | |
'Programming Language :: Python :: 2', | |
'Programming Language :: Python :: 2.7', | |
'Topic :: Internet', | |
'Topic :: Internet :: WWW/HTTP :: Site Management :: Link Checking', | |
'Topic :: Text Processing :: Markup', | |
'Topic :: Text Processing :: Markup :: HTML', | |
'Topic :: Text Processing :: Markup :: XML', | |
] | |
# BUG pypi did not like fllowing languages | |
# 'Natural Language :: Lithuanian', | |
"""Trove classifiers for the Distutils "register" command; | |
Python 2.3 and up.""" | |
if __name__ == '__main__' : | |
do_setup() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment