Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mhpfiles
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Operate
Terraform modules
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Travis Seymour
mhpfiles
Commits
23a53b17
Commit
23a53b17
authored
3 months ago
by
Travis Seymour
Browse files
Options
Downloads
Patches
Plain Diff
rich import not working. will investigate later but now i removed it
parent
5d8b9d99
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
old_tool_install.py
+152
-0
152 additions, 0 deletions
old_tool_install.py
tool_install.py
+25
-42
25 additions, 42 deletions
tool_install.py
with
177 additions
and
42 deletions
old_tool_install.py
0 → 100644
+
152
−
0
View file @
23a53b17
# uv-meta: {"requires": ["rich"]}
import
sys
import
subprocess
import
platform
from
pathlib
import
Path
from
rich.console
import
Console
from
rich
import
print
"""
To run this script:
1. If you don
'
t have git installed, install it from here: https://git-scm.com/downloads
2. If you don
'
t have uv installed, install it from here: https://docs.astral.sh/uv/getting-started/installation/
3. Run this command:
uv run tool_install.py
"""
console
=
Console
()
def
run_command
(
command
):
"""
Run a command and return the output, or None if it fails.
"""
try
:
result
=
subprocess
.
run
(
command
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
text
=
True
,
check
=
True
,
)
return
result
.
stdout
except
subprocess
.
CalledProcessError
as
e
:
console
.
print
(
f
"
[red]Error running command:
{
'
'
.
join
(
command
)
}
[/red]
"
)
console
.
print
(
e
.
stderr
)
return
None
def
ensure_git_installed
():
"""
Check if git is installed; if not, alert the user and quit.
"""
if
not
shutil
.
which
(
"
git
"
):
console
.
print
(
"
[red]Git is not installed![/red]
"
)
console
.
print
(
"
Please install git from [blue]https://git-scm.com/downloads[/blue] before trying again.
"
)
sys
.
exit
(
1
)
def
get_python_3_10_path
():
"""
Get the path to Python 3.10 by checking the current Python interpreter.
"""
python_path
=
Path
(
sys
.
executable
)
if
python_path
.
exists
()
and
python_path
.
name
.
startswith
(
"
python3.10
"
):
return
str
(
python_path
)
console
.
print
(
"
[red]EPICPy requires Python 3.10 on Linux and MacOS, but that version of Python could not be located on this system.
"
"
You can install Python 3.10 by running this command: uv python install 3.10[/red]
"
)
sys
.
exit
(
1
)
def
get_python_3_9_path
():
"""
Get the path to Python 3.9 by checking for it explicitly.
"""
result
=
run_command
(
[
"
where
"
if
platform
.
system
()
==
"
Windows
"
else
"
which
"
,
"
python3.9
"
]
)
if
result
:
python_path
=
Path
(
result
.
strip
())
if
python_path
.
exists
():
return
str
(
python_path
)
console
.
print
(
"
[red]EPICPy requires Python 3. on Windows, but that version of Python could not be located on this system.
"
"
You can install Python 3.9 by running this command: uv python install 3.9[/red]
"
)
sys
.
exit
(
1
)
def
main
():
ensure_git_installed
()
# Determine the appropriate Python version
if
platform
.
system
().
lower
()
==
"
windows
"
:
python_path
=
get_python_3_9_path
()
else
:
python_path
=
get_python_3_10_path
()
# Step 1: Check if EPICpy is installed and uninstall it if necessary
uv_tool_list
=
run_command
([
"
uv
"
,
"
tool
"
,
"
list
"
])
if
uv_tool_list
and
"
EPICpy
"
in
uv_tool_list
:
console
.
print
(
"
[yellow]EPICpy is already installed. Uninstalling...[/yellow]
"
)
run_command
([
"
uv
"
,
"
tool
"
,
"
uninstall
"
,
"
EPICpy
"
])
# Step 2: Install EPICpy using the determined Python path
console
.
print
(
f
"
[cyan]Installing EPICpy with Python at
{
python_path
}
...[/cyan]
"
)
install_output
=
run_command
(
[
"
uv
"
,
"
tool
"
,
"
install
"
,
"
git+https://www.github.com/travisseymour/EPICpy.git
"
,
"
--python
"
,
python_path
,
]
)
if
install_output
and
"
Installed 1 executable: EPICpy
"
in
install_output
:
console
.
print
(
"
[green]EPICpy installed successfully! You can run it from the terminal like this: EPICpy[/green]
"
)
else
:
console
.
print
(
"
[red]Failed to install EPICpy. Please check the error above and try again.[/red]
"
)
sys
.
exit
(
1
)
# Step 3: Check if epiccoder is installed and uninstall it if necessary
uv_tool_list
=
run_command
([
"
uv
"
,
"
tool
"
,
"
list
"
])
if
uv_tool_list
and
"
epiccoder
"
in
uv_tool_list
:
console
.
print
(
"
[yellow]epiccoder is already installed. Uninstalling...[/yellow]
"
)
run_command
([
"
uv
"
,
"
tool
"
,
"
uninstall
"
,
"
epiccoder
"
])
# Step 4: Install epiccoder
console
.
print
(
"
[cyan]Installing epiccoder...[/cyan]
"
)
epiccoder_output
=
run_command
(
[
"
uv
"
,
"
tool
"
,
"
install
"
,
"
git+https://www.github.com/travisseymour/epiccoder.git
"
,
]
)
if
(
epiccoder_output
and
"
Installed 1 executable: epiccoder
"
in
epiccoder_output
):
console
.
print
(
"
[green]epiccoder installed successfully! You can run it from the terminal like this: epiccoder[/green]
"
)
else
:
console
.
print
(
"
[red]Failed to install epiccoder. Please check the error above and try again.[/red]
"
)
sys
.
exit
(
1
)
if
__name__
==
"
__main__
"
:
main
()
This diff is collapsed.
Click to expand it.
tool_install.py
+
25
−
42
View file @
23a53b17
# uv-meta: {
"requires": ["rich"]
}
# uv-meta: {}
import
sys
import
subprocess
import
platform
from
pathlib
import
Path
from
rich.console
import
Console
from
rich
import
print
"""
To run this script:
...
...
@@ -15,8 +13,6 @@ To run this script:
uv run tool_install.py
"""
console
=
Console
()
def
run_command
(
command
):
"""
Run a command and return the output, or None if it fails.
"""
...
...
@@ -30,17 +26,18 @@ def run_command(command):
)
return
result
.
stdout
except
subprocess
.
CalledProcessError
as
e
:
console
.
print
(
f
"
[red]
Error running command:
{
'
'
.
join
(
command
)
}
[/red]
"
)
console
.
print
(
e
.
stderr
)
print
(
f
"
Error running command:
{
'
'
.
join
(
command
)
}
"
,
file
=
sys
.
stderr
)
print
(
e
.
stderr
,
file
=
sys
.
stderr
)
return
None
def
ensure_git_installed
():
"""
Check if git is installed; if not, alert the user and quit.
"""
if
not
shutil
.
which
(
"
git
"
):
console
.
print
(
"
[red]Git is not installed![/red]
"
)
console
.
print
(
"
Please install git from [blue]https://git-scm.com/downloads[/blue] before trying again.
"
print
(
"
Git is not installed!
"
,
file
=
sys
.
stderr
)
print
(
"
Please install git from https://git-scm.com/downloads before trying again.
"
,
file
=
sys
.
stderr
,
)
sys
.
exit
(
1
)
...
...
@@ -50,9 +47,10 @@ def get_python_3_10_path():
python_path
=
Path
(
sys
.
executable
)
if
python_path
.
exists
()
and
python_path
.
name
.
startswith
(
"
python3.10
"
):
return
str
(
python_path
)
console
.
print
(
"
[red]EPICPy requires Python 3.10 on Linux and MacOS, but that version of Python could not be located on this system.
"
"
You can install Python 3.10 by running this command: uv python install 3.10[/red]
"
print
(
"
EPICPy requires Python 3.10 on Linux and MacOS, but that version of Python could not be located on this system.
"
"
You can install Python 3.10 by running this command: uv python install 3.10
"
,
file
=
sys
.
stderr
,
)
sys
.
exit
(
1
)
...
...
@@ -66,9 +64,10 @@ def get_python_3_9_path():
python_path
=
Path
(
result
.
strip
())
if
python_path
.
exists
():
return
str
(
python_path
)
console
.
print
(
"
[red]EPICPy requires Python 3. on Windows, but that version of Python could not be located on this system.
"
"
You can install Python 3.9 by running this command: uv python install 3.9[/red]
"
print
(
"
EPICPy requires Python 3.9 on Windows, but that version of Python could not be located on this system.
"
"
You can install Python 3.9 by running this command: uv python install 3.9
"
,
file
=
sys
.
stderr
,
)
sys
.
exit
(
1
)
...
...
@@ -85,15 +84,11 @@ def main():
# Step 1: Check if EPICpy is installed and uninstall it if necessary
uv_tool_list
=
run_command
([
"
uv
"
,
"
tool
"
,
"
list
"
])
if
uv_tool_list
and
"
EPICpy
"
in
uv_tool_list
:
console
.
print
(
"
[yellow]EPICpy is already installed. Uninstalling...[/yellow]
"
)
print
(
"
EPICpy is already installed. Uninstalling...
"
)
run_command
([
"
uv
"
,
"
tool
"
,
"
uninstall
"
,
"
EPICpy
"
])
# Step 2: Install EPICpy using the determined Python path
console
.
print
(
f
"
[cyan]Installing EPICpy with Python at
{
python_path
}
...[/cyan]
"
)
print
(
f
"
Installing EPICpy with Python at
{
python_path
}
...
"
)
install_output
=
run_command
(
[
"
uv
"
,
...
...
@@ -106,25 +101,19 @@ def main():
)
if
install_output
and
"
Installed 1 executable: EPICpy
"
in
install_output
:
console
.
print
(
"
[green]EPICpy installed successfully! You can run it from the terminal like this: EPICpy[/green]
"
)
print
(
"
EPICpy installed successfully! You can run it from the terminal like this: EPICpy
"
)
else
:
console
.
print
(
"
[red]Failed to install EPICpy. Please check the error above and try again.[/red]
"
)
print
(
"
Failed to install EPICpy. Please check the error above and try again.
"
,
file
=
sys
.
stderr
)
sys
.
exit
(
1
)
# Step 3: Check if epiccoder is installed and uninstall it if necessary
uv_tool_list
=
run_command
([
"
uv
"
,
"
tool
"
,
"
list
"
])
if
uv_tool_list
and
"
epiccoder
"
in
uv_tool_list
:
console
.
print
(
"
[yellow]epiccoder is already installed. Uninstalling...[/yellow]
"
)
print
(
"
epiccoder is already installed. Uninstalling...
"
)
run_command
([
"
uv
"
,
"
tool
"
,
"
uninstall
"
,
"
epiccoder
"
])
# Step 4: Install epiccoder
console
.
print
(
"
[cyan]
Installing epiccoder...
[/cyan]
"
)
print
(
"
Installing epiccoder...
"
)
epiccoder_output
=
run_command
(
[
"
uv
"
,
...
...
@@ -134,19 +123,13 @@ def main():
]
)
if
(
epiccoder_output
and
"
Installed 1 executable: epiccoder
"
in
epiccoder_output
):
console
.
print
(
"
[green]epiccoder installed successfully! You can run it from the terminal like this: epiccoder[/green]
"
)
if
epiccoder_output
and
"
Installed 1 executable: epiccoder
"
in
epiccoder_output
:
print
(
"
epiccoder installed successfully! You can run it from the terminal like this: epiccoder
"
)
else
:
console
.
print
(
"
[red]Failed to install epiccoder. Please check the error above and try again.[/red]
"
)
print
(
"
Failed to install epiccoder. Please check the error above and try again.
"
,
file
=
sys
.
stderr
)
sys
.
exit
(
1
)
if
__name__
==
"
__main__
"
:
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment