From 70c2e95d852d65dd6e02d0d6cb7189cb12f4c155 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 5 Feb 2022 09:59:44 -0800 Subject: [PATCH 1/3] pkgs/sage-conf*: Refactor --- Makefile | 2 +- build/pkgs/sage_conf/dependencies | 2 +- configure.ac | 2 +- pkgs/sage-conf/.gitignore | 4 +- pkgs/sage-conf/VERSION.txt | 1 + pkgs/sage-conf/_sage_conf/__main__.py | 22 ++++++++++ pkgs/sage-conf/_sage_conf/_conf.py.in | 63 +++++++++++++++++++++++++++ pkgs/sage-conf/sage_conf.py | 2 + pkgs/sage-conf/setup.cfg | 23 ++++++++++ pkgs/sage-conf_pypi/.gitignore | 3 +- pkgs/sage-conf_pypi/MANIFEST.in | 5 ++- pkgs/sage-conf_pypi/_sage_conf | 1 + pkgs/sage-conf_pypi/sage_conf.py | 1 + pkgs/sage-conf_pypi/setup.cfg | 17 +------- pkgs/sage-conf_pypi/setup.py | 10 +---- src/bin/sage-env-config.in | 2 +- src/bin/sage-src-env-config.in | 2 +- 17 files changed, 129 insertions(+), 33 deletions(-) create mode 120000 pkgs/sage-conf/VERSION.txt create mode 100644 pkgs/sage-conf/_sage_conf/__main__.py create mode 100644 pkgs/sage-conf/_sage_conf/_conf.py.in create mode 100644 pkgs/sage-conf/sage_conf.py create mode 100644 pkgs/sage-conf/setup.cfg create mode 120000 pkgs/sage-conf_pypi/_sage_conf create mode 120000 pkgs/sage-conf_pypi/sage_conf.py mode change 100644 => 120000 pkgs/sage-conf_pypi/setup.cfg diff --git a/Makefile b/Makefile index d0687ca69b5..9c3e7e2715b 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ sageruntime: base-toolchain # CONFIG_FILES lists all files that appear in AC_CONFIG_FILES in configure.ac; # except for build/make/Makefile-auto, which is unused by the build system -CONFIG_FILES = build/make/Makefile src/bin/sage-env-config build/bin/sage-build-env-config pkgs/sage-conf/sage_conf.py pkgs/sage-conf/setup.cfg +CONFIG_FILES = build/make/Makefile src/bin/sage-env-config build/bin/sage-build-env-config pkgs/sage-conf/_sage_conf/_conf.py # SPKG_COLLECT_FILES contains all files that influence the SAGE_SPKG_COLLECT macro SPKG_COLLECT_FILES = build/pkgs/*/type build/pkgs/*/package-version.txt build/pkgs/*/dependencies build/pkgs/*/requirements.txt build/pkgs/*/checksums.ini build/pkgs/*/spkg-install diff --git a/build/pkgs/sage_conf/dependencies b/build/pkgs/sage_conf/dependencies index 3f91fe3fba6..0479fd1d280 100644 --- a/build/pkgs/sage_conf/dependencies +++ b/build/pkgs/sage_conf/dependencies @@ -1 +1 @@ -$(PYTHON) $(SAGE_ROOT)/pkgs/sage-conf/sage_conf.py $(SAGE_ROOT)/pkgs/sage-conf/setup.cfg $(SAGE_ROOT)/pkgs/sage-conf/bin/sage-env-config | $(PYTHON_TOOLCHAIN) +$(PYTHON) $(SAGE_ROOT)/pkgs/sage-conf/_sage_conf/_conf.py $(SAGE_ROOT)/pkgs/sage-conf/setup.cfg $(SAGE_ROOT)/pkgs/sage-conf/bin/sage-env-config | $(PYTHON_TOOLCHAIN) diff --git a/configure.ac b/configure.ac index ce62d986fb6..45a498cbf91 100644 --- a/configure.ac +++ b/configure.ac @@ -513,7 +513,7 @@ dnl AC_CONFIG_HEADERS([config.h]) AC_CONFIG_FILES([build/make/Makefile-auto build/make/Makefile]) AC_CONFIG_FILES([src/bin/sage-env-config src/bin/sage-src-env-config build/bin/sage-build-env-config]) -AC_CONFIG_FILES([pkgs/sage-conf/sage_conf.py pkgs/sage-conf/setup.cfg]) +AC_CONFIG_FILES([pkgs/sage-conf/_sage_conf/_conf.py]) dnl Create basic directories needed for Sage AC_CONFIG_COMMANDS(mkdirs, diff --git a/pkgs/sage-conf/.gitignore b/pkgs/sage-conf/.gitignore index 2975b16e54b..2f96201a1c9 100644 --- a/pkgs/sage-conf/.gitignore +++ b/pkgs/sage-conf/.gitignore @@ -1,4 +1,6 @@ -/sage_conf.py +/_sage_conf/_conf.py /setup.cfg /build +/dist /*.egg-info +/.tox diff --git a/pkgs/sage-conf/VERSION.txt b/pkgs/sage-conf/VERSION.txt new file mode 120000 index 00000000000..43f4773d7de --- /dev/null +++ b/pkgs/sage-conf/VERSION.txt @@ -0,0 +1 @@ +../../src/VERSION.txt \ No newline at end of file diff --git a/pkgs/sage-conf/_sage_conf/__main__.py b/pkgs/sage-conf/_sage_conf/__main__.py new file mode 100644 index 00000000000..fa0a8888907 --- /dev/null +++ b/pkgs/sage-conf/_sage_conf/__main__.py @@ -0,0 +1,22 @@ +# Entry point 'sage-config'. It does not depend on any packages. + +from sage_conf import * + +def _main(): + from argparse import ArgumentParser + from sys import exit, stdout + parser = ArgumentParser() + parser.add_argument('--version', help="show version", action="version", + version='%(prog)s ' + VERSION) + parser.add_argument("VARIABLE", nargs='?', help="output the value of VARIABLE") + args = parser.parse_args() + d = globals() + if args.VARIABLE: + stdout.write('{}\n'.format(d[args.VARIABLE])) + else: + for k, v in d.items(): + if not k.startswith('_'): + stdout.write('{}={}\n'.format(k, v)) + +if __name__ == "__main__": + _main() diff --git a/pkgs/sage-conf/_sage_conf/_conf.py.in b/pkgs/sage-conf/_sage_conf/_conf.py.in new file mode 100644 index 00000000000..6cd28f558a8 --- /dev/null +++ b/pkgs/sage-conf/_sage_conf/_conf.py.in @@ -0,0 +1,63 @@ +# @configure_input@ + +VERSION = "@PACKAGE_VERSION@" + +# The following must not be used during build to determine source or installation +# location of sagelib. See comments in SAGE_ROOT/src/Makefile.in +# These variables come first so that other substituted variable values can refer +# to it. +SAGE_LOCAL = "@prefix@" +SAGE_ROOT = "@SAGE_ROOT@" + +MAXIMA = "@prefix@/bin/maxima" + +# Delete this line if your ECL can load maxima without further prodding. +MAXIMA_FAS = "@SAGE_MAXIMA_FAS@".replace('${prefix}', SAGE_LOCAL) + +# Delete this line if your ECL can load Kenzo without further prodding. +KENZO_FAS = "@SAGE_KENZO_FAS@".replace('${prefix}', SAGE_LOCAL) + +ARB_LIBRARY = "@SAGE_ARB_LIBRARY@" + +NTL_INCDIR = "@NTL_INCDIR@" +NTL_LIBDIR = "@NTL_LIBDIR@" + +# Path to the ecl-config script +ECL_CONFIG = "@SAGE_ECL_CONFIG@".replace('${prefix}', SAGE_LOCAL) + +SAGE_NAUTY_BINS_PREFIX = "@SAGE_NAUTY_BINS_PREFIX@" + +# Names or paths of the 4ti2 executables +FOURTITWO_HILBERT = "@FOURTITWO_HILBERT@" +FOURTITWO_MARKOV = "@FOURTITWO_MARKOV@" +FOURTITWO_GRAVER = "@FOURTITWO_GRAVER@" +FOURTITWO_ZSOLVE = "@FOURTITWO_ZSOLVE@" +FOURTITWO_QSOLVE = "@FOURTITWO_QSOLVE@" +FOURTITWO_RAYS = "@FOURTITWO_RAYS@" +FOURTITWO_PPI = "@FOURTITWO_PPI@" +FOURTITWO_CIRCUITS = "@FOURTITWO_CIRCUITS@" +FOURTITWO_GROEBNER = "@FOURTITWO_GROEBNER@" + +# Colon-separated list of pkg-config modules to search for cblas functionality. +# We hard-code it here as cblas because configure (build/pkgs/openblas/spkg-configure.m4) +# always provides cblas.pc, if necessary by creating a facade pc file for a system BLAS. +CBLAS_PC_MODULES = "cblas" + +# for sage_setup.setenv +SAGE_ARCHFLAGS = "@SAGE_ARCHFLAGS@" +SAGE_PKG_CONFIG_PATH = "@SAGE_PKG_CONFIG_PATH@".replace('$SAGE_LOCAL', SAGE_LOCAL) + +# Used in sage.repl.ipython_kernel.install +MATHJAX_DIR = SAGE_LOCAL + "/share/mathjax" +THREEJS_DIR = SAGE_LOCAL + "/share/threejs-sage" + +# OpenMP flags, if available. +OPENMP_CFLAGS = "@OPENMP_CFLAGS@" +OPENMP_CXXFLAGS = "@OPENMP_CXXFLAGS@" + +# The full absolute path to the main Singular library. +LIBSINGULAR_PATH = "@LIBSINGULAR_PATH@".replace('$SAGE_LOCAL', SAGE_LOCAL) + +# Installation location of wheels. This is determined at configuration time +# and does not depend on the installation location of sage-conf. +SAGE_SPKG_WHEELS = "@SAGE_VENV@".replace('${SAGE_LOCAL}', SAGE_LOCAL) + "/var/lib/sage/wheels" diff --git a/pkgs/sage-conf/sage_conf.py b/pkgs/sage-conf/sage_conf.py new file mode 100644 index 00000000000..dd36f946828 --- /dev/null +++ b/pkgs/sage-conf/sage_conf.py @@ -0,0 +1,2 @@ +from _sage_conf._conf import * +from _sage_conf.__main__ import _main diff --git a/pkgs/sage-conf/setup.cfg b/pkgs/sage-conf/setup.cfg new file mode 100644 index 00000000000..f961254c731 --- /dev/null +++ b/pkgs/sage-conf/setup.cfg @@ -0,0 +1,23 @@ +[metadata] +name = sage-conf +version = file: VERSION.txt +description = Sage: Open Source Mathematics Software: Configuration module for the SageMath library +long_description = file: README.rst +license = GNU General Public License (GPL) v3 or later +author = The Sage Developers +author_email = sage-support@googlegroups.com +url = https://www.sagemath.org + +[options] +packages = + _sage_conf + +py_modules = + sage_conf + +scripts = + bin/sage-env-config + +[options.entry_points] +console_scripts = + sage-config = sage_conf.__main__:_main diff --git a/pkgs/sage-conf_pypi/.gitignore b/pkgs/sage-conf_pypi/.gitignore index 3bb4a6af5d1..6fdda73c500 100644 --- a/pkgs/sage-conf_pypi/.gitignore +++ b/pkgs/sage-conf_pypi/.gitignore @@ -1,5 +1,6 @@ -/sage_conf.py +/_sage_conf/_conf.py /build /dist /*.egg-info /.tox +/bin/sage-env-config diff --git a/pkgs/sage-conf_pypi/MANIFEST.in b/pkgs/sage-conf_pypi/MANIFEST.in index 5eca5195567..ed0379b28ba 100644 --- a/pkgs/sage-conf_pypi/MANIFEST.in +++ b/pkgs/sage-conf_pypi/MANIFEST.in @@ -16,8 +16,9 @@ graft sage_root/pkgs/sage-docbuild prune sage_root/pkgs/sage-docbuild/build prune sage_root/pkgs/sage-docbuild/*.egg-info # Exclude files generated by config.status (AC_CONFIG_FILES) -exclude sage_root/pkgs/sage-conf/sage_conf.py -exclude sage_root/pkgs/sage-conf/setup.cfg +exclude _sage_conf/_conf.py +exclude sage_root/pkgs/sage-conf/_sage_conf/_conf.py +exclude bin/sage-env-config exclude sage_root/pkgs/sage-conf/bin/sage-env-config exclude sage_root/build/bin/sage-build-env-config exclude sage_root/build/make/Makefile-auto diff --git a/pkgs/sage-conf_pypi/_sage_conf b/pkgs/sage-conf_pypi/_sage_conf new file mode 120000 index 00000000000..d92a91bef8c --- /dev/null +++ b/pkgs/sage-conf_pypi/_sage_conf @@ -0,0 +1 @@ +../sage-conf/_sage_conf \ No newline at end of file diff --git a/pkgs/sage-conf_pypi/sage_conf.py b/pkgs/sage-conf_pypi/sage_conf.py new file mode 120000 index 00000000000..f4bca8cc55c --- /dev/null +++ b/pkgs/sage-conf_pypi/sage_conf.py @@ -0,0 +1 @@ +../sage-conf/sage_conf.py \ No newline at end of file diff --git a/pkgs/sage-conf_pypi/setup.cfg b/pkgs/sage-conf_pypi/setup.cfg deleted file mode 100644 index a024eb955a0..00000000000 --- a/pkgs/sage-conf_pypi/setup.cfg +++ /dev/null @@ -1,16 +0,0 @@ -[metadata] -name = sage-conf -version = file: VERSION.txt -description = Sage: Open Source Mathematics Software: Configuration module for the SageMath library -long_description = file: README.rst -license = GNU General Public License (GPL) v3 or later -author = The Sage Developers -author_email = sage-support@googlegroups.com -url = https://www.sagemath.org - -[options] -py_modules = - sage_conf - -scripts = - bin/sage-env-config diff --git a/pkgs/sage-conf_pypi/setup.cfg b/pkgs/sage-conf_pypi/setup.cfg new file mode 120000 index 00000000000..93df2c80a4b --- /dev/null +++ b/pkgs/sage-conf_pypi/setup.cfg @@ -0,0 +1 @@ +../sage-conf/setup.cfg \ No newline at end of file diff --git a/pkgs/sage-conf_pypi/setup.py b/pkgs/sage-conf_pypi/setup.py index f16019ccd64..a689f4d617b 100644 --- a/pkgs/sage-conf_pypi/setup.py +++ b/pkgs/sage-conf_pypi/setup.py @@ -62,11 +62,8 @@ def run(self): raise DistutilsSetupError(f"make {TARGETS} failed") # Install configuration - shutil.copyfile(os.path.join(SAGE_ROOT, 'pkgs', 'sage-conf', 'sage_conf.py'), - os.path.join(HERE, '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, 'pkgs', 'sage-conf', '_sage_conf', '_conf.py'), + os.path.join(HERE, '_sage_conf', '_conf.py')) shutil.copyfile(os.path.join(SAGE_ROOT, 'src', 'bin', 'sage-env-config'), os.path.join(HERE, 'bin', 'sage-env-config')) setuptools_build_py.run(self) @@ -77,9 +74,6 @@ 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( diff --git a/src/bin/sage-env-config.in b/src/bin/sage-env-config.in index 08776aa63e7..49158df4d4c 100644 --- a/src/bin/sage-env-config.in +++ b/src/bin/sage-env-config.in @@ -20,7 +20,7 @@ # or build/bin/sage-build-env instead. # - Configuration variables that are only needed by the Sage runtime, # but not as environment variables, should instead be set in -# pkgs/sage-conf/sage_conf.py +# pkgs/sage-conf/_sage_conf/_conf.py # ########################################################################## diff --git a/src/bin/sage-src-env-config.in b/src/bin/sage-src-env-config.in index d8aeb8a9023..2949c320665 100644 --- a/src/bin/sage-src-env-config.in +++ b/src/bin/sage-src-env-config.in @@ -23,7 +23,7 @@ # instead. # - Configuration variables that are only needed by the Sage runtime, # but not as environment variables, should instead be set in -# build/pkgs/sage_conf/src/sage_conf.py +# pkgs/sage-conf/_sage_conf/_conf.py # ########################################################################## From 9d100555f824ec0d7d6c509f750a3887692c3f98 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 25 Jun 2022 11:31:08 -0700 Subject: [PATCH 2/3] pkgs/sage-conf*: Remove some obsolete files --- pkgs/sage-conf/sage_conf.py.in | 88 ----------------------------- pkgs/sage-conf/setup.cfg.in | 22 -------- pkgs/sage-conf_pypi/sage_conf.py.in | 1 - 3 files changed, 111 deletions(-) delete mode 100644 pkgs/sage-conf/sage_conf.py.in delete mode 100644 pkgs/sage-conf/setup.cfg.in delete mode 120000 pkgs/sage-conf_pypi/sage_conf.py.in diff --git a/pkgs/sage-conf/sage_conf.py.in b/pkgs/sage-conf/sage_conf.py.in deleted file mode 100644 index f6d71c3e3cb..00000000000 --- a/pkgs/sage-conf/sage_conf.py.in +++ /dev/null @@ -1,88 +0,0 @@ -# @configure_input@ - -VERSION = "@PACKAGE_VERSION@" - -# The following must not be used during build to determine source or installation -# location of sagelib. See comments in SAGE_ROOT/src/Makefile.in -# These variables come first so that other substituted variable values can refer -# to it. -SAGE_LOCAL = "@prefix@" -SAGE_ROOT = "@SAGE_ROOT@" - -MAXIMA = "@prefix@/bin/maxima" - -# Delete this line if your ECL can load maxima without further prodding. -MAXIMA_FAS = "@SAGE_MAXIMA_FAS@".replace('${prefix}', SAGE_LOCAL) - -# Delete this line if your ECL can load Kenzo without further prodding. -KENZO_FAS = "@SAGE_KENZO_FAS@".replace('${prefix}', SAGE_LOCAL) - -ARB_LIBRARY = "@SAGE_ARB_LIBRARY@" - -NTL_INCDIR = "@NTL_INCDIR@" -NTL_LIBDIR = "@NTL_LIBDIR@" - -# Path to the ecl-config script -ECL_CONFIG = "@SAGE_ECL_CONFIG@".replace('${prefix}', SAGE_LOCAL) - -SAGE_NAUTY_BINS_PREFIX = "@SAGE_NAUTY_BINS_PREFIX@" - -# Names or paths of the 4ti2 executables -FOURTITWO_HILBERT = "@FOURTITWO_HILBERT@" -FOURTITWO_MARKOV = "@FOURTITWO_MARKOV@" -FOURTITWO_GRAVER = "@FOURTITWO_GRAVER@" -FOURTITWO_ZSOLVE = "@FOURTITWO_ZSOLVE@" -FOURTITWO_QSOLVE = "@FOURTITWO_QSOLVE@" -FOURTITWO_RAYS = "@FOURTITWO_RAYS@" -FOURTITWO_PPI = "@FOURTITWO_PPI@" -FOURTITWO_CIRCUITS = "@FOURTITWO_CIRCUITS@" -FOURTITWO_GROEBNER = "@FOURTITWO_GROEBNER@" - -# Colon-separated list of pkg-config modules to search for cblas functionality. -# We hard-code it here as cblas because configure (build/pkgs/openblas/spkg-configure.m4) -# always provides cblas.pc, if necessary by creating a facade pc file for a system BLAS. -CBLAS_PC_MODULES = "cblas" - -# for sage_setup.setenv -SAGE_ARCHFLAGS = "@SAGE_ARCHFLAGS@" -SAGE_PKG_CONFIG_PATH = "@SAGE_PKG_CONFIG_PATH@".replace('$SAGE_LOCAL', SAGE_LOCAL) - -# Used in sage.repl.ipython_kernel.install -MATHJAX_DIR = SAGE_LOCAL + "/share/mathjax" -THREEJS_DIR = SAGE_LOCAL + "/share/threejs-sage" - -# OpenMP flags, if available. -OPENMP_CFLAGS = "@OPENMP_CFLAGS@" -OPENMP_CXXFLAGS = "@OPENMP_CXXFLAGS@" - -# Singular executable -SINGULAR_BIN = "@SINGULAR_BIN@" - -# The full absolute path to the main Singular library. -LIBSINGULAR_PATH = "@LIBSINGULAR_PATH@".replace('$SAGE_LOCAL', SAGE_LOCAL) - -# Installation location of wheels. This is determined at configuration time -# and does not depend on the installation location of sage-conf. -SAGE_SPKG_WHEELS = "@SAGE_VENV@".replace('${SAGE_LOCAL}', SAGE_LOCAL) + "/var/lib/sage/wheels" - - -# Entry point 'sage-config'. It does not depend on any packages. - -def _main(): - from argparse import ArgumentParser - from sys import exit, stdout - parser = ArgumentParser() - parser.add_argument('--version', help="show version", action="version", - version='%(prog)s ' + VERSION) - parser.add_argument("VARIABLE", nargs='?', help="output the value of VARIABLE") - args = parser.parse_args() - d = globals() - if args.VARIABLE: - stdout.write('{}\n'.format(d[args.VARIABLE])) - else: - for k, v in d.items(): - if not k.startswith('_'): - stdout.write('{}={}\n'.format(k, v)) - -if __name__ == "__main__": - _main() diff --git a/pkgs/sage-conf/setup.cfg.in b/pkgs/sage-conf/setup.cfg.in deleted file mode 100644 index 792b630eec0..00000000000 --- a/pkgs/sage-conf/setup.cfg.in +++ /dev/null @@ -1,22 +0,0 @@ -# @configure_input@ - -[metadata] -name = sage-conf -version = @PACKAGE_VERSION@ -description = Sage: Open Source Mathematics Software: Configuration module for the SageMath library -long_description = file: README.rst -license = GNU General Public License (GPL) v3 or later -author = The Sage Developers -author_email = sage-support@googlegroups.com -url = https://www.sagemath.org - -[options] -py_modules = - sage_conf - -scripts = - bin/sage-env-config - -[options.entry_points] -console_scripts = - sage-config = sage_conf:_main diff --git a/pkgs/sage-conf_pypi/sage_conf.py.in b/pkgs/sage-conf_pypi/sage_conf.py.in deleted file mode 120000 index ed20b4df7fd..00000000000 --- a/pkgs/sage-conf_pypi/sage_conf.py.in +++ /dev/null @@ -1 +0,0 @@ -../sage-conf/sage_conf.py.in \ No newline at end of file From eeddb03c6ce0ccf80a6a823e16335f445ae26ed3 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Thu, 30 Jun 2022 19:10:20 -0700 Subject: [PATCH 3/3] pkgs/sage-conf/setup.cfg: Fix up console_scripts --- pkgs/sage-conf/setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/sage-conf/setup.cfg b/pkgs/sage-conf/setup.cfg index f961254c731..dac401c303d 100644 --- a/pkgs/sage-conf/setup.cfg +++ b/pkgs/sage-conf/setup.cfg @@ -20,4 +20,4 @@ scripts = [options.entry_points] console_scripts = - sage-config = sage_conf.__main__:_main + sage-config = sage_conf:_main