This repository has been archived by the owner on Jan 30, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
162 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Sage-Bootstrap | ||
|
||
This is a utility libary for dealing with third-party tarballs and | ||
building Sage. You should never import anything from the actual Sage | ||
library here, nor should you import anything from sage_bootstrap into | ||
Sage (because this would reconfigure logging). They must be kept | ||
separate. | ||
|
||
Everything here must support Python 2.6, 2.7, and 3.3+. Use tox to | ||
automatically run the tests with all relevant Python versions. Tests | ||
are written as unittest, not as doctests, because the library is not | ||
meant to be used interactively. Note that the library comes with a | ||
setup.py file so that tox can test it, but it is not meant to be | ||
installed to SAGE_LOCAL. | ||
|
||
Command-line utilities must be able to run as part of a pipe | filter | ||
chain. So you have to be careful about what you send to stdout. You | ||
should use: | ||
|
||
* print() for anything that is meant to be sent to the output pipe. | ||
|
||
* log.info() for human-readable messages about the normal program | ||
flow. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env python | ||
|
||
try: | ||
import sage_bootstrap | ||
except ImportError: | ||
import os, sys | ||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..')) | ||
import sage_bootstrap | ||
|
||
from sage_bootstrap.cmdline import SagePkgApplication | ||
SagePkgApplication().run() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Commandline handling | ||
Note that argparse is not part of Python 2.6, so we cannot rely on it here. | ||
""" | ||
|
||
|
||
#***************************************************************************** | ||
# Copyright (C) 2015 Volker Braun <vbraun.name@gmail.com> | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 2 of the License, or | ||
# (at your option) any later version. | ||
# http://www.gnu.org/licenses/ | ||
#***************************************************************************** | ||
|
||
import os | ||
import sys | ||
import logging | ||
log = logging.getLogger() | ||
|
||
|
||
|
||
class CmdlineSubcommands(object): | ||
|
||
def __init__(self, argv=None): | ||
if argv is None: | ||
argv = sys.argv | ||
if len(argv) == 1: | ||
self.print_help() | ||
sys.exit(0) | ||
self.subcommand = argv[1] | ||
self.extra_args = argv[2:] | ||
|
||
def print_help(self): | ||
from textwrap import dedent | ||
print(dedent(self.__doc__).lstrip()) | ||
|
||
def run(self): | ||
try: | ||
method = getattr(self, 'run_{0}'.format(self.subcommand)) | ||
except AttributeError: | ||
log.error('unknown subcommand: {0}'.format(self.subcommand)) | ||
sys.exit(1) | ||
try: | ||
method(*self.extra_args) | ||
except TypeError as err: | ||
log.error('invalid arguments to the {0} subcommand: {1}' | ||
.format(self.subcommand, self.extra_args)) | ||
sys.exit(1) | ||
|
||
|
||
class SagePkgApplication(CmdlineSubcommands): | ||
""" | ||
sage-pkg | ||
-------- | ||
The package script is used to manage third-party tarballs. | ||
""" | ||
|
||
def run_config(self): | ||
""" | ||
Print the configuration | ||
""" | ||
from sage_bootstrap.config import Configuration | ||
print(Configuration()) | ||
|
||
def run_list(self): | ||
""" | ||
Print a list of all available packages | ||
""" | ||
pass | ||
|
||
def run_name(self, tarball_filename): | ||
""" | ||
Find the package name given a tarball filename | ||
""" | ||
pass | ||
|
||
def run_tarball(self, package_name): | ||
""" | ||
Find the tarball filename given a package name | ||
""" | ||
pass | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Environment Variables | ||
This module defines the following subset of the Sage environment | ||
variables: | ||
* ``SAGE_ROOT`` | ||
* ``SAGE_SRC`` | ||
""" | ||
|
||
|
||
#***************************************************************************** | ||
# Copyright (C) 2015 Volker Braun <vbraun.name@gmail.com> | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 2 of the License, or | ||
# (at your option) any later version. | ||
# http://www.gnu.org/licenses/ | ||
#***************************************************************************** | ||
|
||
import os | ||
|
||
|
||
|
||
try: | ||
SAGE_SRC = os.environ['SAGE_SRC'] | ||
except KeyError: | ||
SAGE_SRC = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) | ||
|
||
try: | ||
SAGE_ROOT = os.environ['SAGE_ROOT'] | ||
except KeyError: | ||
SAGE_ROOT = os.path.dirname(SAGE_SRC) | ||
|
||
|
||
assert os.path.isfile(os.path.join(SAGE_ROOT, 'configure.ac')) | ||
assert os.path.isfile(os.path.join(SAGE_SRC, 'sage_bootstrap', 'setup.py')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters