Skip to content

Commit

Permalink
BUG: fix up setup.py and pavement.py so the binary builds work again.
Browse files Browse the repository at this point in the history
  • Loading branch information
rgommers committed Mar 4, 2011
1 parent 578cbb4 commit 13212a5
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 20 deletions.
33 changes: 26 additions & 7 deletions pavement.py
Expand Up @@ -223,7 +223,15 @@ def copy_bdist(arch):
os.remove(target)
if not os.path.exists(os.path.dirname(target)):
os.makedirs(os.path.dirname(target))
os.rename(source, target)
try:
os.rename(source, target)
except OSError:
# When git is installed on OS X but not under Wine, the name of the
# .exe has "-Unknown" in it instead of the correct git revision.
# Try to fix this here:
revidx = source.index(".dev-") + 5
gitrev = source[revidx:revidx+7]
os.rename(source.replace(gitrev, "Unknown"), target)

bdist_wininst_arch(pyver, 'nosse')
copy_bdist("nosse")
Expand Down Expand Up @@ -390,11 +398,20 @@ def macosx_version():

def mpkg_name(pyver):
maj, min = macosx_version()[:2]
# Note that bdist_mpkg breaks this if building a dev version with a git
# commit string attached. make_fullplatcomponents() in
# bdist_mpkg/cmd_bdist_mpkg.py replaces '-' with '_', comment this out if
# needed.
return "numpy-%s-py%s-macosx%s.%s.mpkg" % (FULLVERSION, pyver, maj, min)

def _build_mpkg(pyver):
ldflags = "-undefined dynamic_lookup -bundle -arch i386 -arch ppc -Wl,-search_paths_first"
# account for differences between Python 2.7.1 versions from python.org
if os.environ.get('MACOSX_DEPLOYMENT_TARGET', None) == "10.6":
ldflags = "-undefined dynamic_lookup -bundle -arch i386 -arch x86_64 -Wl,-search_paths_first"
else:
ldflags = "-undefined dynamic_lookup -bundle -arch i386 -arch ppc -Wl,-search_paths_first"
ldflags += " -L%s" % os.path.join(os.path.dirname(__file__), "build")

if pyver == "2.5":
sh("CC=gcc-4.0 LDFLAGS='%s' %s setupegg.py bdist_mpkg" % (ldflags, " ".join(MPKG_PYTHON[pyver])))
else:
Expand Down Expand Up @@ -440,7 +457,6 @@ def _create_dmg(pyver, src_dir, volname=None):
sh(" ".join(cmd))

@task
@needs("pdf")
@cmdopts([("python-version=", "p", "python version")])
def dmg(options):
try:
Expand All @@ -449,11 +465,17 @@ def dmg(options):
pyver = DEFAULT_PYTHON
idirs = options.installers.installersdir

# Check if docs exist. If not, say so and quit.
ref = os.path.join(options.doc.destdir_pdf, "reference.pdf")
user = os.path.join(options.doc.destdir_pdf, "userguide.pdf")
if (not os.path.exists(ref)) or (not os.path.exists(user)):
warnings.warn("Docs need to be built first! Can't find them.")

# Build the mpkg package
call_task("clean")
_build_mpkg(pyver)

macosx_installer_dir = "tools/numpy-macosx-installer"

dmg = os.path.join(macosx_installer_dir, dmg_name(FULLVERSION, pyver))
if os.path.exists(dmg):
os.remove(dmg)
Expand All @@ -474,10 +496,7 @@ def dmg(options):
if os.path.exists(pdf_docs):
shutil.rmtree(pdf_docs)
os.makedirs(pdf_docs)

user = os.path.join(options.doc.destdir_pdf, "userguide.pdf")
shutil.copy(user, os.path.join(pdf_docs, "userguide.pdf"))
ref = os.path.join(options.doc.destdir_pdf, "reference.pdf")
shutil.copy(ref, os.path.join(pdf_docs, "reference.pdf"))

# Build the dmg
Expand Down
3 changes: 3 additions & 0 deletions release.sh
Expand Up @@ -5,10 +5,13 @@
# downloads, i.e. two versions for Python 2.7. The Intel 32/64-bit version is
# for OS X 10.6+, the other dmg installers are for 10.3+ and are built on 10.5

# bootstrap needed to ensure we build the docs from the right scipy version
paver bootstrap
source bootstrap/bin/activate
python setupsconsegg.py install

# build docs
paver pdf

#------------------------------------------------------------------
# Build tarballs, Windows and 64-bit OS X installers (on OS X 10.6)
Expand Down
28 changes: 15 additions & 13 deletions setup.py
Expand Up @@ -94,6 +94,20 @@ def _minimal_ext_cmd(cmd):
# a lot more robust than what was previously being used.
builtins.__NUMPY_SETUP__ = True

# Construct full version info. Needs to be in setup.py namespace, otherwise it
# can't be accessed from pavement.py at build time.
FULLVERSION = VERSION
if not ISRELEASED:
if os.path.exists('.git'):
GIT_REVISION = git_version()
elif os.path.exists('numpy/version.py'):
# must be a source distribution, use existing version file
from numpy.version import git_revision as GIT_REVISION
else:
GIT_REVISION = "Unknown"

FULLVERSION += '.dev-' + GIT_REVISION[:7]

def write_version_py(filename='numpy/version.py'):
cnt = """
# THIS FILE IS GENERATED FROM NUMPY SETUP.PY
Expand All @@ -106,22 +120,10 @@ def write_version_py(filename='numpy/version.py'):
if not release:
version = full_version
"""
FULL_VERSION = VERSION
if not ISRELEASED:
if os.path.exists('.git'):
GIT_REVISION = git_version()
elif os.path.exists(filename):
# must be a source distribution, use existing version file
from numpy.version import git_revision as GIT_REVISION
else:
GIT_REVISION = "Unknown"

FULL_VERSION += '.dev-' + GIT_REVISION[:7]

a = open(filename, 'w')
try:
a.write(cnt % {'version': VERSION,
'full_version' : FULL_VERSION,
'full_version' : FULLVERSION,
'git_revision' : GIT_REVISION,
'isrelease': str(ISRELEASED)})
finally:
Expand Down

0 comments on commit 13212a5

Please sign in to comment.