Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Spack
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
Container 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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
eic_tools
Spack
Commits
d8c44189
Commit
d8c44189
authored
8 years ago
by
Sergey Kosukhin
Browse files
Options
Downloads
Patches
Plain Diff
Updated python: refactoring and warning messages.
parent
3ba88a75
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
var/spack/repos/builtin/packages/python/package.py
+57
-36
57 additions, 36 deletions
var/spack/repos/builtin/packages/python/package.py
with
57 additions
and
36 deletions
var/spack/repos/builtin/packages/python/package.py
+
57
−
36
View file @
d8c44189
...
@@ -29,10 +29,11 @@
...
@@ -29,10 +29,11 @@
import
spack
import
spack
import
llnl.util.tty
as
tty
import
llnl.util.tty
as
tty
import
yaml
from
llnl.util.lang
import
match_predicate
from
llnl.util.lang
import
match_predicate
from
llnl.util.filesystem
import
force_remove
from
spack
import
*
from
spack
import
*
from
spack.util.environment
import
*
from
spack.util.environment
import
*
import
spack.util.spack_json
as
sjson
class
Python
(
Package
):
class
Python
(
Package
):
...
@@ -78,6 +79,10 @@ class Python(Package):
...
@@ -78,6 +79,10 @@ class Python(Package):
patch
(
'
ncurses.patch
'
)
patch
(
'
ncurses.patch
'
)
_DISTUTIL_VARS_TO_SAVE
=
[
'
LDSHARED
'
]
_DISTUTIL_CACHE_FILENAME
=
'
sysconfig.json
'
_distutil_vars
=
None
@when
(
'
@2.7,3.4:
'
)
@when
(
'
@2.7,3.4:
'
)
def
patch
(
self
):
def
patch
(
self
):
# NOTE: Python's default installation procedure makes it possible for a
# NOTE: Python's default installation procedure makes it possible for a
...
@@ -134,7 +139,7 @@ def install(self, spec, prefix):
...
@@ -134,7 +139,7 @@ def install(self, spec, prefix):
make
()
make
()
make
(
'
install
'
)
make
(
'
install
'
)
self
.
save_distutil
s_data
(
prefix
)
self
.
_
save_distutil
_vars
(
prefix
)
self
.
filter_compilers
(
prefix
)
self
.
filter_compilers
(
prefix
)
...
@@ -176,7 +181,7 @@ def install(self, spec, prefix):
...
@@ -176,7 +181,7 @@ def install(self, spec, prefix):
# >>> import Tkinter
# >>> import Tkinter
# >>> Tkinter._test()
# >>> Tkinter._test()
def
save_distutil
s_data
(
self
,
prefix
):
def
_
save_distutil
_vars
(
self
,
prefix
):
"""
"""
Run before changing automatically generated contents of the
Run before changing automatically generated contents of the
_sysconfigdata.py, which is used by distutils to figure out what
_sysconfigdata.py, which is used by distutils to figure out what
...
@@ -188,6 +193,8 @@ def save_distutils_data(self, prefix):
...
@@ -188,6 +193,8 @@ def save_distutils_data(self, prefix):
autogenerated value to pass it to the dependant package
'
s setup script.
autogenerated value to pass it to the dependant package
'
s setup script.
"""
"""
self
.
_distutil_vars
=
{}
input_filename
=
None
input_filename
=
None
for
filename
in
[
join_path
(
lib_dir
,
for
filename
in
[
join_path
(
lib_dir
,
'
python{0}
'
.
format
(
self
.
version
.
up_to
(
2
)),
'
python{0}
'
.
format
(
self
.
version
.
up_to
(
2
)),
...
@@ -201,7 +208,6 @@ def save_distutils_data(self, prefix):
...
@@ -201,7 +208,6 @@ def save_distutils_data(self, prefix):
return
return
input_dict
=
None
input_dict
=
None
try
:
try
:
with
open
(
input_filename
)
as
input_file
:
with
open
(
input_filename
)
as
input_file
:
match
=
re
.
search
(
r
'
build_time_vars\s*=\s*(?P<dict>{.*})
'
,
match
=
re
.
search
(
r
'
build_time_vars\s*=\s*(?P<dict>{.*})
'
,
...
@@ -214,45 +220,60 @@ def save_distutils_data(self, prefix):
...
@@ -214,45 +220,60 @@ def save_distutils_data(self, prefix):
pass
pass
if
not
input_dict
:
if
not
input_dict
:
tty
.
warn
(
'
Failed to find
\'
build_time_vars
\'
dictionary in file
'
'
\'
%s
\'
. This might cause the extensions that are
'
'
installed with distutils to call compilers directly
'
'
avoiding Spack
\'
s wrappers.
'
%
input_filename
)
return
return
vars_to_save
=
[
'
LDSHARED
'
]
for
var_name
in
Python
.
_DISTUTIL_VARS_TO_SAVE
:
saved_vars
=
{}
for
var_name
in
vars_to_save
:
if
var_name
in
input_dict
:
if
var_name
in
input_dict
:
saved_vars
[
var_name
]
=
input_dict
[
var_name
]
self
.
_distutil_vars
[
var_name
]
=
input_dict
[
var_name
]
else
:
if
len
(
saved_vars
)
>
0
:
tty
.
warn
(
'
Failed to find key
\'
%s
\'
in
\'
build_time_vars
\'
'
'
dictionary in file
\'
%s
\'
. This might cause the
'
'
extensions that are installed with distutils to
'
'
call compilers directly avoiding Spack
\'
s wrappers.
'
%
(
var_name
,
input_filename
))
if
len
(
self
.
_distutil_vars
)
>
0
:
output_filename
=
None
try
:
try
:
output_filename
=
join_path
(
output_filename
=
join_path
(
spack
.
store
.
layout
.
metadata_path
(
self
.
spec
),
spack
.
store
.
layout
.
metadata_path
(
self
.
spec
),
'
sysconfig.yaml
'
)
Python
.
_DISTUTIL_CACHE_FILENAME
)
with
open
(
output_filename
,
'
w
'
)
as
output_file
:
with
open
(
output_filename
,
'
w
'
)
as
output_file
:
yaml
.
dump
(
saved_vars
,
stream
=
output_file
,
sjson
.
dump
(
self
.
_distutil_vars
,
output_file
)
default_flow_style
=
False
)
except
:
except
(
yaml
.
YAMLError
,
IOError
):
tty
.
warn
(
'
Failed to save metadata for distutils. This might
'
'
cause the extensions that are installed with
'
'
distutils to call compilers directly avoiding
'
'
Spack
\'
s wrappers.
'
)
# We make the cache empty if we failed to save it to file
# to provide the same behaviour as in the case when the cache
# is initialized by the method load_distutils_data().
self
.
_distutil_vars
=
{}
if
output_filename
:
force_remove
(
output_filename
)
def
_load_distutil_vars
(
self
):
# We update and keep the cache unchanged only if the package is
# installed.
if
not
self
.
_distutil_vars
and
self
.
installed
:
try
:
input_filename
=
join_path
(
spack
.
store
.
layout
.
metadata_path
(
self
.
spec
),
Python
.
_DISTUTIL_CACHE_FILENAME
)
if
os
.
path
.
isfile
(
input_filename
):
with
open
(
input_filename
)
as
input_file
:
self
.
_distutil_vars
=
sjson
.
load
(
input_file
)
except
:
pass
pass
setattr
(
self
,
'
_distutils_data_cache
'
,
saved_vars
)
if
not
self
.
_distutil_vars
:
self
.
_distutil_vars
=
{}
def
load_distutils_data
(
self
):
if
not
hasattr
(
self
,
'
_distutils_data_cache
'
):
input_filename
=
join_path
(
spack
.
store
.
layout
.
metadata_path
(
self
.
spec
),
'
sysconfig.yaml
'
)
if
os
.
path
.
isfile
(
input_filename
):
try
:
with
open
(
input_filename
)
as
input_file
:
setattr
(
self
,
'
_distutils_data_cache
'
,
yaml
.
load
(
input_file
))
except
(
yaml
.
YAMLError
,
IOError
):
pass
if
not
hasattr
(
self
,
'
_distutils_data_cache
'
):
setattr
(
self
,
'
_distutils_data_cache
'
,
None
)
return
self
.
_distutil
s_data_cache
return
self
.
_distutil
_vars
def
filter_compilers
(
self
,
prefix
):
def
filter_compilers
(
self
,
prefix
):
"""
Run after install to tell the configuration files and Makefiles
"""
Run after install to tell the configuration files and Makefiles
...
@@ -350,10 +371,10 @@ def setup_dependent_package(self, module, ext_spec):
...
@@ -350,10 +371,10 @@ def setup_dependent_package(self, module, ext_spec):
module
.
python
=
Executable
(
python_path
)
module
.
python
=
Executable
(
python_path
)
module
.
setup_py
=
Executable
(
python_path
+
'
setup.py --no-user-cfg
'
)
module
.
setup_py
=
Executable
(
python_path
+
'
setup.py --no-user-cfg
'
)
distutil
s_data
=
self
.
load_distutil
s_data
()
distutil
_vars
=
self
.
_
load_distutil
_vars
()
if
distutil
s_data
:
if
distutil
_vars
:
for
key
,
value
in
distutil
s_data
.
iteritems
():
for
key
,
value
in
distutil
_vars
.
iteritems
():
module
.
setup_py
.
add_default_env
(
key
,
value
)
module
.
setup_py
.
add_default_env
(
key
,
value
)
# Add variables for lib/pythonX.Y and lib/pythonX.Y/site-packages dirs.
# Add variables for lib/pythonX.Y and lib/pythonX.Y/site-packages dirs.
...
...
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