1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
#
# ====================================================================
# (c) 2005-2009 Barry A Scott. All rights reserved.
#
# This software is licensed as described in the file LICENSE.txt,
# which you should have received as part of this distribution.
#
# ====================================================================
#
#
# setup.py
#
# Handles creation of Python eggs, wheels, and source distributions.
#
# To build a source distribution, run:
#
# $ python setup.py sdist
#
# To build an egg, run:
#
# $ python setup.py bdist_egg
#
# To build a wheel, make sure you have the wheel package
# (`pip install wheel`). This is available on newer systems by defaul.
# Then run:
#
# $ python setup.py bdist_wheel
#
# These can all be built and uploaded to PyPI in one command:
#
# $ python setup.py sdist bdist_egg bdist_wheel upload
#
# Subsequent native eggs and wheels can be uploaded to PyPI with:
#
# $ python setup.py bdist_egg bdist_wheel upload
#
import setuptools
import sysconfig
import platform
import shutil
import sys
import os
import os.path
from setuptools.command.build_ext import build_ext
pysvn_version_info = {}
f = open( 'Builder/version.info', 'r' )
for line in f:
key, value = line.strip().split('=')
pysvn_version_info[ key ] = value
name = "pysvn"
_pysvn_soname = '_pysvn_%d_%d' % sys.version_info[:2]
class BuildExtensions(build_ext):
"""Builds the packages using the PySVN Makefile build system.
This overrides the Python builder's build_ext command, invoking the
Makefile build system to compile the deliverable pysvn/ directory. It
then installs the deliverables to the right place so that they can be
included in the package.
By going through the build_ext route, the Python packaging infrastructure
will generate compiled eggs/wheels that only install on systems compatible
with the compiled pysvn.so. pip/easy_install will locate and install a
compatible build, falling back on automatically compiling the source
distribution.
"""
def build_extension( self, ext ):
if ext.name == _pysvn_soname:
self._build_pysvn( ext )
else:
super( BuildExtensions, self ).build_extension( ext )
def _build_pysvn( self, ext ):
dest_dir = os.path.join( os.path.abspath( self.build_lib ), 'pysvn' )
# Generate metadata first
self.run_command( "egg_info" )
if platform.system() == 'Darwin':
# For Mac, figure out the major.minor version of the OS, and
# pass that information to the build system.
os.putenv( 'MACOSX_DEPLOYMENT_TARGET',
'.'.join( platform.mac_ver()[ 0 ].split( '.' )[ :2 ] ) )
# Invoke the build system. This will generate the __init__.py and
# .so that we'll package.
os.chdir( 'Source' )
os.system( sys.executable + ' setup.py configure' )
os.system( 'make clean' )
os.system( 'make' )
# Copy the built files to the destination pysvn/ directory.
self.mkpath( dest_dir )
shutil.copy( os.path.join( 'pysvn', '__init__.py' ), dest_dir )
shutil.copy( os.path.join( 'pysvn', '%s.so' % _pysvn_soname ),
dest_dir )
# We're done. Restore the working directory.
os.chdir( '..' )
setuptools.setup(
name = name,
version='%(MAJOR)s.%(MINOR)s.%(PATCH)s' % pysvn_version_info,
author="Barry Scott",
author_email="barry@barrys-emacs.org",
description="Subversion support for Python",
long_description="",
url="https://pysvn.sourceforge.io",
license="Apache Software License",
keywords="subversion",
include_package_data=True,
zip_safe=False,
cmdclass={
'build_ext': BuildExtensions,
},
ext_modules = [
setuptools.Extension(
_pysvn_soname, []) # This used to tell setuptools that
# there is native extension, but
# they're not build using setuptools.
],
classifiers=[
"Topic :: Software Development :: Version Control",
],
)
|