Ejemplo n.º 1
0
    def clean_stale_files(self):
        """
        Remove stale installed files.

        This removes files which are built/installed but which do not
        exist in the Sage sources (typically because some source file
        has been deleted). Files are removed from the build directory
        ``build/lib-*`` and from the install directory ``site-packages``.
        """
        dist = self.distribution
        cmd_build_py = self.get_finalized_command("build_py")
        cmd_build_cython = self.get_finalized_command("build_cython")

        # Determine all Python modules inside all packages
        py_modules = []
        for package in dist.packages:
            package_dir = cmd_build_py.get_package_dir(package)
            py_modules += cmd_build_py.find_package_modules(
                package, package_dir)
        # modules is a list of triples (package, module, module_file).
        # Construct the complete module name from this.
        py_modules = ["{0}.{1}".format(*m) for m in py_modules]

        # Clean install directory (usually, purelib and platlib are the same)
        # and build directory.
        output_dirs = [
            self.install_purelib, self.install_platlib, self.build_lib
        ]
        from sage_setup.clean import clean_install_dir
        for output_dir in set(output_dirs):
            log.info('- cleaning {0}'.format(output_dir))
            clean_install_dir(output_dir, dist.packages, py_modules,
                              dist.ext_modules,
                              cmd_build_cython.get_cythonized_package_files())
Ejemplo n.º 2
0
    def clean_stale_files(self):
        """
        Remove stale installed files.

        This removes files which are built/installed but which do not
        exist in the Sage sources (typically because some source file
        has been deleted). Files are removed from the build directory
        ``build/lib-*`` and from the install directory ``site-packages``.
        """
        dist = self.distribution
        cmd_build_py = self.get_finalized_command("build_py")
        cmd_build_cython = self.get_finalized_command("build_cython")

        # Determine all Python modules inside all packages
        py_modules = []
        for package in dist.packages:
            package_dir = cmd_build_py.get_package_dir(package)
            py_modules += cmd_build_py.find_package_modules(package, package_dir)
        # modules is a list of triples (package, module, module_file).
        # Construct the complete module name from this.
        py_modules = ["{0}.{1}".format(*m) for m in py_modules]

        # Clean install directory (usually, purelib and platlib are the same)
        # and build directory.
        output_dirs = [self.install_purelib, self.install_platlib, self.build_lib]
        from sage_setup.clean import clean_install_dir
        for output_dir in set(output_dirs):
            log.info('- cleaning {0}'.format(output_dir))
            clean_install_dir(output_dir,
                    dist.packages,
                    py_modules,
                    dist.ext_modules,
                    cmd_build_cython.get_cythonized_package_files())
Ejemplo n.º 3
0
    def clean_stale_files(self):
        """
        Remove stale installed files.

        This removes files which are built/installed but which do not
        exist in the Sage sources (typically because some source file
        has been deleted). Files are removed from the build directory
        ``build/lib-*`` and from the install directory ``site-packages``.
        """
        dist = self.distribution
        cmd_build_py = self.get_finalized_command("build_py")
        cmd_build_cython = self.get_finalized_command("build_cython")

        # Determine all Python modules inside all packages
        py_modules = []
        for package in dist.packages:
            package_dir = cmd_build_py.get_package_dir(package)
            py_modules += cmd_build_py.find_package_modules(
                package, package_dir)
        # modules is a list of triples (package, module, module_file).
        # Construct the complete module name from this.
        py_modules = ["{0}.{1}".format(*m) for m in py_modules]

        # Determine all files of package data and Cythonized package files
        # example of entries of cmd_build_cython.get_cythonized_package_files():
        #   ('sage/media', ['./sage/media/channels.pyx'])
        data_files = cmd_build_cython.get_cythonized_package_files()
        # examples of entries of build_py.data_files:
        #   ('sage.libs.gap', 'sage/libs/gap', 'build/lib.macosx-10.9-x86_64-3.7/sage/libs/gap', ['sage.gaprc'])
        #   ('sage', 'sage', 'build/lib.macosx-10.9-x86_64-3.7/sage', ['ext_data/nodoctest.py', 'ext_data/kenzo/S4.txt', ...])
        nobase_data_files = [
            (src_dir,
             [os.path.join(src_dir, filename) for filename in filenames]) for
            package, src_dir, build_dir, filenames in cmd_build_py.data_files
        ]

        # Clean install directory (usually, purelib and platlib are the same)
        # and build directory.
        output_dirs = [
            self.install_purelib, self.install_platlib, self.build_lib
        ]
        from sage_setup.clean import clean_install_dir
        for output_dir in set(output_dirs):
            log.info('- cleaning {0}'.format(output_dir))
            clean_install_dir(output_dir, dist.packages, py_modules,
                              dist.ext_modules, data_files, nobase_data_files)
Ejemplo n.º 4
0
python_packages, python_modules = find_python_sources(SAGE_SRC,
                                                      ['sage', 'sage_setup'])
print "Discovered Python source, time: %.2f seconds." % (time.time() - t)

#########################################################
### Clean
#########################################################

print('Cleaning up stale installed files....')
t = time.time()
from sage_setup.clean import clean_install_dir
output_dirs = SITE_PACKAGES + glob.glob(os.path.join(SAGE_SRC, 'build',
                                                     'lib*'))
for output_dir in output_dirs:
    print('- cleaning {0}'.format(output_dir))
    clean_install_dir(output_dir, python_packages, python_modules, ext_modules)
print('Finished cleaning, time: %.2f seconds.' % (time.time() - t))

#########################################################
### Distutils
#########################################################

code = setup(name='sage',
             version=SAGE_VERSION,
             description='Sage: Open Source Mathematics Software',
             license='GNU Public License (GPL)',
             author='William Stein et al.',
             author_email='http://groups.google.com/group/sage-support',
             url='http://www.sagemath.org',
             packages=python_packages,
             scripts=[],
Ejemplo n.º 5
0
python_data_files = find_extra_files(python_packages,
    ".", SAGE_CYTHONIZED, SAGE_LIB, ["ntlwrap.cpp"])
print("Discovered Python/Cython sources, time: %.2f seconds." % (time.time() - t))


#########################################################
### Clean
#########################################################

print('Cleaning up stale installed files....')
t = time.time()
from sage_setup.clean import clean_install_dir
output_dirs = SITE_PACKAGES + glob.glob(os.path.join(SAGE_SRC, 'build', 'lib*'))
for output_dir in output_dirs:
    print('- cleaning {0}'.format(output_dir))
    clean_install_dir(output_dir, python_packages, python_modules,
            ext_modules, python_data_files)
print('Finished cleaning, time: %.2f seconds.' % (time.time() - t))


#########################################################
### Install also Jupyter kernel spec
#########################################################

# We cannot just add the installation of the kernel spec to data_files
# since the file is generated, not copied.
class sage_install(install):
    def run(self):
        install.run(self)
        self.install_kernel_spec()

    def install_kernel_spec(self):