Skip to content

Commit 5a039c9

Browse files
setup python lib generation
1 parent 8632a41 commit 5a039c9

File tree

10 files changed

+261
-23
lines changed

10 files changed

+261
-23
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,7 @@ gen-external-apklibs
188188
### Node JS and VuePress
189189
node_modules/.cache
190190
node_modules/vuepress/node_modules
191-
www/.vuepress
191+
www/.vuepres
192+
193+
### Custom Python
194+
dist

install-cpp.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
NC='\033[0m'
4+
RED='\033[0;31m'
5+
GREEN='\033[0;32m'
6+
ORANGE='\033[0;33m'
7+
BLUE='\033[0;34m'
8+
WHITE='\033[0;37m'
9+
10+
APP_NAME='type-cpp'
11+
APP_NAME=${BLUE}${APP_NAME}${NC}
12+
echo -e "=== ${APP_NAME} project ${WHITE}cleanup${NC}" &&
13+
rm -rf build $@ &&
14+
echo -e "=== ${APP_NAME} project ${WHITE}installation${NC}" &&
15+
mkdir build
16+
cd build
17+
cmake ..
18+
make -j install
19+
cd ..
20+
echo -e "=== ${APP_NAME} was ${GREEN}successfully${NC} installed to ${WHITE}${prefix}${NC}"

install-java.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
NC='\033[0m'
4+
RED='\033[0;31m'
5+
GREEN='\033[0;32m'
6+
ORANGE='\033[0;33m'
7+
BLUE='\033[0;34m'
8+
WHITE='\033[0;37m'
9+
10+
APP_NAME='type-java'
11+
APP_NAME=${BLUE}${APP_NAME}${NC}
12+
echo -e "=== ${APP_NAME} project ${WHITE}cleanup${NC}" &&
13+
mvn clean --quiet $@ &&
14+
echo -e "=== ${APP_NAME} project ${WHITE}installation${NC}" &&
15+
mvn install \
16+
-DassembleDirectory=${prefix} \
17+
-DskipTests=true \
18+
-Dmaven.test.skip=true \
19+
-Dlicense.skipAddThirdParty=true \
20+
-Dlicense.skipUpdateProjectLicense=true \
21+
-Dlicense.skipDownloadLicenses \
22+
-Dlicense.skipCheckLicense=true \
23+
-Dmaven.license.skip=true \
24+
--quiet $@ &&
25+
echo -e "=== ${APP_NAME} was ${GREEN}successfully${NC} installed to ${WHITE}${prefix}${NC}"

