Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
add sage_python_library and sage_noarch packages
Browse files Browse the repository at this point in the history
  • Loading branch information
vbraun committed Jun 16, 2014
1 parent f3438e5 commit bc71b57
Show file tree
Hide file tree
Showing 15 changed files with 160 additions and 38 deletions.
5 changes: 4 additions & 1 deletion build/manager/sage_pkg/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,20 @@ def list_all(self, category=None):
baz standard 2.0.1 not installed
foo standard 1.3 not installed
"""
packages = loader.get_all()

def print_line(name, category, version, status):
print('{0:<30} {1:>8} {2:>18} {3:>18}'.format(
name, category, version, status))

print_line(
'Package name',
'Category',
'Version',
'Status',
)
print('-' * 78)
for pkg in loader.get_all():
for pkg in packages:
print_line(pkg.name, pkg.category, pkg.version, pkg.status)

def info(self, pkg):
Expand Down
19 changes: 12 additions & 7 deletions build/manager/sage_pkg/config_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ def __iter__(self):
def __len__(self):
return self._dictionary.__len__()

def __repr__(self):
return 'frozen' + repr(self._dictionary)


class ConfigYAML(object):

Expand Down Expand Up @@ -216,12 +219,14 @@ def __call__(self, *args, **kwds):
except KeyError:
have_default = False
value = self._c
for key in args:
try:
try:
for key in args:
if not isinstance(value, (dict, FrozenDictProxy)):
raise KeyError('parent is not a dict, cannot get key = ' + key)
value = value[key]
except KeyError:
if have_default:
return default
else:
raise
except KeyError:
if have_default:
return default
else:
raise
return value
2 changes: 1 addition & 1 deletion build/manager/sage_pkg/git/blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def get(self, filename):
for mode, name, sha1 in self.ls():
if name == filename:
return sha1
raise ValueError('file is not in the tree')
raise ValueError('file is not in the tree: ' + filename)

def _compare_files(self, dirname, verbose=False):
"""
Expand Down
39 changes: 26 additions & 13 deletions build/manager/sage_pkg/package/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ def deps(dep_type):
self._test_dependencies = deps('test')
self._compile_dependencies = deps('compile')

def _validate(self):
"""
Hook for validating package config
"""
pass

def __eq__(self, other):
return self._config.name == other._config.name

Expand Down Expand Up @@ -240,12 +246,19 @@ def status(self):
elif self.dependency_stamp == self.metadata.dependency_stamp:
return 'up to date'
elif self.version_stamp == self.metadata.version_stamp:
return 'dependencies changed'
return 'modified deps'
else:
return 'old version'

