On Fri, 26 Jul 2013 11:53:25 +0900
Satoshi Kobayashi <[email protected]> wrote:

> Hmm do not know for this to be a common way because I otherwise do
> not know the library which requires super user permission.

How about the following?

=
>From baa059f4ef78796415600fa7121733a3554b7532 Mon Sep 17 00:00:00 2001
From: FUJITA Tomonori <[email protected]>
Date: Tue, 30 Jul 2013 17:26:45 +0900
Subject: [PATCH] use d2to1 and pbr for packaging

- distutils2-like setup.cfg files for a package's metadata
- avoid absolute '/etc/ryu/' path for our config file

Signed-off-by: FUJITA Tomonori <[email protected]>
---
 bin/ryu-manager |  6 +++++-
 ryu/hooks.py    | 33 +++++++++++++++++++++++++++++++++
 setup.cfg       | 35 +++++++++++++++++++++++++++++++++++
 setup.py        | 51 ++++-----------------------------------------------
 4 files changed, 77 insertions(+), 48 deletions(-)
 create mode 100644 ryu/hooks.py

diff --git a/bin/ryu-manager b/bin/ryu-manager
index 62188de..cc1ea74 100755
--- a/bin/ryu-manager
+++ b/bin/ryu-manager
@@ -53,7 +53,11 @@ CONF.register_cli_opts([
 
 
 def main():
-    CONF(project='ryu', version='ryu-manager %s' % version)
+    try:
+        CONF(project='ryu', version='ryu-manager %s' % version,
+             default_config_files=['/usr/local/etc/ryu/ryu.conf'])
+    except cfg.ConfigFilesNotFoundError:
+        CONF(project='ryu', version='ryu-manager %s' % version)
 
     log.init_log()
 
diff --git a/ryu/hooks.py b/ryu/hooks.py
new file mode 100644
index 0000000..c2414cd
--- /dev/null
+++ b/ryu/hooks.py
@@ -0,0 +1,33 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 Hewlett-Packard Development Company, L.P.
+# 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
+#
+#      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.
+
+import sys
+from ryu import version
+
+
+def setup_hook(config):
+    """Filter config parsed from a setup.cfg to inject our defaults."""
+    metadata = config['metadata']
+    if sys.platform == 'win32':
+        requires = metadata.get('requires_dist', list()).split('\n')
+        requires.append('pywin32')
+        requires.append('wmi')
+        requires.remove('pyudev')
+        metadata['requires_dist'] = "\n".join(requires)
+    config['metadata'] = metadata
+
+    metadata['version'] = str(version)
diff --git a/setup.cfg b/setup.cfg
index 1cbeedd..e5a3803 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,3 +1,33 @@
+[metadata]
+name = ryu
+summary = Component-based Software-defined Networking Framework
+license = Apache License 2.0
+author = Ryu project team
+author-email = [email protected]
+home-page = http://osrg.github.io/ryu/
+description-file = README.rst
+platform = any
+classifier =
+    Development Status :: 5 - Production/Stable
+    License :: OSI Approved :: Apache Software License
+    Topic :: System :: Networking
+    Natural Language :: English
+    Programming Language :: Python
+    Operating System :: Unix
+keywords =
+    openflow
+    openvswitch
+    openstack
+
+[files]
+packages =
+    ryu
+data_files =
+    etc/ryu =
+        etc/ryu/ryu.conf
+scripts =
+    bin/ryu-manager
+
 [build_sphinx]
 all_files = 1
 build-dir = doc/build
@@ -12,3 +42,8 @@ doc_files = LICENSE
             README.rst
             SubmittingPatches.rst
             doc/
+
+[global]
+setup-hooks =
+    pbr.hooks.setup_hook
+    ryu.hooks.setup_hook
diff --git a/setup.py b/setup.py
index 55c2660..a613f3f 100644
--- a/setup.py
+++ b/setup.py
@@ -14,52 +14,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import sys
+import setuptools
 
-from setuptools import find_packages
-from setuptools import setup
 
-from ryu import version
-from ryu import utils
-
-requires = utils.parse_requirements()
-
-doing_bdist = any(arg.startswith('bdist') for arg in sys.argv[1:])
-
-long_description = open('README.rst').read() + '\n\n'
-
-if doing_bdist:
-    start = long_description.find('=\n') + 2
-    long_description = long_description[
-        start:long_description.find('\n\n\n', start)]
-
-classifiers = [
-    'Development Status :: 5 - Production/Stable',
-    'License :: OSI Approved :: Apache Software License',
-    'Topic :: System :: Networking',
-    'Natural Language :: English',
-    'Programming Language :: Python',
-    'Operating System :: Unix',
-]
-
-if sys.platform == 'win32':
-    data_files = [('etc/ryu', ['etc/ryu/ryu.conf'])]
-else:
-    data_files = [('/etc/ryu', ['etc/ryu/ryu.conf'])]
-
-setup(name='ryu',
-      version=version,
-      description=("Ryu Network Operating System"),
-      long_description=long_description,
-      classifiers=classifiers,
-      keywords='openflow openvswitch openstack',
-      url='http://osrg.github.io/ryu/',
-      author='Ryu project team',
-      author_email='[email protected]',
-      install_requires=requires,
-      license='Apache License 2.0',
-      packages=find_packages(),
-      scripts=['bin/ryu-manager', ],
-      data_files=data_files,
-      include_package_data=True,
-      )
+setuptools.setup(name='ryu',
+                 setup_requires=['d2to1', 'pbr'],
+                 d2to1=True)
-- 
1.7.12.4 (Apple Git-37)


------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent 
caught up. So what steps can you take to put your SQL databases under 
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to