Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
workspaces
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
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
ssa
workspaces
Commits
0fd2cdca
Commit
0fd2cdca
authored
4 years ago
by
Nathan Hertz
Browse files
Options
Downloads
Patches
Plain Diff
Added logging to setup_to_meta and build_pkgs.
parent
9951a251
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
build/recipes/build_pkgs/build_pkgs.py
+8
-1
8 additions, 1 deletion
build/recipes/build_pkgs/build_pkgs.py
build/recipes/setup_to_meta/setup_to_meta.py
+16
-4
16 additions, 4 deletions
build/recipes/setup_to_meta/setup_to_meta.py
with
24 additions
and
5 deletions
build/recipes/build_pkgs/build_pkgs.py
+
8
−
1
View file @
0fd2cdca
import
subprocess
import
logging
logger
=
logging
.
getLogger
(
"
buildout/build_pkgs
"
)
def
get_dirs
():
"""
Finds all subdirectories containing setup.py files.
:return: List of directories as strings.
"""
logger
.
debug
(
"
Getting list of directories containing setup.py files...
"
)
find
=
subprocess
.
run
([
'
find
'
,
'
.
'
,
'
-name
'
,
'
setup.py
'
,
'
-not
'
,
'
-path
'
,
'
./build/recipes/*
'
],
stdout
=
subprocess
.
PIPE
)
...
...
@@ -14,6 +18,7 @@ def get_dirs():
for
i
,
d
in
enumerate
(
dirs_cpy
):
dirs
[
i
]
=
d
.
replace
(
'
/setup.py
'
,
''
)
logger
.
debug
(
"
Done getting directories.
"
)
return
dirs
def
get_names
(
dirs
):
...
...
@@ -22,6 +27,7 @@ def get_names(dirs):
subproject directory will be the name of the subproject.
:return: List of names as strings.
"""
logger
.
debug
(
"
Generating list of subproject names...
"
)
names
=
[]
for
d
in
dirs
:
if
d
!=
''
:
...
...
@@ -32,6 +38,7 @@ def get_names(dirs):
name
=
"
services
"
names
.
append
(
name
)
logger
.
debug
(
"
Done generating.
"
)
return
names
class
Recipe
:
...
...
@@ -59,7 +66,7 @@ class Recipe:
for
p
in
pkgs
:
if
p
not
in
self
.
pkg_list
or
p
==
''
:
print
(
"
Package {} not valid. Skipping.
"
.
format
(
p
)
)
logger
.
error
(
f
"
Package
{
p
}
not valid. Skipping.
"
)
continue
subprocess
.
run
([
"
conda
"
,
"
build
"
,
"
build/metadata/{}
"
.
format
(
p
),
"
--output-folder
"
,
"
build/pkgs/
"
],
stdout
=
subprocess
.
PIPE
)
...
...
This diff is collapsed.
Click to expand it.
build/recipes/setup_to_meta/setup_to_meta.py
+
16
−
4
View file @
0fd2cdca
import
json
import
setuptools
,
importlib
,
subprocess
,
os
,
re
import
subprocess
import
logging
import
json
import
os
PYTHON_VERSION
=
'
3.8
'
logger
=
logging
.
getLogger
(
"
buildout/setup_to_meta
"
)
def
write_metafile
(
metadata
,
filepath
):
"""
Writes given metadata to file with given path.
"""
logger
.
debug
(
f
"
Writing meta.yaml file at
{
filepath
}
...
"
)
try
:
os
.
makedirs
(
filepath
[:
-
10
])
except
FileExistsError
:
...
...
@@ -15,6 +19,7 @@ def write_metafile(metadata, filepath):
with
open
(
filepath
,
'
w
'
)
as
f
:
f
.
write
(
metadata
)
logger
.
debug
(
"
Done writing.
"
)
class
MetadataGenerator
:
...
...
@@ -89,6 +94,7 @@ class MetadataGenerator:
return
test_string
def
generate
(
self
):
logger
.
debug
(
f
"
Generating meta.yaml file from
{
self
.
path
}
...
"
)
# Filter numpy etc. out of the requirements
try
:
self
.
setup
[
'
install_requires
'
]
=
[
req
for
req
in
self
.
setup
[
'
install_requires
'
]
if
req
!=
'
numpy
'
]
...
...
@@ -106,7 +112,8 @@ class MetadataGenerator:
with
open
(
'
build/tools/metafile_template.txt
'
,
'
r
'
)
as
f
:
metadata
=
f
.
read
()
logger
.
debug
(
"
Done generating.
"
)
return
metadata
.
format
(
name
=
name
,
version
=
version
,
...
...
@@ -126,12 +133,14 @@ def parse_setup(d):
:param d: Directory with a setup.py file.
:return: Data collected from parse_setup.py.
"""
logger
.
debug
(
f
"
Parsing setup.py at
{
d
}
...
"
)
subprocess
.
run
([
'
cp
'
,
'
build/tools/parse_setup.py
'
,
d
])
os
.
chdir
(
d
)
proc
=
subprocess
.
run
([
'
python3
'
,
'
parse_setup.py
'
],
stdout
=
subprocess
.
PIPE
)
os
.
chdir
(
root
)
subprocess
.
run
([
'
rm
'
,
'
{}/parse_setup.py
'
.
format
(
d
)])
logger
.
debug
(
"
Done parsing.
"
)
return
json
.
loads
(
proc
.
stdout
)
def
get_outputs
(
names
):
...
...
@@ -151,6 +160,7 @@ def get_dirs():
Finds all subdirectories containing setup.py files.
:return: List of directories as strings.
"""
logger
.
debug
(
"
Finding list of directories containing setup.py files...
"
)
find
=
subprocess
.
run
([
'
find
'
,
'
.
'
,
'
-name
'
,
'
setup.py
'
,
'
-not
'
,
'
-path
'
,
'
./build/recipes/*
'
],
stdout
=
subprocess
.
PIPE
)
...
...
@@ -160,6 +170,7 @@ def get_dirs():
for
i
,
d
in
enumerate
(
dirs_cpy
):
dirs
[
i
]
=
d
.
replace
(
'
/setup.py
'
,
''
)
logger
.
debug
(
"
Done finding directories.
"
)
return
dirs
def
get_names
(
dirs
):
...
...
@@ -168,6 +179,7 @@ def get_names(dirs):
subproject directory will be the name of the subproject.
:return: List of names as strings.
"""
logger
.
debug
(
"
Getting list of names...
"
)
names
=
[]
for
d
in
dirs
:
if
d
!=
''
:
...
...
@@ -178,6 +190,7 @@ def get_names(dirs):
name
=
"
services
"
names
.
append
(
name
)
logger
.
debug
(
"
Done getting list of names.
"
)
return
names
def
del_substrings
(
s
,
substrings
):
...
...
@@ -213,7 +226,6 @@ class Recipe:
self
.
outputs
=
get_outputs
(
self
.
names
)
self
.
options
=
options
# TODO: Keep track of path in setup_dict
def
install
(
self
):
"""
Install method that runs when recipe has components it needs to install.
...
...
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