Closed Ravencentric closed 1 month ago
How would we determine the authors
in this case?
So I just checked poetry, pdm, and hatch. Both poetry and hatch pull the author from git
. pdm is an exception here since pdm's init interactively asks the user for author instead.
You can check that git (if installed) doesn't have a configured author by running:
$ git config user.name # no output
$ git config user.email # no output
Both hatch and poetry use a placeholder in this case:
poetry
$ poetry new --src hello-poetry && cat hello-poetry/pyproject.toml
[tool.poetry]
name = "hello-poetry"
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]
readme = "README.md"
packages = [{include = "hello_poetry", from = "src"}]
[tool.poetry.dependencies]
python = "^3.12"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
hatch
$ hatch new hello-hatch && cat hello-hatch/pyproject.toml
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "hello-hatch"
dynamic = ["version"]
description = ''
readme = "README.md"
requires-python = ">=3.8"
license = "MIT"
keywords = []
authors = [
{ name = "U.N. Owen", email = "void@some.where" },
]
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
dependencies = []
Configure git:
$ git config --global user.name "raven"
$ git config --global user.email "raven@email.com"
$ git config user.name
raven
$ git config user.email
raven@email.com
Now both poetry and hatch will pull the author field from the above git configuration:
poetry
$ poetry new --src hello-poetry && cat hello-poetry/pyproject.toml
[tool.poetry]
name = "hello-poetry"
version = "0.1.0"
description = ""
authors = ["raven <raven@email.com>"]
readme = "README.md"
packages = [{include = "hello_poetry", from = "src"}]
[tool.poetry.dependencies]
python = "^3.12"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
hatch
$ hatch new hello-hatch && cat hello-hatch/pyproject.toml
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "hello-hatch"
dynamic = ["version"]
description = ''
readme = "README.md"
requires-python = ">=3.8"
license = "MIT"
keywords = []
authors = [
{ name = "raven", email = "raven@email.com" },
]
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
dependencies = []
Relevant poetry snippet: https://github.com/python-poetry/poetry/blob/150ff09e5609f9ea9f5502e7f8b4720458e5126b/src/poetry/console/commands/init.py#L152-L157
Relevant hatch snippet(s): https://github.com/pypa/hatch/blob/5352e4422636cf1238017a74f0c67d689ccee558/src/hatch/config/model.py#L460-L483 https://github.com/pypa/hatch/blob/5352e4422636cf1238017a74f0c67d689ccee558/src/hatch/config/model.py#L491-L514
As I prefer not to expose my personal email in the Git commit history, I usually set up accounts with email addresses like @users.noreply.github.com
and @users.noreply.gitlab.com
.
Therefore, I hope that when encountering these two types of email addresses, they won't be set as the author's email, or a warning will be initialized.
How would we determine the
authors
in this case?pdm's init interactively asks the user for author instead.
I'd prefer pdm's approach (also w.r.t. @FishAlchemist's comment), plus a way to store this info in the user-level configuration (e.g., ~/.config/uv/uv.toml
).
For a non-Python precedent see use_description()
from the {usethis} R 📦 (especially the paragraph starting with "If you create a lot of packages, ..."). lt can also set a licence and package (or project) language. (In R, the DESCRIPTION
file is the equivalent to pyproject.toml
.)
I like the idea of being able to define commonly shared project metadata in user level uv.toml
Defining metadata in the uv.toml
seems nice, as does reading from git
by default. I think that we won't make this command interactive just for this feature, but I think an --interactive / -i
flag would be nice in the future.
Feature Request
poetry init
autofills theauthors
field:I find this quite helpful. This is usually boiler-plate that I'll have to fill anyway and not something that frequently changes so I doubt this will be controversial either. Would love to see this in
uv init
.Wish
I would also like it if
uv init
would autofill license field. MIT seems to be the popular option as of 2018. This might be harder to get a consensus on so I don't mind if this gets rejected. This can also be tied to a specific mode, like say--package
and--lib
but not with--app
since the former two are supposed to be published and the latter isn't. Prior art example for this would behatch
which uponhatch new
creates this:along with the
license.txt