Add simple implementation for writing pyproject.toml
This commit is contained in:
parent
abb169c231
commit
afb98a5fea
@ -317,6 +317,41 @@ def load_pyproject_toml(dirname, maxdepth=3, filename='pyproject.toml'):
|
|||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
||||||
|
def write_pyproject_toml(path):
|
||||||
|
|
||||||
|
config = {
|
||||||
|
'Module name': '',
|
||||||
|
'Author': '',
|
||||||
|
'Author email': '',
|
||||||
|
'CLI command': '',
|
||||||
|
'CLI path': '',
|
||||||
|
}
|
||||||
|
|
||||||
|
for key in config.keys():
|
||||||
|
config[key] = input(f"{key}: ")
|
||||||
|
|
||||||
|
author_and_email = '{name = "' + config['Author'] + '", email = "' + config['Author email'] + '"}'
|
||||||
|
|
||||||
|
with open(path, 'w') as f:
|
||||||
|
f.write(f"""\
|
||||||
|
[build-system]
|
||||||
|
requires = ["flit_core >=3.2,<4"]
|
||||||
|
build-backend = "flit_core.buildapi"
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "{config['Module name']}"
|
||||||
|
authors = [{author_and_email}]
|
||||||
|
dynamic = ["version", "description"]
|
||||||
|
dependencies = ["magicli"]
|
||||||
|
|
||||||
|
[project.scripts]
|
||||||
|
{config['CLI command']} = "{config['CLI path']}"
|
||||||
|
|
||||||
|
[tool.magicli]
|
||||||
|
test = "test"
|
||||||
|
""")
|
||||||
|
|
||||||
|
|
||||||
def first_calling_frame():
|
def first_calling_frame():
|
||||||
for s in reversed(inspect.stack()):
|
for s in reversed(inspect.stack()):
|
||||||
if s.code_context == None:
|
if s.code_context == None:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user