Skip to content

Commit bd2f4b6

Browse files
author
Release Manager
committed
Trac #31386: Move list of scripts and package_data from setup.py to setup.cfg
This will allow us to reduce the duplication between `src/setup.py` (which is currently used when `./configure --enable-editable` is in use) and `build/pkgs/sagelib/src/setup.py`. We also update the developer's guide on the topic of `package_data`. URL: https://trac.sagemath.org/31386 Reported by: mkoeppe Ticket author(s): Matthias Koeppe Reviewer(s): John Palmieri
2 parents 576bdc7 + 81e9c9a commit bd2f4b6

File tree

4 files changed

+114
-169
lines changed

4 files changed

+114
-169
lines changed

pkgs/sagemath-standard/setup.py

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/usr/bin/env python
22

3-
from __future__ import print_function
4-
53
import os
64
import sys
75
import time
@@ -102,82 +100,5 @@
102100

103101
code = setup(
104102
packages = python_packages,
105-
package_data = {
106-
'sage.libs.gap': ['sage.gaprc'],
107-
'sage.interfaces': ['sage-maxima.lisp'],
108-
'sage.doctest': ['tests/*'],
109-
'sage': ['ext_data/*',
110-
'ext_data/kenzo/*',
111-
'ext_data/singular/*',
112-
'ext_data/singular/function_field/*',
113-
'ext_data/images/*',
114-
'ext_data/doctest/*',
115-
'ext_data/doctest/invalid/*',
116-
'ext_data/doctest/rich_output/*',
117-
'ext_data/doctest/rich_output/example_wavefront/*',
118-
'ext_data/gap/*',
119-
'ext_data/gap/joyner/*',
120-
'ext_data/mwrank/*',
121-
'ext_data/notebook-ipython/*',
122-
'ext_data/nbconvert/*',
123-
'ext_data/graphs/*',
124-
'ext_data/pari/*',
125-
'ext_data/pari/dokchitser/*',
126-
'ext_data/pari/buzzard/*',
127-
'ext_data/pari/simon/*',
128-
'ext_data/magma/*',
129-
'ext_data/magma/latex/*',
130-
'ext_data/magma/sage/*',
131-
'ext_data/valgrind/*',
132-
'ext_data/threejs/*']
133-
},
134-
scripts = [## The sage script
135-
'bin/sage',
136-
## Other scripts that should be in the path also for OS packaging of sage:
137-
'bin/sage-eval',
138-
'bin/sage-runtests', # because it is useful for doctesting user scripts too
139-
'bin/sage-fixdoctests', # likewise
140-
'bin/sage-coverage', # because it is useful for coverage-testing user scripts too
141-
'bin/sage-cython', # deprecated, might be used in user package install scripts
142-
## Helper scripts invoked by sage script
143-
## (they would actually belong to something like libexec)
144-
'bin/sage-cachegrind',
145-
'bin/sage-callgrind',
146-
'bin/sage-massif',
147-
'bin/sage-omega',
148-
'bin/sage-valgrind',
149-
'bin/sage-venv-config',
150-
'bin/sage-version.sh',
151-
'bin/sage-cleaner',
152-
## Only makes sense in sage-the-distribution. TODO: Move to another installation script.
153-
'bin/sage-list-packages',
154-
'bin/sage-location',
155-
## Uncategorized scripts in alphabetical order
156-
'bin/math-readline',
157-
'bin/sage-env',
158-
# sage-env-config -- installed by sage_conf
159-
# sage-env-config.in -- not to be installed',
160-
'bin/sage-gdb-commands',
161-
'bin/sage-grep',
162-
'bin/sage-grepdoc',
163-
'bin/sage-inline-fortran',
164-
'bin/sage-ipynb2rst',
165-
'bin/sage-ipython',
166-
'bin/sage-native-execute',
167-
'bin/sage-notebook',
168-
'bin/sage-num-threads.py',
169-
'bin/sage-open',
170-
'bin/sage-preparse',
171-
'bin/sage-python',
172-
'bin/sage-rebase.bat',
173-
'bin/sage-rebase.sh',
174-
'bin/sage-rebaseall.bat',
175-
'bin/sage-rebaseall.sh',
176-
'bin/sage-run',
177-
'bin/sage-run-cython',
178-
'bin/sage-startuptime.py',
179-
'bin/sage-update-src',
180-
'bin/sage-update-version',
181-
],
182103
cmdclass = cmdclass,
183104
ext_modules = cython_modules)

