Skip to content

Commit da75272

Browse files
pprkutSteveMcGrathmarsam
authored
Make sclack installable from pip in a more universal fashion (#142)
Moved app and config within the sclack package Co-authored-by: Steven McGrath <[email protected]> Co-authored-by: Mario Rodas <[email protected]>
1 parent c44ddbc commit da75272

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

app.py renamed to sclack/app.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -958,10 +958,15 @@ def ask_for_token(json_config):
958958
config_file.write(json.dumps(token_config, indent=False))
959959
json_config.update(token_config)
960960

961-
if __name__ == '__main__':
961+
def run():
962962
json_config = {}
963-
with open('./config.json', 'r') as config_file:
963+
config_file = os.path.join(
964+
os.path.dirname(os.path.realpath(__file__)), 'config.json')
965+
with open(config_file, 'r') as config_file:
964966
json_config.update(json.load(config_file))
965967
ask_for_token(json_config)
966968
app = App(json_config)
967969
app.start()
970+
971+
if __name__ == '__main__':
972+
run()
File renamed without changes.

setup.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@
1212
author='Marcelo Camargo',
1313
author_email='[email protected]',
1414
url='https://github.com/haskellcamargo/sclack',
15-
scripts=["app.py"],
15+
entry_points={
16+
'console_scripts': [
17+
'sclack=sclack.app:run',
18+
],
19+
},
20+
package_data={
21+
'sclack': ['config.json']
22+
},
1623
packages=find_packages(),
1724
install_requires=[
1825
'asyncio',

tests/test_api.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from sclack.quick_switcher import remove_diacritic
2-
from app import ask_for_token
2+
from sclack.app import ask_for_token
33

44
from slackclient import SlackClient
55

@@ -58,4 +58,4 @@ def test_get_members_pagination2():
5858
limit=10, # 1k is max limit
5959
types='public_channel,private_channel,im')
6060
members = client.api_call('conversations.members', channel=channels['channels'][0]['id'], limit=1)
61-
assert members != None and members.get('response_metadata', None) != None
61+
assert members != None and members.get('response_metadata', None) != None

0 commit comments

Comments
 (0)