mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
added the generate-setup action
This commit is contained in:
parent
ab244398ba
commit
721ccd0ce1
2 changed files with 18 additions and 2 deletions
|
@ -9,7 +9,7 @@ from copy import copy
|
||||||
|
|
||||||
from packaging import logger
|
from packaging import logger
|
||||||
from packaging.dist import Distribution
|
from packaging.dist import Distribution
|
||||||
from packaging.util import _is_archive_file
|
from packaging.util import _is_archive_file, generate_setup_py
|
||||||
from packaging.command import get_command_class, STANDARD_COMMANDS
|
from packaging.command import get_command_class, STANDARD_COMMANDS
|
||||||
from packaging.install import install, install_local_project, remove
|
from packaging.install import install, install_local_project, remove
|
||||||
from packaging.database import get_distribution, get_distributions
|
from packaging.database import get_distribution, get_distributions
|
||||||
|
@ -38,6 +38,14 @@ Usage: pysetup create
|
||||||
Create a new Python package.
|
Create a new Python package.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
generate_usage = """\
|
||||||
|
Usage: pysetup generate-setup
|
||||||
|
or: pysetup generate-setup --help
|
||||||
|
|
||||||
|
Generates a setup.py script for backward-compatibility purposes.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
graph_usage = """\
|
graph_usage = """\
|
||||||
Usage: pysetup graph dist
|
Usage: pysetup graph dist
|
||||||
or: pysetup graph --help
|
or: pysetup graph --help
|
||||||
|
@ -204,6 +212,13 @@ def _create(distpatcher, args, **kw):
|
||||||
return main()
|
return main()
|
||||||
|
|
||||||
|
|
||||||
|
@action_help(generate_usage)
|
||||||
|
def _generate(distpatcher, args, **kw):
|
||||||
|
generate_setup_py()
|
||||||
|
print('The setup.py was generated')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@action_help(graph_usage)
|
@action_help(graph_usage)
|
||||||
def _graph(dispatcher, args, **kw):
|
def _graph(dispatcher, args, **kw):
|
||||||
name = args[1]
|
name = args[1]
|
||||||
|
@ -381,6 +396,7 @@ actions = [
|
||||||
('list', 'Search for local projects', _list),
|
('list', 'Search for local projects', _list),
|
||||||
('graph', 'Display a graph', _graph),
|
('graph', 'Display a graph', _graph),
|
||||||
('create', 'Create a Project', _create),
|
('create', 'Create a Project', _create),
|
||||||
|
('generate-setup', 'Generates a backward-comptatible setup.py', _generate)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1087,7 +1087,7 @@ def generate_setup_py():
|
||||||
Raises a PackagingFileError when a setup.py already exists.
|
Raises a PackagingFileError when a setup.py already exists.
|
||||||
"""
|
"""
|
||||||
if os.path.exists("setup.py"):
|
if os.path.exists("setup.py"):
|
||||||
raise PackagingFileError("a setup.py file alreadyexists")
|
raise PackagingFileError("a setup.py file already exists")
|
||||||
|
|
||||||
with open("setup.py", "w", encoding='utf-8') as fp:
|
with open("setup.py", "w", encoding='utf-8') as fp:
|
||||||
fp.write(_SETUP_TMPL % {'func': getsource(cfg_to_args)})
|
fp.write(_SETUP_TMPL % {'func': getsource(cfg_to_args)})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue