Add license and fix some substitutions

This commit is contained in:
Antonio J. Delgado 2022-06-14 09:42:54 +03:00
parent 4d90d26087
commit 72c2ac2d9f
5 changed files with 62 additions and 3 deletions

36
deploy_new_python_project.sh Normal file → Executable file
View file

@ -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)"

0
skeleton/LICENSE Normal file
View file

View file

@ -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__()

View file

@ -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"

View file

@ -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"]
)