[CalendarServer-changes] [15218] OSXFrameworks/trunk/setup.py
source_changes at macosforge.org
source_changes at macosforge.org
Fri Oct 23 12:52:53 PDT 2015
Revision: 15218
http://trac.calendarserver.org//changeset/15218
Author: cdaboo at apple.com
Date: 2015-10-23 12:52:53 -0700 (Fri, 23 Oct 2015)
Log Message:
-----------
Fix pip based setup.
Modified Paths:
--------------
OSXFrameworks/trunk/setup.py
Modified: OSXFrameworks/trunk/setup.py
===================================================================
--- OSXFrameworks/trunk/setup.py 2015-10-23 19:37:48 UTC (rev 15217)
+++ OSXFrameworks/trunk/setup.py 2015-10-23 19:52:53 UTC (rev 15218)
@@ -1,22 +1,51 @@
##
-# Copyright (c) 2015 Cyrus Daboo. All rights reserved.
+# Copyright (c) 2015 Apple Inc. All rights reserved.
#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
#
-# http://www.apache.org/licenses/LICENSE-2.0
+# http://www.apache.org/licenses/LICENSE-2.0
#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
##
from distutils.core import setup
-from osx import _corefoundation_cffi_build
+from distutils.command.build import build
+from distutils.command.install import install
+
+# pip imports setup.py prior to doing the actual build and install so it can
+# determine dependency order of modules. The trouble is when it does that, cffi
+# is not actually available, so we are not able to use the
+# ffi.distutils_extension() call to build the extension module list. Instead
+# what we have to do is override the L{Build} and L{Install} setup.py commands
+# to lazily add the extension module list during execution of those commands
+# only (i.e., not during the initial pip import).
+
+def get_ext_modules():
+ from osx import _corefoundation_cffi_build
+ return [_corefoundation_cffi_build.ffi.distutils_extension()]
+
+
+
+class LazyBuild(build):
+ def finalize_options(self):
+ self.distribution.ext_modules = get_ext_modules()
+ build.finalize_options(self)
+
+
+
+class LazyInstall(install):
+ def finalize_options(self):
+ self.distribution.ext_modules = get_ext_modules()
+ install.finalize_options(self)
+
+
setup(
name="OSXFrameworks",
version="0.1",
@@ -29,7 +58,10 @@
'osx.frameworks',
],
ext_package="osx",
- ext_modules=[_corefoundation_cffi_build.ffi.distutils_extension()],
setup_requires=["cffi>=1.3.0"],
install_requires=["cffi>=1.3.0"],
+ cmdclass={
+ "build": LazyBuild,
+ "install": LazyInstall,
+ }
)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20151023/e08484ea/attachment.html>
More information about the calendarserver-changes
mailing list