src/doc/en/developer/coding_basics.rst

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,31 @@ Then in the file ``SAGE_ROOT/src/sage/all.py``, add a line ::
152152

153153
from sage.measure_theory.all import *
154154

155-
Non-Python Sage source code and supporting files should be placed in
156-
appropriate subdirectories of ``SAGE_ROOT/src/sage/ext_data/``. They will then be
157-
automatically copied to the corresponding subdirectories of
158-
``SAGE_ROOT/local/share/sage/ext/`` during the build process and can be
159-
accessed at runtime using ``SAGE_EXTCODE``. For example, if ``file`` is placed
160-
in ``SAGE_ROOT/src/sage/ext_data/directory/`` it can be accessed with ::
155+
Non-Python Sage source code and supporting files can be included in one
156+
of the following places:
157+
158+
- In the directory of the Python code that uses that file. When the
159+
Sage library is installed, the file will be installed in the same
160+
location as the Python code. For example,
161+
``SAGE_ROOT/src/sage/interfaces/maxima.py`` needs to use the file
162+
``SAGE_ROOT/src/sage/interfaces/maxima.lisp`` at runtime, so it refers
163+
to it as ::
164+
165+
os.path.join(os.path.dirname(__file__), 'sage-maxima.lisp')
166+
167+
- In an appropriate subdirectory of ``SAGE_ROOT/src/sage/ext_data/``.
168+
(At runtime, it is then available in the directory indicated by
169+
``SAGE_EXTCODE``). For example, if ``file`` is placed in
170+
``SAGE_ROOT/src/sage/ext_data/directory/`` it can be accessed with ::
161171

162172
from sage.env import SAGE_EXTCODE
163173
file = os.path.join(SAGE_EXTCODE, 'directory', 'file')
164174

165-
``SAGE_EXTCODE`` is used because not all distributions have ``SAGE_ROOT``.
175+
In both cases, the files must be listed (explicitly or via wildcards) in
176+
the section ``options.package_data`` of the file
177+
``SAGE_ROOT/pkgs/sagemath-standard/setup.cfg.m4`` (or the corresponding
178+
file of another distribution).
179+
166180

167181

168182
Learn by copy/paste

src/setup.cfg.m4

