This is an automated email from the ASF dual-hosted git repository.

oleewere pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new d06469a  AMBARI-24558. Add setup.py for ambari python packages (for 
using with pip) (#2195)
d06469a is described below

commit d06469a094c9e76c0e9cc6dd490198e24d4965f9
Author: Olivér Szabó <oleew...@gmail.com>
AuthorDate: Thu Aug 30 19:12:13 2018 +0200

    AMBARI-24558. Add setup.py for ambari python packages (for using with pip) 
(#2195)
    
    * AMBARI-24558. Add setup.py for ambari-commons (for pip)
    
    * AMBARI-24558 Add /usr/bin/env python
    
    * AMBARI-24558. Find subpackages + rename module + move setup.py to root
    
    * AMBARI-24558. Add descriptions + .gitignore
    
    * AMBARI-24558. Add descriptions + .gitignore
    
    * AMBARI-24558. Extends default version to __version__ in order to replace 
that during builds.
    
    * AMBARI-24558. Fix last commit
    
    * AMBARI-24558. Add rat check excludes
---
 .gitignore  |  3 +++
 MANIFEST.in | 14 +++++++++++
 pom.xml     |  4 ++++
 setup.py    | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 98 insertions(+)

diff --git a/.gitignore b/.gitignore
index 63de799..7e5a649 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,3 +29,6 @@ createDDL.jdbc
 /contrib/views/storm/src/main/resources/ui/node_modules/
 /contrib/views/storm/src/main/resources/ui/public/
 /contrib/views/storm/src/main/resources/ui/npm-debug.log
+/dist
+/build
+ambari_python.egg-info
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..243a688
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,14 @@
+#   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.
+include ambari-common/src/main/python/ambari_commons/resources/*
+include ambari-common/src/main/python/ambari_commons/libs/**/*.so
+include ambari-common/src/main/python/pluggable_stack_definition/configs/*
diff --git a/pom.xml b/pom.xml
index b4d7df9..61300d6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -372,6 +372,10 @@
             <!-- generated DDL-->
             <exclude>**/createDDL.jdbc</exclude>
             <exclude>**/yarn.lock</exclude>
+
+            <exclude>ambari_python.egg-info/**</exclude>
+            <exclude>dist/**</exclude>
+            <exclude>build/**</exclude>
           </excludes>
         </configuration>
         <executions>
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..836a58e
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,77 @@
+#!/usr/bin/env python
+'''
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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 os
+from os.path import dirname
+from setuptools import find_packages, setup
+
+AMBARI_COMMON_PYTHON_FOLDER = "ambari-common/src/main/python"
+AMBARI_SERVER_TEST_PYTHON_FOLDER = "ambari-server/src/test/python"
+
+def get_ambari_common_packages():
+  return find_packages(AMBARI_COMMON_PYTHON_FOLDER, exclude=["*.tests", 
"*.tests.*", "tests.*", "tests"])
+
+def get_ambari_server_stack_package():
+  return ["stacks.utils"]
+
+def create_package_dir_map():
+  package_dirs = {}
+  ambari_common_packages = get_ambari_common_packages()
+  for ambari_common_package in ambari_common_packages:
+    package_dirs[ambari_common_package] = AMBARI_COMMON_PYTHON_FOLDER + '/' + 
ambari_common_package.replace(".", "/")
+
+  ambari_server_packages = get_ambari_server_stack_package()
+  for ambari_server_package in ambari_server_packages:
+    package_dirs[ambari_server_package] = AMBARI_SERVER_TEST_PYTHON_FOLDER + 
'/' + ambari_server_package.replace(".", "/")
+  return package_dirs
+__version__ = "3.0.0.dev0"
+def get_version():
+  ambari_version = os.environ["AMBARI_VERSION"] if "AMBARI_VERSION" in 
os.environ else __version__
+  print ambari_version
+  return ambari_version
+
+"""
+Example usage:
+- build package with specific version:
+  python setup.py sdist -d "my/dist/location"
+- build and install package with specific version:
+  python setup.py sdist -d "my/dist/location" install
+- build and upload package with specific version:
+  python setup.py sdist -d "my/dist/location" upload -r "http://localhost:8080";
+
+Installing from pip:
+- pip install --extra-index-url=http://localhost:8080 ambari-python==2.7.1  // 
3.0.0.dev0 is the snapshot version
+
+Note: using 'export AMBARI_VERSION=2.7.1' before commands you can redefine the 
package version, but you will need this export during the pip install as well
+"""
+setup(
+  name = "ambari-python",
+  version = get_version(),
+  author = "Apache Software Foundation",
+  author_email = "d...@ambari.apache.org",
+  description = ("Framework for provison/manage/monitor Hadoop clusters"),
+  license = "AP2",
+  keywords = "hadoop, ambari",
+  url = "https://ambari.apache.org";,
+  packages = get_ambari_common_packages() + get_ambari_server_stack_package(),
+  package_dir = create_package_dir_map(),
+  include_package_data = True,
+  long_description="The Apache Ambari project is aimed at making Hadoop 
management simpler by developing software for provisioning, managing, and 
monitoring Apache Hadoop clusters. "
+                   "Ambari provides an intuitive, easy-to-use Hadoop 
management web UI backed by its RESTful APIs."
+)

Reply via email to