generated from patel-zeel/pip-template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
customize.py
72 lines (60 loc) · 2.37 KB
/
customize.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import os
# Manually modify following parameters to customize the structure of your project
path = os.path.abspath(os.path.dirname(__file__)).split("/")
# print(path)
REPO_HOME_PATH = "/".join(path[:-1])
REPO_NAME = path[-1]
PACKAGE_NAME = REPO_NAME
AUTHOR = "Zeel B Patel"
AUTHOR_EMAIL = "[email protected]"
description = "example description"
URL = "https://github.com/patel-zeel/" + REPO_NAME
LICENSE = "MIT"
LICENSE_FILE = "LICENSE"
LONG_DESCRIPTION = "file: README.md"
LONG_DESCRIPTION_CONTENT_TYPE = "text/markdown"
full_path = os.path.join(REPO_HOME_PATH, REPO_NAME)
# Write setup.cfg
with open(os.path.join(full_path, "setup.cfg"), "w") as f:
f.write("[metadata]\n")
f.write("name = " + PACKAGE_NAME + "\n")
f.write("author = " + AUTHOR + "\n")
f.write("author-email = " + AUTHOR_EMAIL + "\n")
f.write("description = " + description + "\n")
f.write("url = " + URL + "\n")
f.write("license = " + LICENSE + "\n")
f.write("long_description_content_type = " + LONG_DESCRIPTION_CONTENT_TYPE + "\n")
f.write("long_description = " + LONG_DESCRIPTION + "\n")
# Write CI
with open(os.path.join(full_path, ".github/workflows/CI.template"), "r") as f:
content = f.read()
with open(os.path.join(full_path, ".github/workflows/CI.yml"), "w") as f:
content = content.replace("<reponame>", REPO_NAME)
f.write(content)
# Write .gitignore
with open(os.path.join(full_path, ".gitignore"), "w") as f:
f.write("__pycache__/\n")
f.write("*.vscode\n")
f.write("*.ipynb_checkpoints\n")
f.write("*.pyc\n")
f.write("*.egg-info/\n")
f.write(f"{PACKAGE_NAME}/_version.py\n")
# Write pyproject.toml
with open(os.path.join(full_path, "pyproject.toml"), "w") as f:
f.write("[build-system]\n")
f.write("requires = [\n")
f.write('\t"setuptools>=50.0",\n')
f.write('\t"setuptools_scm[toml]>=6.0",\n')
f.write('\t"setuptools_scm_git_archive",\n')
f.write('\t"wheel>=0.33",\n')
f.write('\t"numpy>=1.16",\n')
f.write('\t"cython>=0.29",\n')
f.write("\t]\n")
f.write("\n")
f.write("[tool.setuptools_scm]\n")
f.write(f'write_to = "{PACKAGE_NAME}/_version.py"')
# Initialize project folder
os.makedirs(os.path.join(full_path , PACKAGE_NAME), exist_ok=True)
with open(os.path.join(full_path, PACKAGE_NAME, "__init__.py"), "w") as f:
f.write("from ._version import version as __version__ # noqa")
print("Successful")