-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactivestate.yaml
61 lines (51 loc) · 2.2 KB
/
activestate.yaml
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
project: https://platform.activestate.com/mitchell-as/test3?branch=main&commitID=fc0eaa41-21ff-4774-855c-ddebddf70445
scripts:
- name: activationMessage
language: python3
value: |
# -*- coding: utf-8 -*-
import textwrap
print(textwrap.dedent("""
Quick Start
───────────
• To add a package to your runtime, type "state install <package name>"
• Learn more about how to use the State Tool, type "state learn"
"""))
- name: pip
language: python3
value: |
import os
import subprocess
import sys
env = os.environ.copy()
env["ACTIVESTATE_SHIM"] = "pip"
project_path = os.path.join(r"${project.path()}", "activestate.yaml")
def configure_message():
print("To configure this shim edit the following file:\n" + project_path + "\n")
def mapcmds(mapping):
for fromCmd, toCmd in mapping.items():
if len(sys.argv) == 1:
print("pip requires an argument. Try:\n pip [install, uninstall, list, show, search, help]")
sys.exit()
if sys.argv[1] != fromCmd:
continue
print(("Shimming command to: 'state %s'") % toCmd)
configure_message()
code = subprocess.call(["state", toCmd] + sys.argv[2:], env=env)
sys.exit(code)
mapcmds({
"help": "help",
"install": "install",
"uninstall": "uninstall",
"list": "packages",
"show": "info",
"search": "search",
})
print("Could not shim your command as it is not supported by the State Tool.\n" +
"Please check 'state --help' to find the best analog for the command you're trying to run.\n")
configure_message()
events:
# This is the ACTIVATE event, it will run whenever a new virtual environment is created (eg. by running `state activate`)
# On Linux and macOS this will be ran as part of your shell's rc file, so you can use it to set up aliases, functions, environment variables, etc.
- name: ACTIVATE
value: python3 $scripts.activationMessage.path()