Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Commit

Permalink
Fix build errors due to import order.
Browse files Browse the repository at this point in the history
Parse __init__.py to find the version number instead of loading googleclouddebugger in setup.py. The native dependencies get built as part of the last stage of setup, so it's not safe to import the library anywhere in setup.py.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=113971723
  • Loading branch information
b-daniels committed Feb 9, 2016
1 parent 5c50e97 commit 229a80d
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@

"""Python Cloud Debugger build and packaging script."""

import ConfigParser
from glob import glob
import os
import ConfigParser

from setuptools import setup, Extension
import re
from distutils import sysconfig
import googleclouddebugger
from setuptools import Extension
from setuptools import setup


def RemovePrefixes(optlist, bad_prefixes):
Expand Down Expand Up @@ -69,6 +69,20 @@ def ReadConfig(section, value, default):
cvars.get('OPT').split(),
['-g', '-O', '-Wstrict-prototypes']))

# Determine the current version of the package. The easiest way would be to
# import "googleclouddebugger" and read its __version__ attribute.
# Unfortunately we can't do that because "googleclouddebugger" depends on
# "cdbg_native" that hasn't been built yet.
version = None
with open('googleclouddebugger/__init__.py', 'r') as init_file:
version_pattern = re.compile(r"^\s*__version__\s*=\s*'([0-9.]*)'")
for line in init_file:
match = version_pattern.match(line)
if match:
version = match.groups()[0]
print 'clouddebugger module version is {0}'.format(version)
assert version

cdbg_native_module = Extension(
'googleclouddebugger.cdbg_native',
sources=glob('googleclouddebugger/*.cc'),
Expand All @@ -87,11 +101,11 @@ def ReadConfig(section, value, default):
long_description=LONG_DESCRIPTION,
url='https://github.com/GoogleCloudPlatform/cloud-debug-python',
author='Google Inc.',
version=googleclouddebugger.__version__,
version=version,
install_requires=['google-api-python-client'],
packages=['googleclouddebugger'],
ext_modules=[cdbg_native_module],
license="Apache License, Version 2.0",
license='Apache License, Version 2.0',
keywords='google cloud debugger',
classifiers=[
'Programming Language :: Python :: 2.7',
Expand Down

0 comments on commit 229a80d

Please sign in to comment.