@cached_property
def age(self):
"""
Human-readable age of the installation
OUTPUT:
String. Only suitable for the UI
"""
if not self.metadata.previous:
return 'NA'
return pretty_age(self.metadata.time)
Expand Down Expand Up @@ -334,7 +347,7 @@ def build_tasks(self, dependencies, stop_at='install'):
>>> foo = loader.get('foo')
>>> deps = dict()
>>> tasks = foo.build_tasks(deps); tasks
[foo-download, foo-unpack, foo-prepare, foo-configure, foo-compile, foo-install]
[foo:download, foo:unpack, foo:prepare, foo:configure, foo:compile, foo:install]
>>> for task in tasks: print task.work
<bound method TestPackage.download of foo>
<bound method TestPackage.unpack of foo>
Expand All @@ -347,17 +360,17 @@ def build_tasks(self, dependencies, stop_at='install'):
dependency on the package name::
>>> deps
{foo: foo-install}
{foo: foo:install}
You can also stop before installation, in which case ``deps``
is never modified::
>>> foo.build_tasks(deps, stop_at='download')
[foo-download]
[foo:download]
>>> foo.build_tasks(deps, stop_at='unpack')
[foo-download, foo-unpack]
[foo:download, foo:unpack]
>>> foo.build_tasks(deps, stop_at='prepare')
[foo-download, foo-unpack, foo-prepare]
[foo:download, foo:unpack, foo:prepare]
>>> foo.build_tasks(deps, stop_at='unknownvalue')
Traceback (most recent call last):
Expand All @@ -367,35 +380,35 @@ def build_tasks(self, dependencies, stop_at='install'):
from sage_pkg.task_queue import Task
dependencies[self] = None # default if you skip installation
tasklist = []
task_download = prev = Task(self.download, [], name='{0}-download' .format(self.name))
task_download = prev = Task(self.download, [], name='{0}:download' .format(self.name))
tasklist.append(prev)
if stop_at == 'download':
return tasklist
build = [prev] + [dependencies[dep] for dep in self.get_compile_dependencies()]
task_unpack = prev = Task(self.unpack, build, name='{0}-unpack' .format(self.name))
task_unpack = prev = Task(self.unpack, build, name='{0}:unpack' .format(self.name))
tasklist.append(prev)
if stop_at == 'unpack':
return tasklist
task_prepare = prev = Task(self.prepare, [prev], name='{0}-prepare' .format(self.name))
task_prepare = prev = Task(self.prepare, [prev], name='{0}:prepare' .format(self.name))
tasklist.append(prev)
if stop_at == 'prepare':
return tasklist
hard = [prev] + [dependencies[dep] for dep in self.get_hard_dependencies()]
task_configure = prev = Task(self.configure, hard, name='{0}-configure'.format(self.name))
task_configure = prev = Task(self.configure, hard, name='{0}:configure'.format(self.name))
tasklist.append(prev)
if stop_at == 'configure':
return tasklist
task_compile = prev = Task(self.compile, [prev], name='{0}-compile' .format(self.name))
task_compile = prev = Task(self.compile, [prev], name='{0}:compile' .format(self.name))
tasklist.append(prev)
if stop_at == 'compile':
return tasklist
if self.want_check():
test = [prev] + [dependencies[dep] for dep in self.get_test_dependencies()]
task_check = prev = Task(self.check, test, name='{0}-check' .format(self.name))
task_check = prev = Task(self.check, test, name='{0}:check' .format(self.name))
tasklist.append(prev)
if stop_at == 'check':
return tasklist
task_install = prev = Task(self.install, [prev], name='{0}-install' .format(self.name))
task_install = prev = Task(self.install, [prev], name='{0}:install' .format(self.name))
tasklist.append(prev)
if stop_at != 'install':
raise ValueError('unknown value for the stop_at parameter')
Expand Down
2 changes: 1 addition & 1 deletion build/manager/sage_pkg/package/package_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class PackageConfig(ConfigYAML):
- config.builder.install_script = spkg-install
- config.builder.type = TestPackage
- config.category = standard
- config.depends.build = None
- config.depends.compile = None
- config.depends.hard = ['bar']
- config.depends.soft = None
- config.depends.test = None
Expand Down
2 changes: 1 addition & 1 deletion build/manager/sage_pkg/package/sage_mirror_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class SageMirrorMixin(object):

