11## -*- encoding: utf-8 -*-
22import os
33import sys
4+ import re
5+ import urllib2
46from setuptools import setup
57from codecs import open # To open the README file with proper encoding
68from setuptools .command .test import test as TestCommand # for tests
79from distutils .command import build as build_module
810
9- # The next block is needed if there are cython files
10- from setuptools import Extension
11- from Cython .Build import cythonize
12- import Cython .Compiler .Options
13- from sage .env import sage_include_directories
11+ # Obtain the different Sage versions
12+ def get_all_version_names (mirror_url , idx = None , distribution = 'Ubuntu_16.04-x86_64' ):
13+ if idx is None :
14+ idx = 0
15+ else :
16+ idx = int (idx )
17+ site = urllib2 .urlopen (mirror_url ).read ()
18+ ans = re .findall ('(sage-([0-9]*(?:\.[0-9]*)*)-%s.tar.bz2)' % distribution , site )
19+ all_version_names = []
20+ for fname , ver in ans :
21+ if fname not in all_version_names :
22+ all_version_names .append (fname )
23+ return all_version_names [idx ]
1424
1525# Get information from separate files (README, VERSION)
1626def readfile (filename ):
@@ -24,47 +34,58 @@ def run(self):
2434 check_version (sage_required_version )
2535 build_module .build .run (self )
2636
37+
2738# For the tests
2839class SageTest (TestCommand ):
2940 def run_tests (self ):
30- errno = os .system ("sage -t --force-lib sage_sample" )
41+ errno = os .system ("sage -t --force-lib sage_sample sage_sample/*.pyx " )
3142 if errno != 0 :
3243 sys .exit (1 )
3344
34- # Cython modules
35- ext_modules = [
36- Extension ('sage_sample.one_cython_file' ,
37- sources = [os .path .join ('sage_sample' ,'one_cython_file.pyx' )],
38- include_dirs = sage_include_directories ())
39- ]
45+ if __name__ == "__main__" :
46+
47+ # The next block is needed if there are cython files
48+ from setuptools import Extension
49+ from Cython .Build import cythonize
50+ import Cython .Compiler .Options
51+ from sage .env import sage_include_directories
52+
53+
54+ # Cython modules
55+ ext_modules = [
56+ Extension ('sage_sample.one_cython_file' ,
57+ sources = [os .path .join ('sage_sample' ,'one_cython_file.pyx' )],
58+ include_dirs = sage_include_directories ())
59+ ]
4060
41- # Specify the required Sage version
42- sage_required_version = '>=7.6 '
61+ # Specify the required Sage version
62+ sage_required_version = '>=7.5 '
4363
44- setup (
45- name = "sage_sample" ,
46- version = readfile ("VERSION" ), # the VERSION file is shared with the documentation
47- description = 'An example of a basic sage package' ,
48- long_description = readfile ("README.rst" ), # get the long description from the README
49- url = 'https://github.com/sagemath/sage_sample' ,
50- author = 'Matthias Koeppe, Sébastien Labbé, Viviane Pons, Nicolas M. Thiéry, ... with inspiration from many' ,
51- author_email = 'viviane.pons@lri.fr' , # choose a main contact email
52- license = 'GPLv2+' , # This should be consistent with the LICENCE file
53- classifiers = [
54- # How mature is this project? Common values are
55- # 3 - Alpha
56- # 4 - Beta
57- # 5 - Production/Stable
58- 'Development Status :: 4 - Beta' ,
59- 'Intended Audience :: Science/Research' ,
60- 'Topic :: Software Development :: Build Tools' ,
61- 'Topic :: Scientific/Engineering :: Mathematics' ,
62- 'License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)' ,
63- 'Programming Language :: Python :: 2.7' ,
64- ], # classifiers list: https://pypi.python.org/pypi?%3Aaction=list_classifiers
65- keywords = "SageMath packaging" ,
66- install_requires = ['sagemath' ], # This ensures that Sage is installed
67- packages = ['sage_sample' ],
68- ext_modules = cytonize (ext_modules ), # This line is only needed if there are cython files present
69- cmdclass = {'build' : build , 'test' : SageTest } # adding a special setup command for tests
70- )
64+ setup (
65+ name = "sage_sample" ,
66+ version = readfile ("VERSION" ), # the VERSION file is shared with the documentation
67+ description = 'An example of a basic sage package' ,
68+ long_description = readfile ("README.rst" ), # get the long description from the README
69+ url = 'https://github.com/sagemath/sage_sample' ,
70+ author = 'Matthias Koeppe, Sébastien Labbé, Viviane Pons, Nicolas M. Thiéry, ... with inspiration from many' ,
71+ author_email = 'viviane.pons@lri.fr' , # choose a main contact email
72+ license = 'GPLv2+' , # This should be consistent with the LICENCE file
73+ classifiers = [
74+ # How mature is this project? Common values are
75+ # 3 - Alpha
76+ # 4 - Beta
77+ # 5 - Production/Stable
78+ 'Development Status :: 4 - Beta' ,
79+ 'Intended Audience :: Science/Research' ,
80+ 'Topic :: Software Development :: Build Tools' ,
81+ 'Topic :: Scientific/Engineering :: Mathematics' ,
82+ 'License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)' ,
83+ 'Programming Language :: Python :: 2.7' ,
84+ ], # classifiers list: https://pypi.python.org/pypi?%3Aaction=list_classifiers
85+ keywords = "SageMath packaging" ,
86+ install_requires = ['sagemath' ], # This ensures that Sage is installed
87+ packages = ['sage_sample' ],
88+ ext_modules = cythonize (ext_modules ), # This line is only needed if there are cython files present
89+ include_package_data = True ,
90+ cmdclass = {'build' : build , 'test' : SageTest } # adding a special setup command for tests
91+ )
0 commit comments