forked from eyurtsev/fcsparser
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfabfile.py
More file actions
73 lines (57 loc) · 1.68 KB
/
Copy pathfabfile.py
File metadata and controls
73 lines (57 loc) · 1.68 KB
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
73
"""Fabric file."""
import base64
import os
import json
import urllib2
from contextlib import contextmanager
from fabric.api import local, lcd, abort
from fabric.decorators import task
BUILD_DIRS = (
"dist",
"doc/build",
"build",
"fcsparser.egg-info",
)
SDIST_RST_FILES = (
"README.rst",
)
SDIST_TXT_FILES = [os.path.splitext(x)[0] + ".txt" for x in SDIST_RST_FILES]
@task
def clean():
"""Clean build files."""
for build_dir in list(BUILD_DIRS):
local("rm -rf %s" % build_dir)
###############################################################################
# PyPI
###############################################################################
@contextmanager
def _dist_wrapper():
"""Add temporary distribution build files (and then clean up)."""
try:
# Copy select *.rst files to *.txt for build.
for rst_file, txt_file in zip(SDIST_RST_FILES, SDIST_TXT_FILES):
local("cp %s %s" % (rst_file, txt_file))
# Perform action.
yield
finally:
# Clean up temp *.txt files.
for rst_file in SDIST_TXT_FILES:
local("rm -f %s" % rst_file, capture=False)
@task
def sdist():
"""Package into distribution."""
with _dist_wrapper():
local("python setup.py sdist", capture=False)
@task
def pypi_register():
"""Register and prep user for PyPi upload.
.. note:: May need to weak ~/.pypirc file per issue:
http://stackoverflow.com/questions/1569315
"""
with _dist_wrapper():
local("python setup.py register", capture=False)
@task
def pypi_upload():
"""Upload package."""
with _dist_wrapper():
local("python setup.py sdist upload", capture=False)