install-python.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
3+
NC='\033[0m'
4+
RED='\033[0;31m'
5+
GREEN='\033[0;32m'
6+
ORANGE='\033[0;33m'
7+
BLUE='\033[0;34m'
8+
WHITE='\033[0;37m'
9+
10+
APP_NAME='type-python'
11+
APP_NAME=${BLUE}${APP_NAME}${NC}
12+
13+
14+
PYTHON_TEMPLATES="src/main/python"
15+
PROTOBUF_SOURCE="src/main/proto"
16+
PYTHON_SOURCE="target/generated-sources/protobuf/python/org/openbase/type"
17+
18+
PYTHON_DIST="./dist"
19+
PYTHON_DIST_DATA="${PYTHON_DIST}/data"
20+
PYTHON_DIST_SOURCE="${PYTHON_DIST}/openbase_type"
21+
22+
echo -e "=== ${APP_NAME} project ${WHITE}cleanup${NC}" &&
23+
rm -rf ${PYTHON_DIST}
24+
echo -e "=== ${APP_NAME} project ${WHITE}installation${NC}"
25+
26+
# copy python sources and meta
27+
mkdir -p ${PYTHON_DIST_SOURCE}
28+
mkdir -p ${PYTHON_DIST_DATA}
29+
cp -r ${PYTHON_SOURCE}/* ${PYTHON_DIST_SOURCE}/
30+
cp ${PYTHON_TEMPLATES}/* ${PYTHON_DIST}/
31+
cp README.md ACKNOWLEDGMENT.md LICENSE.txt ${PYTHON_DIST}/
32+
33+
# copy raw protobuf types
34+
cp -r ${PROTOBUF_SOURCE} ${PYTHON_DIST_DATA}/
35+
cd ${PYTHON_DIST}
36+
37+
# generate package files
38+
python package-gen.py
39+
40+
# generate source distribution
41+
python setup.py sdist
42+
43+
echo -e "=== ${APP_NAME} was ${GREEN}successfully${NC} installed to ${WHITE}${prefix}${NC}"

install.sh

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,6 @@
11
#!/bin/bash
22

3-
NC='\033[0m'
4-
RED='\033[0;31m'
5-
GREEN='\033[0;32m'
6-
ORANGE='\033[0;33m'
7-
BLUE='\033[0;34m'
8-
WHITE='\033[0;37m'
93

10-
APP_NAME='type'
11-
APP_NAME=${BLUE}${APP_NAME}${NC}
12-
echo -e "=== ${APP_NAME} project ${WHITE}cleanup${NC}" &&
13-
mvn clean --quiet $@ &&
14-
echo -e "=== ${APP_NAME} project ${WHITE}installation${NC}" &&
15-
mvn install \
16-
-DassembleDirectory=${prefix} \
17-
-DskipTests=true \
18-
-Dmaven.test.skip=true \
19-
-Dlicense.skipAddThirdParty=true \
20-
-Dlicense.skipUpdateProjectLicense=true \
21-
-Dlicense.skipDownloadLicenses \
22-
-Dlicense.skipCheckLicense=true \
23-
-Dmaven.license.skip=true \
24-
--quiet $@ &&
25-
echo -e "=== ${APP_NAME} was ${GREEN}successfully${NC} installed to ${WHITE}${prefix}${NC}"
4+
./install-java.sh &&
5+
./install-cpp.sh &&
6+
./install-python.sh

src/main/python/MANIFEST.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include *.md LICENSE.txt .travis.yml
2+
recursive-include src *.proto
3+
recursive-include docs *.md
4+
prune target

src/main/python/package-gen.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from os.path import isdir, walk, join
2+
3+
# generates the python package identification files within the given source folder.
4+
5+
source_folder = "./openbase_type"
6+
finit = '__init__.py'
7+
8+
def visitor(arg, dirname, fnames):
9+
fnames = [fname for fname in fnames if isdir(fname)]
10+
with open(join(dirname, finit), 'w') as file_: file_.write('')
11+
12+
walk(source_folder, visitor, None)

src/main/python/setup.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[bdist_wheel]
2+
universal = 1
3+
4+
[metadata]
5+
license_file = LICENSE.txt
6+
version = v1.0.0

src/main/python/setup.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import codecs
2+
import sys
3+
from setuptools import setup, find_packages
4+
5+
PROTO_SOURCES = "target/generated-sources/protobuf/python"
6+
7+
#with open('src/version.py') as f:
8+
# exec(f.read())
9+
10+
with codecs.open('README.md', 'r', 'utf-8') as f:
11+
# cut the badges from the description and also the TOC which is currently not working on PyPi
12+
long_description = ''.join(f.readlines())
13+
14+
#if len(set(('test', 'easy_install')).intersection(sys.argv)) > 0:
15+
# import setuptools
16+
17+
setup(
18+
name="openbase-type",
19+
version='1.0.0',
20+
description="Type lib",
21+
long_description=long_description,
22+
long_description_content_type="text/markdown",
23+
author='Divine Threepwood',
24+
author_email='[email protected]',
25+
#maintainer='',
26+
#maintainer_email='',
27+
url='https://github.com/openbase/type.git',
28+
#packages=find_packages(where='target/generated-sources/protobuf/python'),
29+
packages=find_packages('openbase_type'),
30+
package_data={'proto': ['data/proto/*']},
31+
package_dir={'':'openbase_type'},
32+
include_package_data=True,
33+
install_requires=['six'],
34+
#extras_require=extras_require,
35+
#tests_require=tests_require,
36+
license='LGPLv3+',
37+
#download_url='https://github.com/xxx/%s.tar.gz' % __version__,
38+
classifiers=[
39+
"Development Status :: 4 - Beta",
40+
"Intended Audience :: Developers",
41+
"Natural Language :: English",
42+
"License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)",
43+
"Operating System :: OS Independent",
44+
"Programming Language :: Python",
45+
"Programming Language :: Python :: 2",
46+
"Programming Language :: Python :: 2.7",
47+
"Programming Language :: Python :: 3",
48+
"Programming Language :: Python :: 3.3",
49+
"Programming Language :: Python :: 3.4",
50+
"Programming Language :: Python :: 3.5",
51+
"Programming Language :: Python :: 3.6",
52+
"Programming Language :: Python :: Implementation :: CPython",
53+
"Programming Language :: Python :: Implementation :: PyPy",
54+
"Topic :: Software Development :: Libraries :: Python Modules",
55+
"Topic :: Home Automation",
56+
"Topic :: Scientific/Engineering :: Artificial Intelligence"
57+
],
58+
#**extra_setuptools_args
59+
)

src/main/python/setup.py.back

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import codecs
2+
import os
3+
import re
4+
5+
from setuptools import setup, find_packages
6+
7+
8+
###################################################################
9+
10+
NAME = "openbase_type"
11+
PROTO_SOURCES = "target/generated-sources/protobuf/python"
12+
PACKAGES = find_packages(where=PROTO_SOURCES)
13+
META_PATH = os.path.join(PROTO_SOURCES, "attr", "__init__.py")
14+
KEYWORDS = ["class", "attribute", "boilerplate"]
15+
CLASSIFIERS = [
16+
"Development Status :: 4 - Beta",
17+
"Intended Audience :: Developers",
18+
"Natural Language :: English",
19+
"License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)",
20+
"Operating System :: OS Independent",
21+
"Programming Language :: Python",
22+
"Programming Language :: Python :: 2",
23+
"Programming Language :: Python :: 2.7",
24+
"Programming Language :: Python :: 3",
25+
"Programming Language :: Python :: 3.3",
26+
"Programming Language :: Python :: 3.4",
27+
"Programming Language :: Python :: 3.5",
28+
"Programming Language :: Python :: 3.6",
29+
"Programming Language :: Python :: Implementation :: CPython",
30+
"Programming Language :: Python :: Implementation :: PyPy",
31+
"Topic :: Software Development :: Libraries :: Python Modules",
32+
"Topic :: Home Automation",
33+
"Topic :: Scientific/Engineering :: Artificial Intelligence"
34+
]
35+
INSTALL_REQUIRES = []
36+
37+
###################################################################
38+
39+
HERE = os.path.abspath(os.path.dirname(__file__))
40+
41+
42+
def read(*parts):
43+
"""
44+
Build an absolute path from *parts* and and return the contents of the
45+
resulting file. Assume UTF-8 encoding.
46+
"""
47+
with codecs.open(os.path.join(HERE, *parts), "rb", "utf-8") as f:
48+
return f.read()
49+
50+
51+
META_FILE = read(META_PATH)
52+
53+
54+
def find_meta(meta):
55+
"""
56+
Extract __*meta*__ from META_FILE.
57+
"""
58+
meta_match = re.search(
59+
r"^__{meta}__ = ['\"]([^'\"]*)['\"]".format(meta=meta),
60+
META_FILE, re.M
61+
)
62+
if meta_match:
63+
return meta_match.group(1)
64+
raise RuntimeError("Unable to find __{meta}__ string.".format(meta=meta))
65+
66+
67+
if __name__ == "__main__":
68+
setup(
69+
name=NAME,
70+
description=find_meta("description"),
71+
license=find_meta("license"),
72+
url=find_meta("uri"),
73+
version=find_meta("version"),
74+
author=find_meta("author"),
75+
author_email=find_meta("email"),
76+
maintainer=find_meta("author"),
77+
maintainer_email=find_meta("email"),
78+
keywords=KEYWORDS,
79+
long_description=read("README.rst"),
80+
packages=PACKAGES,
81+
package_dir={"": "src"},
82+
zip_safe=False,
83+
classifiers=CLASSIFIERS,
84+
install_requires=INSTALL_REQUIRES,
85+
)

0 commit comments

Comments
 (0)