diff --git a/BUILD b/BUILD index 1cc330ea4..ca5bd9daf 100644 --- a/BUILD +++ b/BUILD @@ -1,2 +1,16 @@ -# Top-level Bazel BUILD file for TensorFlow Quantum. -# This file is intentionally empty. +# Copyright 2020 The TensorFlow Quantum Authors +# +# 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. + +# Export for the release package. +exports_files(["README.md"]) diff --git a/release/BUILD b/release/BUILD index f23d8528f..abe9557c3 100644 --- a/release/BUILD +++ b/release/BUILD @@ -44,7 +44,9 @@ sh_binary( "//tensorflow_quantum/datasets:__init__.py", # Dependencies to run PIP package creation. + # Use the repository root README.md for PyPI long_description. "MANIFEST.in", + "//:README.md", "setup.py", # Dependencies that the PIP package will import. diff --git a/release/build_pip_package.sh b/release/build_pip_package.sh index 02538b871..d8654e719 100755 --- a/release/build_pip_package.sh +++ b/release/build_pip_package.sh @@ -62,6 +62,7 @@ main() { echo "=== Copying TFQ files" # Copy over files necessary to run setup.py + cp "${EXPORT_DIR}/README.md" "${TMPDIR}" cp "${EXPORT_DIR}/release/setup.py" "${TMPDIR}" cp "${EXPORT_DIR}/release/MANIFEST.in" "${TMPDIR}" mkdir "${TMPDIR}/tensorflow_quantum" diff --git a/release/setup.py b/release/setup.py index df9cefea4..e99c35ca3 100644 --- a/release/setup.py +++ b/release/setup.py @@ -61,7 +61,22 @@ def read_version(): CUR_VERSION = read_version() -DOCLINES = __doc__.split("\n") + +def read_readme(): + """Return the project README contents for PyPI.""" + + setup_dir = Path(__file__).resolve().parent + + # setup.py runs from release/ in the source tree, but it is copied to the + # package root in the wheel build tmpdir. + if (setup_dir / "tensorflow_quantum").is_dir(): + readme_path = setup_dir / "README.md" + else: + readme_path = setup_dir.parent / "README.md" + + if not readme_path.is_file(): + raise RuntimeError(f"Could not find README.md at: {readme_path}") + return readme_path.read_text(encoding="utf-8") class InstallPlatlib(install): @@ -121,7 +136,7 @@ def has_ext_modules(self): name=PROJECT_NAME, version=BUILD_VERSION, description="Library for hybrid quantum-classical machine learning.", - long_description="\n".join(DOCLINES[2:]), + long_description=read_readme(), long_description_content_type="text/markdown", author="The TensorFlow Quantum Authors", author_email="tensorflow-quantum-team@google.com",