cookiecutter-pypackage icon indicating copy to clipboard operation
cookiecutter-pypackage copied to clipboard

what is project_slug? why we use it and what are the naming conventions?

Open mianasbat opened this issue 5 years ago • 6 comments

The cookiecutter template ask for entering project_slug, however I couldnt find any explanation about it online. One of the issue shows that hyphen is not allowed but on my local cookiecutter hyphen is accepted. I am not sure if the name with hyphen is fine or not?

Also could you please explain what it is used for? What is the difference between project name and project slug? What are the naming conventions for entering project slug?

Thanks

mianasbat avatar May 24 '19 23:05 mianasbat

the project slug is the python package name that will be used when you want to install your package elsewere using pip install your_package_name.

Please follow the guide on 'package names' https://www.python.org/dev/peps/pep-0008/#package-and-module-names

Simply said:

  • does not contain spaces
  • hit the keys on your keyboard without holding shift
  • hence: No Caps
  • does not contain - or + but use the _ (underscore or snakecase)
  • short, consise and informative

jberends avatar Jun 03 '19 07:06 jberends

Thanks for reply and clarification.

mianasbat avatar Jun 03 '19 14:06 mianasbat

Thank you for your attention. There will be a small update later to help some people understand similar issues.

PsiACE avatar Sep 10 '19 00:09 PsiACE

but what does "slug" means?

aleivag avatar Mar 23 '20 17:03 aleivag

The term slug is commonly used in the world of web apps and refers to a modification of, e.g., an article title such that it conforms to the constraints of urls.

To give you an example for this context: Say your project name is "My Favorite Package". This is not a valid Python package name. The equivalent slug would be my_favorite_package.

Dr-ZeeD avatar Apr 22 '20 12:04 Dr-ZeeD

A slug is a normalized form of a string, but there's some ambiguity around the term in cookiecutter. It seems that normally a slug refers to a string with words separated by hyphens (-). This is the default in all the slugify packages I've looked at. For example, the Cookiecutter slugify extension uses python-slugify which defaults to hyphen-separated. But in this template, package_slug is used as a package directory name, which means package_slug has to be a legal python package name, i.e. underscore-separated.

kamatsuoka avatar Jun 04 '20 19:06 kamatsuoka