From 72c2ac2d9f54a73bac2afd82482750b94fcd9491 Mon Sep 17 00:00:00 2001 From: "Antonio J. Delgado" Date: Tue, 14 Jun 2022 09:42:54 +0300 Subject: [PATCH] Add license and fix some substitutions --- deploy_new_python_project.sh | 36 +++++++++++++++++++ skeleton/LICENSE | 0 skeleton/project_codename/project_codename.py | 3 +- skeleton/pyproject.toml | 22 ++++++++++++ skeleton/setup.py | 4 ++- 5 files changed, 62 insertions(+), 3 deletions(-) mode change 100644 => 100755 deploy_new_python_project.sh create mode 100644 skeleton/LICENSE diff --git a/deploy_new_python_project.sh b/deploy_new_python_project.sh old mode 100644 new mode 100755 index a7778e1..e9944f1 --- a/deploy_new_python_project.sh +++ b/deploy_new_python_project.sh @@ -12,11 +12,14 @@ function usage() { echo " --author-email Email address of the author." echo " --url URL of the project." echo " --license License name." + echo " --license-url License URL to fetch in plain text and save in your project folder." + echo " --description Description." if [ -e "$(dirname "${0}")/defaults" ] then echo "Defaults:" cat "$(dirname "${0}")/defaults" fi + echo "" } # shellcheck disable=SC1090 if [ -e "$(dirname "${0}")/defaults" ] @@ -75,17 +78,49 @@ do LICENSE="${1}" shift ;; + "--license-url"|"-U") + shift + license_url="${1}" + shift + ;; + "--description") + shift + DESCRIPTION="${1}" + shift + ;; *) echo "Ignoring unknwon parameter '${1}'" shift ;; esac done +if [ -z ${DESCRIPTION} ]; then + DESCRIPTION=${PROJECT_NAME} +fi destination_path="${DEPLOYMENT_PATH}/${PROJECT_CODENAME}" mkdir -p "${DEPLOYMENT_PATH}" script_path=$(dirname "${0}") cp "${script_path}/skeleton" "${destination_path}" -rfp +if [ -z "${license_url}" ]; then + case "${license}" in + "GPLv3") + license_url="https://www.gnu.org/licenses/gpl-3.0.txt" + ;; + "GPLv2") + license_url="https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt" + ;; + "GPLv1"|"GPL") + licence_url="https://www.gnu.org/licenses/old-licenses/gpl-1.0.txt" + ;; + *) + echo "Warning! Put the license text in the file ${destination_path}/LICENSE or pass the URL with the --license-url option" + ;; + esac +fi +if [ -n "${licence_url}" ]; then + curl -s "${license_url}" > "${destination_path}/LICENSE" +fi mv "${destination_path}/project_codename" "${destination_path}/${PROJECT_CODENAME}" mv "${destination_path}/${PROJECT_CODENAME}/project_codename.py" "${destination_path}/${PROJECT_CODENAME}/${PROJECT_CODENAME}.py" while read -r file @@ -98,4 +133,5 @@ do sed -i "s/__version__/${VERSION}/g" "${file}" sed -i "s/__url__/${URL}/g" "${file}" sed -i "s/__license__/${LICENSE}/g" "${file}" + sed -i "s/__description__/${DESCRIPTION}/g" "${file}" done <<< "$(find "${destination_path}/" -type f)" \ No newline at end of file diff --git a/skeleton/LICENSE b/skeleton/LICENSE new file mode 100644 index 0000000..e69de29 diff --git a/skeleton/project_codename/project_codename.py b/skeleton/project_codename/project_codename.py index 04cfd69..bb16560 100644 --- a/skeleton/project_codename/project_codename.py +++ b/skeleton/project_codename/project_codename.py @@ -64,8 +64,7 @@ class __project_codename__: #@click.option("--dummy","-n" is_flag=True, help="Don't do anything, just show what would be done.") # Don't forget to add dummy to parameters of main function @click_config_file.configuration_option() def __main__(debug_level, log_file): - object = __project_codename__(debug_level, log_file) - object._log.info('Initialized __project_codename__') + return __project_codename__(debug_level, log_file) if __name__ == "__main__": __main__() diff --git a/skeleton/pyproject.toml b/skeleton/pyproject.toml index 9787c3b..4693a39 100644 --- a/skeleton/pyproject.toml +++ b/skeleton/pyproject.toml @@ -1,3 +1,25 @@ [build-system] requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" + +[project.urls] +Homepage = "__url__" + +[project] +name = "__project_codename__" +version = "__version__" +description = "__description__" +readme = "README.md" +authors = [{ name = "__author__", email = "__author_email__" }] +license = { file = "LICENSE" } +classifiers = [ + "License :: OSI Approved :: __license__ License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", +] +#keywords = ["vCard", "contacts", "duplicates"] +dependencies = [ + "click", + "click_config_file", +] +requires-python = ">=3" \ No newline at end of file diff --git a/skeleton/setup.py b/skeleton/setup.py index f536d35..8ac1383 100644 --- a/skeleton/setup.py +++ b/skeleton/setup.py @@ -3,10 +3,12 @@ setuptools.setup( scripts=['__project_codename__/__project_codename__.py'], author="__author__", version='__version__', - name='__project_codenane__', + name='__project_codename__', author_email="__author_email__", url="__url__", description="__description__", + long_description="README.md", + long_description_content_type="text/markdown", license="__license__", #keywords=["my", "script", "does", "things"] )