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

Commit

Permalink
build/setup.py: Install sage_conf.py, sage-env-config
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Jul 1, 2020
1 parent 733427c commit 60642d3
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions build/setup.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#!/usr/bin/env sage-system-python

import os
import sys
import shutil

from distutils.core import setup
from distutils.cmd import Command
from distutils.command.install import install as distutils_install
from distutils.command.build_scripts import build_scripts as distutils_build_scripts
from distutils.command.build_py import build_py as distutils_build_py
from distutils.errors import (DistutilsSetupError, DistutilsModuleError,
DistutilsOptionError)

class install(distutils_install):
class build_py(distutils_build_py):

def run(self):
import os
import sys
import shutil
distutils_install.run(self)

DOT_SAGE = os.environ.get('DOT_SAGE', os.path.join(os.environ.get('HOME'), '.sage'))
# config.status and other configure output has to be writable.
SAGE_ROOT = os.path.join(DOT_SAGE, 'sage-{}'.format(self.distribution.version))
Expand All @@ -26,7 +26,27 @@ def run(self):
print("Running {}".format(cmd))
if os.system(cmd) != 0:
raise DistutilsSetupError("configure failed")
# TODO: Store SAGE_LOCAL in a module sage_bootstrap.config

# Install configuration
shutil.copyfile(os.path.join(SAGE_ROOT, 'build', 'pkgs', 'sage_conf', 'src', 'sage_conf.py'),
'sage_conf.py')
if not self.distribution.py_modules:
self.py_modules = self.distribution.py_modules = []
self.distribution.py_modules.append('sage_conf')
shutil.copyfile(os.path.join(SAGE_ROOT, 'src', 'bin', 'sage-env-config'),
os.path.join('bin', 'sage-env-config'))
distutils_build_py.run(self)

class build_scripts(distutils_build_scripts):

def run(self):
self.distribution.scripts.append(os.path.join('bin', 'sage-env-config'))
if not self.distribution.entry_points:
self.entry_points = self.distribution.entry_points = dict()
if 'console_scripts' not in self.distribution.entry_points:
self.distribution.entry_points['console_scripts'] = []
self.distribution.entry_points['console_scripts'].append('sage-config=sage_conf:_main')
distutils_build_scripts.run(self)

setup(
name='sage_bootstrap',
Expand All @@ -44,5 +64,5 @@ def run(self):
},
version='1.0',
url='https://www.sagemath.org',
cmdclass=dict(install=install)
cmdclass=dict(build_py=build_py, build_scripts=build_scripts)
)

0 comments on commit 60642d3

Please sign in to comment.