Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.buildout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
6
Merge Requests
6
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
slapos.buildout
Commits
1ef1daf7
Commit
1ef1daf7
authored
Oct 15, 2022
by
Godefroid Chapelle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor: move top level code to function
parent
80006c77
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
159 additions
and
155 deletions
+159
-155
dev.py
dev.py
+159
-155
No files found.
dev.py
View file @
1ef1daf7
...
@@ -29,21 +29,22 @@ import os, shutil, subprocess, tempfile
...
@@ -29,21 +29,22 @@ import os, shutil, subprocess, tempfile
os
.
environ
[
"SETUPTOOLS_USE_DISTUTILS"
]
=
"stdlib"
os
.
environ
[
"SETUPTOOLS_USE_DISTUTILS"
]
=
"stdlib"
for
d
in
'eggs'
,
'develop-eggs'
,
'bin'
,
'parts'
:
def
main
():
for
d
in
'eggs'
,
'develop-eggs'
,
'bin'
,
'parts'
:
if
not
os
.
path
.
exists
(
d
):
if
not
os
.
path
.
exists
(
d
):
os
.
mkdir
(
d
)
os
.
mkdir
(
d
)
bin_buildout
=
os
.
path
.
join
(
'bin'
,
'buildout'
)
bin_buildout
=
os
.
path
.
join
(
'bin'
,
'buildout'
)
if
os
.
path
.
isfile
(
bin_buildout
):
if
os
.
path
.
isfile
(
bin_buildout
):
os
.
remove
(
bin_buildout
)
os
.
remove
(
bin_buildout
)
if
os
.
path
.
isdir
(
'build'
):
if
os
.
path
.
isdir
(
'build'
):
shutil
.
rmtree
(
'build'
)
shutil
.
rmtree
(
'build'
)
print
(
"Current directory %s"
%
os
.
getcwd
())
print
(
"Current directory %s"
%
os
.
getcwd
())
#######################################################################
#######################################################################
def
install_pip
():
def
install_pip
():
print
(
''
)
print
(
''
)
print
(
'Install pip'
)
print
(
'Install pip'
)
print
(
''
)
print
(
''
)
...
@@ -76,7 +77,7 @@ def install_pip():
...
@@ -76,7 +77,7 @@ def install_pip():
)
)
sys
.
exit
(
return_code
)
sys
.
exit
(
return_code
)
try
:
try
:
import
pip
import
pip
print
(
''
)
print
(
''
)
try
:
try
:
...
@@ -94,11 +95,11 @@ try:
...
@@ -94,11 +95,11 @@ try:
b"ModuleNotFoundError"
in
e
.
output
):
b"ModuleNotFoundError"
in
e
.
output
):
install_pip
()
install_pip
()
raise
e
raise
e
except
ImportError
:
except
ImportError
:
install_pip
()
install_pip
()
######################################################################
######################################################################
def
check_upgrade
(
package
):
def
check_upgrade
(
package
):
print
(
''
)
print
(
''
)
print
(
'Try to upgrade %s'
%
package
)
print
(
'Try to upgrade %s'
%
package
)
print
(
''
)
print
(
''
)
...
@@ -125,7 +126,7 @@ def check_upgrade(package):
...
@@ -125,7 +126,7 @@ def check_upgrade(package):
raise
RuntimeError
(
"Upgrade %s failed."
%
package
)
raise
RuntimeError
(
"Upgrade %s failed."
%
package
)
def
show
(
package
):
def
show
(
package
):
try
:
try
:
sys
.
stdout
.
flush
()
sys
.
stdout
.
flush
()
output
=
subprocess
.
check_output
(
output
=
subprocess
.
check_output
(
...
@@ -138,40 +139,40 @@ def show(package):
...
@@ -138,40 +139,40 @@ def show(package):
raise
RuntimeError
(
"Upgrade %s failed."
%
package
)
raise
RuntimeError
(
"Upgrade %s failed."
%
package
)
need_restart
=
False
need_restart
=
False
for
package
in
[
'pip'
,
'setuptools'
,
'wheel'
]:
for
package
in
[
'pip'
,
'setuptools'
,
'wheel'
]:
did_upgrade
=
check_upgrade
(
package
)
did_upgrade
=
check_upgrade
(
package
)
show
(
package
)
show
(
package
)
need_restart
=
need_restart
or
did_upgrade
need_restart
=
need_restart
or
did_upgrade
if
need_restart
:
if
need_restart
:
print
(
"Restart"
)
print
(
"Restart"
)
sys
.
stdout
.
flush
()
sys
.
stdout
.
flush
()
return_code
=
subprocess
.
call
(
return_code
=
subprocess
.
call
(
[
sys
.
executable
]
+
sys
.
argv
[
sys
.
executable
]
+
sys
.
argv
)
)
sys
.
exit
(
return_code
)
sys
.
exit
(
return_code
)
######################################################################
######################################################################
print
(
''
)
print
(
''
)
print
(
'Install buildout'
)
print
(
'Install buildout'
)
print
(
''
)
print
(
''
)
sys
.
stdout
.
flush
()
sys
.
stdout
.
flush
()
if
subprocess
.
call
(
if
subprocess
.
call
(
[
sys
.
executable
]
+
[
sys
.
executable
]
+
[
'setup.py'
,
'-q'
,
'develop'
,
'-m'
,
'-x'
,
'-d'
,
'develop-eggs'
],
[
'setup.py'
,
'-q'
,
'develop'
,
'-m'
,
'-x'
,
'-d'
,
'develop-eggs'
],
):
):
raise
RuntimeError
(
"buildout build failed."
)
raise
RuntimeError
(
"buildout build failed."
)
import
pkg_resources
import
pkg_resources
pkg_resources
.
working_set
.
add_entry
(
'src'
)
pkg_resources
.
working_set
.
add_entry
(
'src'
)
import
zc.buildout.easy_install
import
zc.buildout.easy_install
zc
.
buildout
.
easy_install
.
scripts
(
zc
.
buildout
.
easy_install
.
scripts
(
[
'zc.buildout'
],
pkg_resources
.
working_set
,
sys
.
executable
,
'bin'
)
[
'zc.buildout'
],
pkg_resources
.
working_set
,
sys
.
executable
,
'bin'
)
######################################################################
######################################################################
def
install_coverage
():
def
install_coverage
():
print
(
''
)
print
(
''
)
print
(
'Install coverage'
)
print
(
'Install coverage'
)
print
(
''
)
print
(
''
)
...
@@ -182,20 +183,23 @@ def install_coverage():
...
@@ -182,20 +183,23 @@ def install_coverage():
):
):
raise
RuntimeError
(
"coverage install failed."
)
raise
RuntimeError
(
"coverage install failed."
)
try
:
try
:
import
coverage
import
coverage
except
ImportError
:
except
ImportError
:
install_coverage
()
install_coverage
()
######################################################################
######################################################################
print
(
''
)
print
(
''
)
print
(
'Run buildout'
)
print
(
'Run buildout'
)
print
(
''
)
print
(
''
)
bin_buildout
=
os
.
path
.
join
(
'bin'
,
'buildout'
)
bin_buildout
=
os
.
path
.
join
(
'bin'
,
'buildout'
)
if
sys
.
platform
.
startswith
(
'java'
):
if
sys
.
platform
.
startswith
(
'java'
):
# Jython needs the script to be called twice via sys.executable
# Jython needs the script to be called twice via sys.executable
assert
subprocess
.
Popen
([
sys
.
executable
,
bin_buildout
,
'-N'
]).
wait
()
==
0
assert
subprocess
.
Popen
([
sys
.
executable
,
bin_buildout
,
'-N'
]).
wait
()
==
0
sys
.
stdout
.
flush
()
sys
.
stdout
.
flush
()
sys
.
exit
(
subprocess
.
Popen
(
bin_buildout
).
wait
())
sys
.
exit
(
subprocess
.
Popen
(
bin_buildout
).
wait
())
if
__name__
==
'__main__'
:
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment