-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
135 lines (109 loc) · 4.6 KB
/
example.py
File metadata and controls
135 lines (109 loc) · 4.6 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# This docstring is not used by pakit, by convention they are usually similar
""" Formula for building example """
# All Recipes must be usable on python 2.7+, use future print if needed
from __future__ import print_function
# Feel free to use standard libs provided with python 2.7
# avoid python 3 specific dependencies
import os
# Pakit provides convenience classes, full list available with `pydoc pakit`
# Import only those you need.
from pakit import Git, Recipe
# This recipe should be in file 'example.py'
# It can be referenced by pakit commands as 'example'
class Example(Recipe):
"""
Example recipe. This line should be a short description.
This is a longer description.
It can be of any length.
Have breaks in text.
It will be presented as 'More Information' when displaying a Recipe.
For instance `pakit --display example`.
"""
def __init__(self):
# Required
super(Example, self).__init__()
# Extra attributes are ignored by pakit
self.src = 'https://github.com/ggreer/the_silver_searcher.git'
# The homepage of the project, should be information for users
self.homepage = self.src
# A dictionary of Fetchable classes, used to get the source code
# By convention, should always have 'stable' and 'unstable' keys
# 'stable' -> point to stable release of source code
# 'unstable' -> point to a more recent version, like branch of code
self.repos = {
'stable': Git(self.src, tag='0.30.0'),
'unstable': Git(self.src),
}
# OPTIONAL: If present, this Recipe requires listed Recipes to be
# installed before it can be.
self.requires = ['exampledep']
def log(self, msg): # pylint: disable=R0201
"""
Simple method prints message followed by current working directory.
You can add any method you want to Recipe so long as pakit's
conventions are followed. I currently do no checking to ensure
they are.
"""
print(msg, 'the working directory is', os.getcwd())
def pre_build(self):
"""
OPTIONAL: Will be called BEFORE build().
When called, the working directory will be set to the source code.
Possible Use Case: Patching source before build().
"""
self.log('Before build()')
def build(self):
"""
MANDATORY
When called, the working directory will be set to the source code.
Steps should be taken to build and install the program.
Issue system commands using self.cmd.
For usage, see 'pydoc pakit.recipe.cmd` for details.
"""
self.log('build()')
cmd1 = self.cmd('pwd')
cmd2 = self.cmd('ls')
print('Current dir: ' + cmd1.output()[0])
print('Contains:\n ' + '\n '.join(cmd2.output()))
def post_build(self):
"""
OPTIONAL: Will be called AFTER build().
When called, the working directory will be set to the source code.
Possible Use Case: Patching files after installed.
"""
self.log('After build()')
def pre_verify(self):
"""
OPTIONAL: Will be called BEFORE verify().
When called, the working directory will be set to a temporary
directory created by pakit.
Your program binaries will be available at the front of $PATH.
You may do anything in the temp directory so long as permission
to delete the files/folder are not removed.
Possible Use Case: Fetch some remote file to test against.
"""
self.log('Before verify()')
def verify(self):
"""
MANDATORY
When called, the working directory will be set to a temporary
directory created by pakit.
Your program binaries will be available at the front of $PATH.
You may do anything in the temp directory so long as permission
to delete the files/folder are not removed.
You should execute Commands with self.cmd and verify the output.
Use 'assert' statements to ensure the build is good.
"""
self.log('verify()')
assert True
def post_verify(self):
"""
OPTIONAL: Will be called AFTER verify().
When called, the working directory will be set to a temporary
directory created by pakit.
Your program binaries will be available at the front of $PATH.
You may do anything in the temp directory so long as permission
to delete the files/folder are not removed.
Possible Use Case: Not yet found.
"""
self.log('After verify()')