Update package CLI handling of README and LICENSE (#8422)

* Copy rather than move files to top-level of package
* Add all files to `MANIFEST.in` (primarily for older versions of pip)
* Include the `README.md` contents as `long_description` in the setup
This commit is contained in:
Adriane Boyd 2021-06-18 15:48:53 +02:00 committed by GitHub
parent 30d4eb506a
commit 83fd04dee5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -133,7 +133,7 @@ def package(
for file_name in FILENAMES_DOCS:
file_path = package_path / model_name_v / file_name
if file_path.exists():
shutil.move(str(file_path), str(main_path))
shutil.copy(str(file_path), str(main_path))
imports = []
for code_path in code_paths:
imports.append(code_path.stem)
@ -248,6 +248,13 @@ def load_meta(fp):
return json.load(f)
def load_readme(fp):
if path.exists(fp):
with io.open(fp, encoding='utf8') as f:
return f.read()
return ""
def list_files(data_dir):
output = []
for root, _, filenames in walk(data_dir):
@ -273,6 +280,8 @@ def setup_package():
root = path.abspath(path.dirname(__file__))
meta_path = path.join(root, 'meta.json')
meta = load_meta(meta_path)
readme_path = path.join(root, 'README.md')
readme = load_readme(readme_path)
model_name = str(meta['lang'] + '_' + meta['name'])
model_dir = path.join(model_name, model_name + '-' + meta['version'])
@ -282,6 +291,7 @@ def setup_package():
setup(
name=model_name,
description=meta.get('description'),
long_description=readme,
author=meta.get('author'),
author_email=meta.get('email'),
url=meta.get('url'),
@ -303,6 +313,8 @@ if __name__ == '__main__':
TEMPLATE_MANIFEST = """
include meta.json
include LICENSE
include LICENSES_SOURCES
include README.md
""".strip()