Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
Poulpe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
octobus
Poulpe
Commits
bf4de3f2
Commit
bf4de3f2
authored
1 year ago
by
Pierre-Yves David
Browse files
Options
Downloads
Patches
Plain Diff
XXX refresh script (make it an option of the setup instead)
parent
95383c16
Branches
topic/default/refresh-den
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/refresh-poulpe-den
+206
-0
206 additions, 0 deletions
bin/refresh-poulpe-den
with
206 additions
and
0 deletions
bin/refresh-poulpe-den
0 → 100755
+
206
−
0
View file @
bf4de3f2
#!/usr/bin/env python3
import
os
import
stat
import
sys
import
subprocess
import
glob
from
pathlib
import
Path
USAGE
=
"
USAGE: %s ROOTPATH
"
%
os
.
path
.
basename
(
sys
.
argv
[
0
])
POULPE_DIR
=
Path
(
__file__
).
absolute
().
parent
.
parent
RESULT_DIR
=
"
results
"
BIN_ENV_DIR
=
"
bin-envs
"
DATA_ENV_DIR
=
"
data-envs
"
BENCHMARK_DIR
=
"
benchmarks
"
REPOSITORIES_DIR
=
"
repositories
"
DIRECTORIES
=
[
RESULT_DIR
,
BIN_ENV_DIR
,
DATA_ENV_DIR
,
BENCHMARK_DIR
,
REPOSITORIES_DIR
,
]
SUITE_DIR
=
"
suites
"
TOOLING
=
"
tooling
"
def
re_install_poulpe
(
poulpe_dir
):
"""
reset any venv and install poulpe in it
"""
venv
=
Path
(
"
.venv
"
)
if
venv
.
exists
():
print
(
"
Deleting existing venv
"
)
shutil
.
rmtree
(
venv
)
print
(
"
Installing poulpe (editable) into a new venv
"
)
install_venv
=
[
sys
.
executable
,
"
-m
"
,
"
venv
"
,
"
.venv
"
]
update_pip
=
[
str
(
Path
(
"
.venv
"
)
/
"
bin
"
/
"
pip
"
),
"
install
"
,
"
--quiet
"
,
"
--upgrade
"
,
"
pip
"
,
]
install_poulpe
=
[
str
(
Path
(
"
.venv
"
)
/
"
bin
"
/
"
pip
"
),
"
install
"
,
"
--quiet
"
,
"
--editable
"
,
str
(
poulpe_dir
),
]
# TODO fix the symlink support thing
commands
=
[
install_venv
,
update_pip
,
install_poulpe
]
for
command
in
commands
:
subprocess
.
run
(
command
,
check
=
True
)
ACTIVATE
=
"""
#!/bin/bash
export POULPE_BASE_DIR=
"
%s
"
.
"
$POULPE_BASE_DIR
"
/.venv/bin/activate
# setup autocomplete
if [ ! -z ${ZSH_VERSION+x} ]; then
eval
"
$(_POULPE_COMPLETE=zsh_source poulpe)
"
elif [ ! -z ${BASH_VERSION+x} ]; then
eval
"
$(_POULPE_COMPLETE=bash_source poulpe)
"
fi
"""
POULPE_PROXY
=
"""
#!/bin/bash
base=
"
`dirname $0`
"
.
"
$base
"
/activate
poulpe
"
$@
"
"""
BASH_PROXY
=
"""
#!/bin/bash
base=
"
`dirname $0`
"
.
"
$base
"
/activate
"
$@
"
"""
def
setup_quick_access
(
base_dir
):
print
(
'
Creating a
"
bin/
"
directory with a few utilities
'
)
Path
(
"
bin
"
).
mkdir
(
parents
=
True
)
dir_bin
=
Path
(
"
bin
"
)
poulpe_proxy
=
dir_bin
/
"
poulpe
"
poulpe_proxy
.
write_text
(
POULPE_PROXY
)
poulpe_proxy
.
chmod
(
poulpe_proxy
.
stat
().
st_mode
|
stat
.
S_IEXEC
)
activate
=
dir_bin
/
"
activate
"
activate
.
write_text
(
ACTIVATE
%
base_dir
)
bash_proxy
=
dir_bin
/
"
shell
"
bash_proxy
.
write_text
(
BASH_PROXY
)
bash_proxy
.
chmod
(
bash_proxy
.
stat
().
st_mode
|
stat
.
S_IEXEC
)
def
clone_one_repo
(
repo_dir
,
repo_type
,
url
,
dest
):
dest
=
repo_dir
/
dest
if
repo_type
!=
"
hg
"
:
raise
NotImplementedError
(
repo_type
)
clone_hg
(
url
,
dest
)
def
clone_hg
(
source
,
dest
):
environ
=
os
.
environ
.
copy
()
environ
[
"
HGRCPATH
"
]
=
""
environ
[
"
HGPLAIN
"
]
=
""
command
=
[
"
hg
"
,
"
clone
"
,
"
--quiet
"
,
source
,
dest
,
]
if
"
TESTTMP
"
in
environ
:
command
.
extend
(
[
"
--config
"
,
"
extensions.share=
"
,
"
--config
"
,
"
share.poolnaming=remote
"
,
"
--config
"
,
f
"
share.pool=
{
POULPE_DIR
}
/.repos_caches
"
,
]
)
subprocess
.
run
(
command
,
check
=
True
)
def
setup_base_dir
(
path
):
base_path
=
Path
(
path
).
absolute
()
print
(
"
Creating folders
"
)
base_path
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
for
d
in
DIRECTORIES
:
base_path
.
joinpath
(
d
).
mkdir
(
exist_ok
=
True
)
old_dir
=
os
.
curdir
os
.
chdir
(
base_path
)
try
:
tooling
=
Path
(
TOOLING
)
tooling
.
mkdir
(
exist_ok
=
True
)
local_poulpe
=
tooling
/
"
poulpe
"
print
(
"
Create symlinks to Poulpe
"
)
if
not
local_poulpe
.
exists
():
os
.
symlink
(
POULPE_DIR
.
resolve
(),
local_poulpe
)
os
.
symlink
(
local_poulpe
/
SUITE_DIR
,
SUITE_DIR
)
bench
=
base_path
/
BENCHMARK_DIR
bench_glob
=
local_poulpe
.
absolute
()
/
SUITE_DIR
/
'
*
'
/
'
benchmarks
'
for
p
in
glob
.
glob
(
str
(
bench_glob
)):
b
=
Path
(
p
).
relative_to
(
base_path
)
suite_name
=
b
.
parent
.
name
if
not
(
bench
/
suite_name
).
exists
():
os
.
symlink
(
'
..
'
/
b
,
bench
/
suite_name
)
re_install_poulpe
(
local_poulpe
)
setup_quick_access
(
base_path
)
finally
:
os
.
chdir
(
old_dir
)
print
(
"
Cloning repositories to benchmark
"
)
repos
=
base_path
/
REPOSITORIES_DIR
for
listing
in
glob
.
glob
(
str
(
base_path
/
'
suites
'
/
'
*
'
/
'
repositories
'
)):
with
open
(
listing
)
as
f
:
for
line
in
f
:
line
=
line
.
strip
()
if
not
line
.
startswith
(
'
#
'
):
spec
=
line
.
split
()
if
len
(
spec
)
!=
3
:
msg
=
"
ignoring malformated repository line: %r
"
msg
%=
line
print
(
msg
,
file
=
sys
.
stderr
)
repo_type
,
url
,
dest
=
spec
if
not
(
repos
/
dest
).
exists
():
clone_one_repo
(
repos
,
repo_type
,
url
,
dest
)
print
(
"
Updating environment variables
"
)
repos
=
base_path
/
REPOSITORIES_DIR
activate
=
base_path
/
"
bin
"
/
"
activate
"
for
env
in
glob
.
glob
(
str
(
base_path
/
'
suites
'
/
'
*
'
/
'
environment
'
)):
source
=
Path
(
p
).
relative_to
(
base_path
)
with
activate
.
open
(
mode
=
"
a
"
)
as
f
:
f
.
write
(
"
\n
# from %s
\n
"
%
source
)
with
open
(
env
)
as
e
:
f
.
write
(
e
.
read
())
print
(
f
'
Poulpe Den ready to use in
"
{
base_path
}
"'
)
if
__name__
==
"
__main__
"
:
if
len
(
sys
.
argv
)
!=
2
or
sys
.
argv
[
1
].
startswith
(
'
-
'
):
print
(
USAGE
,
file
=
sys
.
stderr
)
sys
.
exit
(
128
)
else
:
ret
=
setup_base_dir
(
sys
.
argv
[
1
])
sys
.
exit
(
ret
)
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