Repository: rucio/rucio

Issue:
setup.py and setup_rucio.py should be the same file
Modification
------------
setup.py and setup_rucio.py should be the same file


Discussion:

Resolving patch:
diff --git a/setup_rucio.py b/setup_rucio.py
--- a/setup_rucio.py
+++ b/setup_rucio.py
@@ -1,13 +1,27 @@
-# Copyright European Organization for Nuclear Research (CERN)
+# Copyright 2012-2018 CERN for the benefit of the ATLAS collaboration.
 #
 # 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
+# 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.
 #
 # Authors:
-# - Vincent Garonne, <vincent.garonne@cern.ch>, 2011-2017
-# - Mario Lassnig, <mario.lassnig@cern.ch>, 2012-2013
-# - Martin Barisits, <martin.barisits@cern.ch>, 2016-2017
+# - Mario Lassnig <mario.lassnig@cern.ch>, 2012-2014
+# - Vincent Garonne <vgaronne@gmail.com>, 2012-2018
+# - Martin Barisits <martin.barisits@cern.ch>, 2012-2017
+# - Wen Guan <wguan.icedew@gmail.com>, 2014
+# - Thomas Beermann <thomas.beermann@cern.ch>, 2014
+
+'''
+Setup.py which moves kerberos modules in extra dependencies to be buildthedocs compliant.
+'''
 
 import glob
 import os
@@ -27,7 +41,6 @@
 
 try:
     from setuptools import setup, find_packages
-#    from setuptools.command.sdist import sdist
 except ImportError:
     from ez_setup import use_setuptools
     use_setuptools()
@@ -48,15 +61,51 @@
 
 scripts = glob.glob('bin/rucio*')
 
-# Arguments to the setup script to build stable release
 copy_args = sys.argv[1:]
 if '--release' in copy_args:
     IsRelease = True
     copy_args.remove('--release')
 
-# If Sphinx is installed on the box running setup.py,
-# enable setup.py to build the documentation, otherwise,
-# just ignore it
+# Flags to know if the installation is done through pip and against git
+using_pip = os.path.basename(os.path.dirname(__file__)).startswith('pip-')
+using_git = os.path.isdir('.git')
+
+
+def run_git_command(cmd):
+    """
+    Run a git command in path and return output"
+
+    :param cmd: the git command.
+    :return: Output of the git command.
+    """
+    output = subprocess.Popen(["/bin/sh", "-c", cmd], stdout=subprocess.PIPE)
+    return output.communicate()[0].strip()
+
+
+if using_pip and using_git:
+    git_version_cmd = '''git describe --dirty=-dev`date +%s`'''
+    pkg_version = run_git_command(git_version_cmd)
+    branch_nick_cmd = 'git branch | grep -Ei "\* (.*)" | cut -f2 -d" "'
+    branch_nick = run_git_command(branch_nick_cmd)
+    revid_cmd = "git rev-parse HEAD"
+    revid = run_git_command(revid_cmd)
+    revno_cmd = "git --no-pager log --oneline | wc -l"
+    revno = run_git_command(revno_cmd)
+    version_file = open("lib/rucio/vcsversion.py", 'w')
+    version_file.write("""'''\n"""
+                       """This file is automatically generated by setup.py, So don't edit it. :)\n"""
+                       """'''\n"""
+                       """VERSION_INFO = {\n"""
+                       """    'final': False,\n"""
+                       """    'version': '%s',\n"""
+                       """    'branch_nick': '%s',\n"""
+                       """    'revision_id': '%s',\n"""
+                       """    'revno': %s\n"""
+                       """}""" % (pkg_version, branch_nick, revid, revno))
+    version_file.close()
+else:
+    pkg_version = version.version_string()
+
 cmdclass = {}
 
 try:
@@ -83,7 +132,9 @@ def parse_requirements(requirements_files):
     requirements = []
     for requirements_file in requirements_files:
         for line in get_reqs_from_file(requirements_file):
-            if re.match(r'\s*-e\s+', line):
+            if 'kerberos' in line:
+                pass
+            elif re.match(r'\s*-e\s+', line):
                 requirements.append(re.sub(r'\s*-e\s+.*#egg=(.*)$', r'\1', line))
             elif re.match(r'\s*-f\s+', line):
                 pass
@@ -116,12 +167,12 @@ def write_requirements():
 oracle_extras = ['cx_oracle>=5.1']
 postgresql_extras = ['psycopg2>=2.4.2']
 mysql_extras = ['PyMySQL']
-
+kerberos_extras = ['kerberos>=1.2.5', 'pykerberos>=1.1.14', 'requests-kerberos>=0.11.0']
 requires = parse_requirements(requirements_files=requirements_files)
 extras_require = dict(oracle=oracle_extras,
                       postgresql=postgresql_extras,
-                      mysql=mysql_extras)
-requires = parse_requirements(requirements_files=requirements_files)
+                      mysql=mysql_extras,
+                      kerberos=kerberos_extras)
 depend_links = parse_dependency_links(requirements_files=requirements_files)
 
 
@@ -145,7 +196,7 @@ def get_file_list(self):
 
 setup(
     name=name,
-    version=version.version_string(),
+    version=pkg_version,
     packages=packages,
     package_dir={'': 'lib'},
     data_files=data_files,


Test patch: