Skip to content

Commit 00bad94

Browse files
authored
Merge pull request #2 from seanpmorgan/directory-structure
Directory Structure
2 parents 20635ad + 199432b commit 00bad94

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2177
-6
lines changed

.gitignore

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
27+
# Jupyter Notebook
28+
.ipynb_checkpoints
29+
30+
# IDE
31+
.vscode/
32+
.idea/
33+
34+
# Build
35+
/.bazelrc
36+
/bazel-*
37+
/artifacts

BUILD

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
sh_binary(
2+
name = "build_pip_pkg",
3+
srcs = ["build_pip_pkg.sh"],
4+
data = [
5+
"LICENSE",
6+
"MANIFEST.in",
7+
"setup.py",
8+
"tensorflow_addons/__init__.py",
9+
"//tensorflow_addons/layers:layers_py",
10+
"//tensorflow_addons/text:text_py",
11+
],
12+
)

CONTRIBUTING.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Want to contribute? Great! First, read this page (including the small print at the end).
2+
3+
### Before you contribute
4+
5+
Before we can use your code, you must sign the
6+
[Google Individual Contributor License Agreement]
7+
(https://cla.developers.google.com/about/google-individual)
8+
(CLA), which you can do online. The CLA is necessary mainly because you own the
9+
copyright to your changes, even after your contribution becomes part of our
10+
codebase, so we need your permission to use and distribute your code. We also
11+
need to be sure of various other things—for instance that you'll tell us if you
12+
know that your code infringes on other people's patents. You don't have to sign
13+
the CLA until after you've submitted your code for review and a member has
14+
approved it, but you must do it before we can put your code into our codebase.
15+
Before you start working on a larger contribution, you should get in touch with
16+
us first through the issue tracker with your idea so that we can help out and
17+
possibly guide you. Coordinating up front makes it much easier to avoid
18+
frustration later on.
19+
20+
### Code reviews
21+
22+
All submissions, including submissions by project members, require review. We
23+
use Github pull requests for this purpose.
24+
25+
### The small print
26+
27+
Contributions made by corporations are covered by a different agreement than
28+
the one above, the
29+
[Software Grant and Corporate Contributor License Agreement]
30+
(https://cla.developers.google.com/about/google-corporate).

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ Copyright 2018 The TensorFlow Authors. All rights reserved.
188188
same "printed page" as the copyright notice for easier
189189
identification within third-party archives.
190190

191-
Copyright 2017, The TensorFlow Authors.
191+
Copyright 2019, The TensorFlow Authors.
192192

193193
Licensed under the Apache License, Version 2.0 (the "License");
194194
you may not use this file except in compliance with the License.

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
recursive-include tensorflow_addons/ *.so

README.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,27 @@ The tensorflow/addons repository, will contain additional functionality fitting
1616
* The addon is useful for a large number of users (e.g., an implementation used in widely cited paper, or a utility with broad applicability)
1717

1818

19-
---
19+
# Developing
2020

21-
<br><br>
22-
<div align="center">
23-
<img src ="https://cdn.pixabay.com/photo/2017/06/16/07/26/under-construction-2408062_640.png" />
24-
</div>
21+
## Docker
22+
```
23+
docker run --rm -it -v ${PWD}:/working_dir -w /working_dir tensorflow/tensorflow:nightly-custom-op /bin/bash
24+
```
25+
26+
## Packaging
27+
```
28+
# In docker
29+
./configure.sh
30+
bazel build build_pip_pkg
31+
bazel-bin/build_pip_pkg artifacts
32+
```
33+
34+
A package file artifacts/tensorflow_addons-*.whl will be generated after a build is successful.
35+
36+
37+
## Testing
38+
```
39+
# In docker
40+
./configure.sh
41+
bazel test //tensorflow_addons/...
42+
```

WORKSPACE

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
load("//tf_dependency:tf_configure.bzl", "tf_configure")
2+
3+
tf_configure(
4+
name = "local_config_tf",
5+
)

build_pip_pkg.sh

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
# ==============================================================================
16+
set -e
17+
set -x
18+
19+
PLATFORM="$(uname -s | tr 'A-Z' 'a-z')"
20+
21+
PIP_FILE_PREFIX="bazel-bin/build_pip_pkg.runfiles/__main__/"
22+
23+
function main() {
24+
while [[ ! -z "${1}" ]]; do
25+
if [[ ${1} == "make" ]]; then
26+
echo "Using Makefile to build pip package."
27+
PIP_FILE_PREFIX=""
28+
else
29+
DEST=${1}
30+
fi
31+
shift
32+
done
33+
34+
if [[ -z ${DEST} ]]; then
35+
echo "No destination dir provided"
36+
exit 1
37+
fi
38+
39+
# Create the directory, then do dirname on a non-existent file inside it to
40+
# give us an absolute paths with tilde characters resolved to the destination
41+
# directory.
42+
mkdir -p ${DEST}
43+
DEST=$(readlink -f "${DEST}")
44+
echo "=== destination directory: ${DEST}"
45+
46+
TMPDIR=$(mktemp -d -t tmp.XXXXXXXXXX)
47+
48+
echo $(date) : "=== Using tmpdir: ${TMPDIR}"
49+
50+
echo "=== Copy TensorFlow Addons files"
51+
52+
cp ${PIP_FILE_PREFIX}setup.py "${TMPDIR}"
53+
cp ${PIP_FILE_PREFIX}MANIFEST.in "${TMPDIR}"
54+
cp ${PIP_FILE_PREFIX}LICENSE "${TMPDIR}"
55+
rsync -avm -L --exclude='*_test.py' ${PIP_FILE_PREFIX}tensorflow_addons "${TMPDIR}"
56+
57+
pushd ${TMPDIR}
58+
echo $(date) : "=== Building wheel"
59+
60+
python setup.py bdist_wheel > /dev/null
61+
62+
cp dist/*.whl "${DEST}"
63+
popd
64+
rm -rf ${TMPDIR}
65+
echo $(date) : "=== Output wheel file is in: ${DEST}"
66+
}
67+
68+
main "$@"

configure.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
# ==============================================================================
16+
function write_to_bazelrc() {
17+
echo "$1" >> .bazelrc
18+
}
19+
20+
function write_action_env_to_bazelrc() {
21+
write_to_bazelrc "build --action_env $1=\"$2\""
22+
}
23+
24+
rm .bazelrc
25+
if python -c "import tensorflow" &> /dev/null; then
26+
echo 'using installed tensorflow'
27+
else
28+
pip install tf-nightly-2.0-preview
29+
fi
30+
31+
TF_CFLAGS=( $(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_compile_flags()))') )
32+
TF_LFLAGS=( $(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_link_flags()))') )
33+
34+
write_action_env_to_bazelrc "TF_HEADER_DIR" ${TF_CFLAGS:2}
35+
write_action_env_to_bazelrc "TF_SHARED_LIBRARY_DIR" ${TF_LFLAGS:2}

setup.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ==============================================================================
15+
"""Setup for pip package."""
16+
from __future__ import absolute_import
17+
from __future__ import division
18+
from __future__ import print_function
19+
20+
from setuptools import find_packages
21+
from setuptools import setup
22+
from setuptools.dist import Distribution
23+
24+
__version__ = '0.0.1'
25+
REQUIRED_PACKAGES = [
26+
'tf-nightly-2.0-preview',
27+
]
28+
project_name = 'tensorflow-addons'
29+
30+
31+
class BinaryDistribution(Distribution):
32+
"""This class is needed in order to create OS specific wheels."""
33+
34+
def has_ext_modules(self):
35+
return True
36+
37+
38+
setup(
39+
name=project_name,
40+
version=__version__,
41+
description=('TensorFlow Addons'),
42+
author='Google Inc.',
43+
author_email='[email protected]',
44+
packages=find_packages(),
45+
install_requires=REQUIRED_PACKAGES,
46+
include_package_data=True,
47+
zip_safe=False,
48+
distclass=BinaryDistribution,
49+
classifiers=[
50+
'Development Status :: 4 - Beta',
51+
'Intended Audience :: Developers',
52+
'Intended Audience :: Education',
53+
'Intended Audience :: Science/Research',
54+
'License :: OSI Approved :: Apache Software License',
55+
'Programming Language :: Python :: 2.7',
56+
'Programming Language :: Python :: 3.4',
57+
'Programming Language :: Python :: 3.5',
58+
'Programming Language :: Python :: 3.6',
59+
'Topic :: Scientific/Engineering :: Mathematics',
60+
'Topic :: Software Development :: Libraries :: Python Modules',
61+
'Topic :: Software Development :: Libraries',
62+
],
63+
license='Apache 2.0',
64+
keywords='tensorflow addons machine learning',
65+
)

0 commit comments

Comments
 (0)