| 138 | |
| 139 | @contextlib.contextmanager |
| 140 | def make_project( |
| 141 | name="my_project", # type: str |
| 142 | version="0.0.0", # type: str |
| 143 | zip_safe=True, # type: bool |
| 144 | install_reqs=None, # type: Optional[List[str]] |
| 145 | extras_require=None, # type: Optional[Dict[str, List[str]]] |
| 146 | entry_points=None, # type: Optional[Union[str, Dict[str, List[str]]]] |
| 147 | python_requires=None, # type: Optional[str] |
| 148 | universal=False, # type: bool |
| 149 | prepare_project=None, # type: Optional[Callable[[str], None]] |
| 150 | ): |
| 151 | # type: (...) -> Iterator[str] |
| 152 | project_content = { |
| 153 | "setup.py": dedent( |
| 154 | """ |
| 155 | from setuptools import setup |
| 156 | |
| 157 | setup( |
| 158 | name=%(project_name)r, |
| 159 | version=%(version)r, |
| 160 | zip_safe=%(zip_safe)r, |
| 161 | packages=[%(project_name)r], |
| 162 | scripts=[ |
| 163 | 'scripts/%(hello_world_script_name)s', |
| 164 | 'scripts/%(shell_script_name)s', |
| 165 | ], |
| 166 | package_data={%(project_name)r: ['package_data/*.dat']}, |
| 167 | install_requires=%(install_requires)r, |
| 168 | extras_require=%(extras_require)r, |
| 169 | entry_points=%(entry_points)r, |
| 170 | python_requires=%(python_requires)r, |
| 171 | options={'bdist_wheel': {'universal': %(universal)r}}, |
| 172 | ) |
| 173 | """ |
| 174 | ), |
| 175 | os.path.join(name, "__init__.py"): 0, |
| 176 | os.path.join(name, "my_module.py"): 'def do_something():\n print("hello world!")\n', |
| 177 | os.path.join(name, "package_data/resource1.dat"): 1000, |
| 178 | os.path.join(name, "package_data/resource2.dat"): 1000, |
| 179 | } # type: Dict[str, Union[str, int]] |
| 180 | |
| 181 | if WINDOWS: |
| 182 | project_content.update( |
| 183 | ( |
| 184 | ( |
| 185 | "scripts/hello_world.py", |
| 186 | '#!/usr/bin/env python\r\nprint("hello world from py script!")\r\n', |
| 187 | ), |
| 188 | ("scripts/shell_script.bat", "@echo off\r\necho hello world from shell script\r\n"), |
| 189 | ) |
| 190 | ) |
| 191 | else: |
| 192 | project_content.update( |
| 193 | ( |
| 194 | ( |
| 195 | "scripts/hello_world", |
| 196 | '#!/usr/bin/env python\nprint("hello world from py script!")\n', |
| 197 | ), |