Lines changed: 93 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ install_requires =
3131
sage_conf
3232
esyscmd(`sage-get-system-packages install-requires \
3333
six \
34-
| sed "2,\$s/^/ /;"')dnl
34+
| sed "2,\$s/^/ /;"')dnl'
3535
dnl From build/pkgs/sagelib/dependencies
3636
esyscmd(`sage-get-system-packages install-requires \
3737
cypari \
@@ -44,12 +44,12 @@ dnl From build/pkgs/sagelib/dependencies
4444
pkgconfig \
4545
pplpy \
4646
memory_allocator \
47-
| sed "2,\$s/^/ /;"')dnl
47+
| sed "2,\$s/^/ /;"')dnl'
4848
dnl From Makefile.in: SAGERUNTIME
4949
esyscmd(`sage-get-system-packages install-requires \
5050
ipython \
5151
pexpect \
52-
| sed "2,\$s/^/ /;"')dnl
52+
| sed "2,\$s/^/ /;"')dnl'
5353
dnl From Makefile.in: DOC_DEPENDENCIES
5454
esyscmd(`sage-get-system-packages install-requires \
5555
sphinx \
@@ -62,10 +62,98 @@ dnl From Makefile.in: DOC_DEPENDENCIES
6262
ipykernel \
6363
jupyter_client \
6464
ipywidgets \
65-
| sed "2,\$s/^/ /;"')dnl
65+
| sed "2,\$s/^/ /;"')dnl'
6666
dnl Other Python packages that are standard spkg, used in doctests
6767
esyscmd(`sage-get-system-packages install-requires \
6868
rpy2 \
6969
fpylll \
70-
| sed "2,\$s/^/ /;"')dnl
70+
| sed "2,\$s/^/ /;"')dnl'
7171
dnl pycryptosat # Sage distribution installs it as part of cryptominisat. According to its README on https://pypi.org/project/pycryptosat/: "The pycryptosat python package compiles while compiling CryptoMiniSat. It cannot be compiled on its own, it must be compiled at the same time as CryptoMiniSat."
72+
73+
scripts =
74+
# The sage script
75+
bin/sage
76+
# Other scripts that should be in the path also for OS packaging of sage:
77+
bin/sage-eval
78+
# Included because it is useful for doctesting/coverage testing user scripts too:
79+
bin/sage-runtests
80+
bin/sage-fixdoctests
81+
bin/sage-coverage
82+
# The following is deprecated but might still be used in user package install scripts
83+
bin/sage-cython
84+
# Helper scripts invoked by sage script
85+
# (they would actually belong to something like libexec)
86+
bin/sage-cachegrind
87+
bin/sage-callgrind
88+
bin/sage-massif
89+
bin/sage-omega
90+
bin/sage-valgrind
91+
bin/sage-venv-config
92+
bin/sage-version.sh
93+
bin/sage-cleaner
94+
# Only makes sense in sage-the-distribution. TODO: Move to another installation script.
95+
bin/sage-list-packages
96+
bin/sage-location
97+
# Uncategorized scripts in alphabetical order
98+
bin/math-readline
99+
bin/sage-env
100+
# sage-env-config -- installed by sage_conf
101+
# sage-env-config.in -- not to be installed
102+
bin/sage-gdb-commands
103+
bin/sage-grep
104+
bin/sage-grepdoc
105+
bin/sage-inline-fortran
106+
bin/sage-ipynb2rst
107+
bin/sage-ipython
108+
bin/sage-native-execute
109+
bin/sage-notebook
110+
bin/sage-num-threads.py
111+
bin/sage-open
112+
bin/sage-preparse
113+
bin/sage-python
114+
bin/sage-rebase.bat
115+
bin/sage-rebase.sh
116+
bin/sage-rebaseall.bat
117+
bin/sage-rebaseall.sh
118+
bin/sage-run
119+
bin/sage-run-cython
120+
bin/sage-startuptime.py
121+
bin/sage-update-src
122+
bin/sage-update-version
123+
124+
[options.package_data]
125+
126+
sage.libs.gap =
127+
sage.gaprc
128+
129+
sage.interfaces =
130+
sage-maxima.lisp
131+
132+
sage.doctest =
133+
tests/*
134+
135+
sage =
136+
ext_data/*
137+
ext_data/kenzo/*
138+
ext_data/singular/*
139+
ext_data/singular/function_field/*
140+
ext_data/images/*
141+
ext_data/doctest/*
142+
ext_data/doctest/invalid/*
143+
ext_data/doctest/rich_output/*
144+
ext_data/doctest/rich_output/example_wavefront/*
145+
ext_data/gap/*
146+
ext_data/gap/joyner/*
147+
ext_data/mwrank/*
148+
ext_data/notebook-ipython/*
149+
ext_data/nbconvert/*
150+
ext_data/graphs/*
151+
ext_data/pari/*
152+
ext_data/pari/dokchitser/*
153+
ext_data/pari/buzzard/*
154+
ext_data/pari/simon/*
155+
ext_data/magma/*
156+
ext_data/magma/latex/*
157+
ext_data/magma/sage/*
158+
ext_data/valgrind/*
159+
ext_data/threejs/*

src/setup.py

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -124,84 +124,6 @@
124124
# ########################################################
125125
code = setup(
126126
packages=python_packages,
127-
package_data={
128-
'sage.libs.gap': ['sage.gaprc'],
129-
'sage.interfaces': ['sage-maxima.lisp'],
130-
'sage.doctest': ['tests/*'],
131-
'sage': ['ext_data/*',
132-
'ext_data/kenzo/*',
133-
'ext_data/singular/*',
134-
'ext_data/singular/function_field/*',
135-
'ext_data/images/*',
136-
'ext_data/doctest/*',
137-
'ext_data/doctest/invalid/*',
138-
'ext_data/doctest/rich_output/*',
139-
'ext_data/doctest/rich_output/example_wavefront/*',
140-
'ext_data/gap/*',
141-
'ext_data/gap/joyner/*',
142-
'ext_data/mwrank/*',
143-
'ext_data/notebook-ipython/*',
144-
'ext_data/nbconvert/*',
145-
'ext_data/graphs/*',
146-
'ext_data/pari/*',
147-
'ext_data/pari/dokchitser/*',
148-
'ext_data/pari/buzzard/*',
149-
'ext_data/pari/simon/*',
150-
'ext_data/magma/*',
151-
'ext_data/magma/latex/*',
152-
'ext_data/magma/sage/*',
153-
'ext_data/valgrind/*',
154-
'ext_data/threejs/*']
155-
},
156-
scripts=[
157-
# The sage script
158-
'bin/sage',
159-
# Other scripts that should be in the path also for OS packaging of sage:
160-
'bin/sage-eval',
161-
'bin/sage-runtests', # because it is useful for doctesting user scripts too
162-
'bin/sage-fixdoctests', # likewise
163-
'bin/sage-coverage', # because it is useful for coverage-testing user scripts too
164-
'bin/sage-cython', # deprecated, might be used in user package install scripts
165-
# Helper scripts invoked by sage script
166-
# (they would actually belong to something like libexec)
167-
'bin/sage-cachegrind',
168-
'bin/sage-callgrind',
169-
'bin/sage-massif',
170-
'bin/sage-omega',
171-
'bin/sage-valgrind',
172-
'bin/sage-venv-config',
173-
'bin/sage-version.sh',
174-
'bin/sage-cleaner',
175-
# Only makes sense in sage-the-distribution. TODO: Move to another installation script.
176-
'bin/sage-list-packages',
177-
'bin/sage-location',
178-
# Uncategorized scripts in alphabetical order
179-
'bin/math-readline',
180-
'bin/sage-env',
181-
# sage-env-config -- installed by sage_conf
182-
# sage-env-config.in -- not to be installed
183-
'bin/sage-gdb-commands',
184-
'bin/sage-grep',
185-
'bin/sage-grepdoc',
186-
'bin/sage-inline-fortran',
187-
'bin/sage-ipynb2rst',
188-
'bin/sage-ipython',
189-
'bin/sage-native-execute',
190-
'bin/sage-notebook',
191-
'bin/sage-num-threads.py',
192-
'bin/sage-open',
193-
'bin/sage-preparse',
194-
'bin/sage-python',
195-
'bin/sage-rebase.bat',
196-
'bin/sage-rebase.sh',
197-
'bin/sage-rebaseall.bat',
198-
'bin/sage-rebaseall.sh',
199-
'bin/sage-run',
200-
'bin/sage-run-cython',
201-
'bin/sage-startuptime.py',
202-
'bin/sage-update-src',
203-
'bin/sage-update-version',
204-
],
205127
cmdclass={
206128
"build_ext": sage_build_ext_minimal,
207129
"install": sage_install,

0 commit comments

Comments
 (0)