in src/sagemaker_training/modules.py [0:0]
def prepare(path, name): # type: (str, str) -> None
"""Prepare a Python script (or module) to be imported as a module.
If the script does not contain a setup.py file, it creates a minimal setup.
Args:
path (str): Path to directory with the script or module.
name (str): Name of the script or module.
"""
setup_path = os.path.join(path, "setup.py")
if not os.path.exists(setup_path):
data = textwrap.dedent(
"""
from setuptools import setup
setup(packages=[''],
name="%s",
version='1.0.0',
include_package_data=True)
"""
% name
)
logger.info("Module %s does not provide a setup.py. \nGenerating setup.py" % name)
files.write_file(setup_path, data)
data = textwrap.dedent(
"""
[wheel]
universal = 1
"""
)
logger.info("Generating setup.cfg")
files.write_file(os.path.join(path, "setup.cfg"), data)
data = textwrap.dedent(
"""
recursive-include . *
recursive-exclude . __pycache__*
recursive-exclude . *.pyc
recursive-exclude . *.pyo
"""
)
logger.info("Generating MANIFEST.in")
files.write_file(os.path.join(path, "MANIFEST.in"), data)