def _validate(self):
super(SageMirrorMixin, self)._validate()
self._require(
self._config._require(
'source.tarball.name',
'source.tarball.sha1',
)
Expand Down
9 changes: 4 additions & 5 deletions build/manager/sage_pkg/package/shell_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ShellCommands(SourceVersionStampMixin, SageEnvironmentMixin, PackageBase):

def _validate(self):
super(ShellCommands, self)._validate()
self._require(
self._config._require(
'builder.workdir',
'builder.commands',
)
Expand All @@ -33,8 +33,7 @@ def install(self):
env = self.get_environment()
builder = self._config.builder
work_dir = os.path.join(config.path.root, builder.workdir)
with chdir(work_dir):
for cmd in builder.commands:
logger.debug('%s: executing %s', self.name, cmd)
subprocess.check_call(cmd, env=env, shell=True)
for cmd in builder.commands:
logger.debug('%s: executing %s', self.name, cmd)
subprocess.check_call(cmd, env=env, shell=True, cwd=work_dir)
super(ShellCommands, self).install()
21 changes: 20 additions & 1 deletion build/manager/sage_pkg/package/source_version_stamp_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
dependency computatons) not only depend on the package directory, but
also no other directories of the repository.
"""

import os

from sage_pkg.config import config
from sage_pkg.utils import random_sha1, cached_property
Expand All @@ -14,6 +16,23 @@

class SourceVersionStampMixin(object):

def _validate(self):
super(SourceVersionStampMixin, self)._validate()
self._config._require(
'source',
)
for source_dir in self.source_iter():
if not os.path.exists(source_dir):
raise ValueError('package {0} specifies non-existing source {1}'
.format(self.name, source_dir))

def source_iter(self):
"""
Iterate over the sources specified in the package config
"""
for source_dir in self._config.source:
yield source_dir

def _directory_version_stamp(self, directory):
git = GitRepository(config.path.dot_git)
if git.is_clean_dir(directory):
Expand All @@ -38,6 +57,6 @@ def version_stamp(self):
"""
acc = CommutingSha1Accumulator()
acc += self._version_stamp
for source_dir in self._config.source:
for source_dir in self.source_iter():
acc += self._directory_version_stamp(source_dir)
return str(acc)
9 changes: 3 additions & 6 deletions build/manager/sage_pkg/package/spkg_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import subprocess

from sage_pkg.config import config
from sage_pkg.chdir_context import chdir
from sage_pkg.utils import cached_property
from .base import PackageBase
from .sage_mirror_mixin import SageMirrorMixin
Expand All @@ -19,7 +18,7 @@ class SpkgInstallScript(SageEnvironmentMixin, SageMirrorMixin, PackageBase):

def _validate(self):
super(SpkgInstallScript, self)._validate()
self._require(
self._config._require(
'source.version',
'builder.install_script',
)
Expand Down Expand Up @@ -83,15 +82,13 @@ def make_executable(script):

def install(self):
env = self.get_environment()
with chdir(self.build_dir):
subprocess.check_call('sage-spkg-sage_pkg', env=env, shell=True)
subprocess.check_call('sage-spkg-sage_pkg', env=env, shell=True, cwd=self.build_dir)
super(SpkgInstallScript, self).install()

def check(self):
if not (self.want_check() and self.check_script):
return
env = self.get_environment()
with chdir(self.build_dir):
subprocess.check_call(self.check_script)
subprocess.check_call(self.check_script, cwd=self.build_dir)
super(SpkgInstallScript, self).check()

3 changes: 3 additions & 0 deletions build/manager/sage_pkg/package_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ def get_all(self):
pkg_dict = dict((pkg.name, pkg) for pkg in result)
for pkg in result:
pkg._init_dependencies(pkg_dict)
# finally, call the validation hook
for pkg in result:
pkg._validate()
self._packages = tuple(sorted(result))
return self._packages

Expand Down
2 changes: 1 addition & 1 deletion build/manager/sage_pkg/upgrade_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
'iconv': [],
'docutils': ['python'],
'elliptic_curves': ['python', 'sqlite'],
'conway': [],
'conway': ['sage_python_library', 'sage_noarch', 'sagenb', 'ipython'],
'graphs': [],
'glpk': ['mpir', 'zlib'],
'python': ['zlib', 'bzip2', 'pkgconf', 'readline', 'sqlite', 'libpng'],
Expand Down
2 changes: 1 addition & 1 deletion build/manager/test_data/test_pkgs/baz/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ depends:
- bar
soft:
test:
build:
compile:
3 changes: 3 additions & 0 deletions build/pkgs/sage_c_library/package.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
summary:
C Support Library for Sage

name:
sage_c_library

Expand Down
21 changes: 21 additions & 0 deletions build/pkgs/sage_noarch/package.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
summary:
Architecture-Independent Files of Sage

name:
sage_noarch

category:
standard

source:
- src/bin
- src/ext

builder:
type: ShellCommands
workdir: src
commands:
- cp -r -p -f bin/* "$SAGE_LOCAL/bin/"
- cp -r -p -f ext/* "$SAGE_EXTCODE/"

depends:

0 comments on commit bc71b57

Please sign in to comment.