forked from tomerfiliba/plumbum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.py
executable file
·32 lines (24 loc) · 1019 Bytes
/
build.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
#!/usr/bin/env python
from plumbum import local, cli, FG
from plumbum.path.utils import delete
try:
from plumbum.cmd import twine
except ImportError:
twine = None
class BuildProject(cli.Application):
'Build and optionally upload. For help, see https://packaging.python.org/en/latest/distributing/#uploading-your-project-to-pypi'
upload = cli.Flag("upload", help = "If given, the artifacts will be uploaded to PyPI")
def main(self):
delete(local.cwd // "*.egg-info", "build", "dist")
local.python("setup.py", "sdist", "bdist_wheel")
delete(local.cwd // "*.egg-info", "build")
if self.upload:
if twine is None:
print("Twine not installed, cannot securely upload. Install twine.")
else:
twine['upload', 'dist/*tar.gz', 'dist/*.whl'] & FG
else:
print("Built. To upload, run:")
print(" twine upload dist/*tar.gz dist/*.whl")
if __name__ == "__main__":
BuildProject.run()