Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

relocatable wheel version of package sage_conf #31396

Closed
mkoeppe opened this issue Feb 14, 2021 · 269 comments
Closed

relocatable wheel version of package sage_conf #31396

mkoeppe opened this issue Feb 14, 2021 · 269 comments

Comments

@mkoeppe
Copy link
Contributor

mkoeppe commented Feb 14, 2021

This version of sage_conf is for making a wheel that packages the precompiled non-Python bits of the Sage distribution, making SAGE_ROOT (and thus SAGE_LOCAL=$SAGE_ROOT/local) relocatable using Marc Culler's symbolic link surgery (the method proposed in #31076, using SAGE_ROOT=/var/tmp/sage-... and a symlink).

The sage script invokes sage-config to determine SAGE_ROOT and SAGE_LOCAL. In the version of sage-config supplied by this version of sage_conf, we ensure that the symlink from /var/tmp/sage-.... to the actual install location is set.

So far, a wheel has been built for XCode python 3.8 on macOS 10.15. The wheel is 670MB in size, an order of magnitude above the standard file size limit on PyPI; but a file size limit increase (requested in pypi/support#985) has kindly been granted by the PyPI team.

The wheel declares dependencies (install-requires) to all Python packages in the Sage distribution that have extension modules. The dependencies are specific using @ to URLs on
https://github.com/sagemath/sage-wheels/releases/tag/9.5.rc2, where I have uploaded the binary wheels. Unfortunately, by PyPI policy, such @ references are not allowed for packages on PyPI.
Hence, the pip invocation needs to use a URL.

(See also https://twitter.com/mkoeppe_math/status/1378860285537054723)

Instructions for testing:

  1. Make sure that the bin directory of the user installation scheme is in PATH. For example, on macOS:
$ export PATH=$HOME/Library/Python/3.8/bin:/usr/bin:/bin:/usr/sbin:/sbin
  1. Install the wheel in the user scheme:
$ /usr/bin/python3 -m pip install -U --user  https://github.com/sagemath/sage-wheels/releases/download/9.3.rc1/sagemath_standard-9.3rc1-cp38-cp38-macosx_10_15_x86_64.whl
  1. Run the installed sage.
$ sage

Procedure for building the sage_conf wheel and compatible wheels:

For building wheels on macOS Catalina that uses XCode python 3.8:

$ SKIP_CONFIGURE=1 tox -e local-macos-10.15-nohomebrew-python3_xcode -- bash
(tox -e ...) $ (cd src/pkgs/sage_conf-relocatable/ && python3 setup.py bdist_wheel --plat-name macosx_10_15_x86_64)

or

tox -e local-macos-10.15-nohomebrew-python3_xcode -- SAGE_CHECK=no sage-wheels

This creates (uploaded to https://github.com/sagemath/sage-wheels/releases/tag/9.5.rc2)

  • src/pkgs/sage_conf-relocatable/dist/sage_conf-9.3rc1-cp38-cp38-macosx_10_15_x86_64.whl
  • src/pkgs/sage_conf-relocatable/sage_root/venv-cpython-38-darwin-macosx_10_15_x86_64/var/lib/sage/wheels/*.whl

Build for macOS Big Sur (requires a machine running Big Sur or Monterey) (uploaded to https://github.com/sagemath/sage-wheels/releases/tag/9.5.rc2)

tox -e local-macos-11.1-nohomebrew-python3_xcode -- SAGE_CHECK=no sage-wheels

Build for macOS Monterey (requires a machine running Monterey)

tox -e local-macos-12.1-nohomebrew-python3_xcode -- SAGE_CHECK=no sage-wheels

Build for Linux (does not work yet):

$ TARGETS_PRE=Makefile tox -e docker-manylinux-2_24-minimal-python3.9 -- sage-wheels

Follow-up steps:

Depends on #33817

CC: @culler @kliem @dimpase @jhpalmieri @slel @kiwifb

Component: relocation

Author: Matthias Koeppe

Branch/Commit: u/mkoeppe/relocatable_wheel_version_of_package_sage_conf @ 1b2d4be

Reviewer: Julian Rüth

Issue created by migration from https://trac.sagemath.org/ticket/31396

@mkoeppe mkoeppe added this to the sage-9.3 milestone Feb 14, 2021
@mkoeppe
Copy link
Contributor Author

mkoeppe commented Feb 15, 2021

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 15, 2021

Commit: 9573b7c

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 15, 2021

Branch pushed to git repo; I updated commit sha1. New commits:

952fb9aFix up package_data
9573b7cCloser to working

@mkoeppe

This comment has been minimized.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Feb 15, 2021

Author: Matthias Koeppe

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Feb 15, 2021

comment:4

On macOS, some shared libraries from homebrew still leak into the build:

find src/pkgs/sage_conf-relocatable/.tox/python/lib/python3.9/site-packages/sage_root -name "*.so" -o -name "*.dylib" | xargs otool -L
libgiac.dylib:
/usr/local/opt/gettext/lib/libintl.8.dylib
R/library/cluster/libs/*.dylib:
	/usr/local/opt/gettext/lib/libintl.8.dylib (compatibility version 11.0.0, current version 11.0.0)
	/usr/local/opt/pcre/lib/libpcre.1.dylib (compatibility version 4.0.0, current version 4.12.0)
	/usr/local/opt/xz/lib/liblzma.5.dylib (compatibility version 8.0.0, current version 8.5.0)

Definitely should disable the R build (#30383).

Also check whether setting CC=gcc -sysroot.... helps getting rid of /usr/local leaking in.

Also need to add --enable-fat-binary.

setup.py build_py should probably use a symlink from /var/tmp... into ~/.sage as well so that it is easy to test relocation after removing the symlink.
Also copytree from sage_root_source should be changed so it overwrites (updates) the existing contents of SAGE_ROOT.

the tox test should include the test with otool for self-containedness.

@mkoeppe

This comment has been minimized.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 16, 2021

Changed commit from 9573b7c to f785d3c

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 16, 2021

Branch pushed to git repo; I updated commit sha1. New commits:

f785d3csrc/pkgs/sage_conf-relocatable/tox.ini: Add environment macos-10.15

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Feb 16, 2021

comment:6

Using -isysroot helps but giac configuration needs more work - #31403

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Feb 16, 2021

comment:7

Replying to @mkoeppe:

setup.py build_py should probably use a symlink from /var/tmp... into ~/.sage as well so that it is easy to test relocation after removing the symlink.

Does not work because sage resolves symlinks when it determines SAGE_ROOT.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Feb 19, 2021

Changed dependencies from #29039 to #29039, #31409

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 19, 2021

Branch pushed to git repo; I updated commit sha1. New commits:

6da7ba2Add variable TARGETS
b2d4ab8build/pkgs/{r,rpy2}: Downgrade to optional
8732076src/sage/repl/ipython_tests.py: Mark R interface tests # optional - rpy2
dbdf084src/sage/structure/sage_object.pyx: Mark R interface test # optional - rpy2
737b21csrc/sage/stats/r.py: Mark all 2 doctests in this file as # optional - rpy2
4403924src/sage/interfaces/r.py: Mark all tests # optional - rpy2
e56a2a9Merge branch 't/31409/cygwin_standard__r_build_fails_____downgrade_r__rpy2_to_optional' into t/31396/relocatable_wheel_version_of_package_sage_conf

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 19, 2021

Changed commit from f785d3c to e56a2a9

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 19, 2021

Branch pushed to git repo; I updated commit sha1. New commits:

a228974src/pkgs/sage_conf-relocatable/setup.py: Move the SAGE_ROOT directory away after building

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 19, 2021

Changed commit from e56a2a9 to a228974

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 19, 2021

Changed commit from a228974 to c260942

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 19, 2021

Branch pushed to git repo; I updated commit sha1. New commits:

0cac965build/pkgs/ecl: Update to 21.2.1, remove patches included in new version
6a62484delete all merged upstream patches: MR 210, MR 231
62fac00Merge branch 't/31336/upgrade_ecl_to_21_2_1' into t/31396/relocatable_wheel_version_of_package_sage_conf
c260942src/pkgs/sage_conf-relocatable/setup.py: Use --enable-download-from-upstream-url

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 19, 2021

Changed commit from c260942 to 4f17a04

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 19, 2021

Branch pushed to git repo; I updated commit sha1. Last 10 new commits:

dc5e225build/pkgs/python3/spkg-configure.m4: On macOS, if the distutils test fails, try using empty ARCHFLAGS
df17ad4tox.ini: Add configuration factors for specific homebrew python3.x
914ea58build/pkgs/python3/spkg-configure.m4: Get rid of stray AC_SUBST
986739bm4/sage_check_python_for_venv.m4: Fix reason
0b3e70dbuild/pkgs/python3/spkg-configure.m4: If PYTHON_FOR_VENV is configured to build multiarch extensions, set SAGE_ARCHFLAGS to disable it
372adcb.github/workflows/tox.yml: Update xcode versions
fc8b676SAGE_CHECK_PYTHON_FOR_VENV: Rework with less nesting
5ae8044Merge branch 'u/mkoeppe/accept__usr_bin_python3_from_xcode_12_3_on_macos_10_15__catalina_' of git://trac.sagemath.org/sage into t/31396/relocatable_wheel_version_of_package_sage_conf
c5c73a9src/pkgs/sage_conf-relocatable/tox.ini: Define environments macos-python3.8, macos-python3.7, macos-python3_xcode
4f17a04src/pkgs/sage_conf-relocatable/setup.py: Use --enable-fat-binary

@mkoeppe

This comment has been minimized.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 19, 2021

Branch pushed to git repo; I updated commit sha1. New commits:

8514352src/pkgs/sage_conf-relocatable/tox.ini: Run delocate-listdeps

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 19, 2021

Changed commit from 4f17a04 to 8514352

@mkoeppe

This comment has been minimized.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 15, 2021

Changed commit from 8514352 to 1baf390

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 15, 2021

Branch pushed to git repo; I updated commit sha1. Last 10 new commits:

c3e4093Rename SAGE_OPTIONAL_CLEANED_PACKAGES to SAGE_OPTIONAL_UNINSTALLED_PACKAGES
4916415Merge tag '9.3.beta9' into t/30383/new_package_type__optional_enabled_by_default
a35428eMerge #30383
e098133src/pkgs/sage_conf/sage_conf.py.in: Add SAGE_SPKG_WHEELS
5dbd712src/pkgs/sage_conf-pypi/setup.py: Use 'configure --disable-notebook', run 'make build' so that wheels are built
839c534src/pkgs/sage_conf-pypi/setup.py: Fix typo
100ff51src/pkgs/sage_conf-pypi/MANIFEST.in: Graft sage_root/build/pkgs/sage_docbuild/src
afa2ffdAdd configure option --disable-sagelib
a4f75b8src/pkgs/sage_conf-pypi: Use configure --disable-sagelib, update README
1baf390Merge branch 't/29039/pip_installable_package_sage_bootstrap' into t/31396/relocatable_wheel_version_of_package_sage_conf

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 11, 2022

Branch pushed to git repo; I updated commit sha1. New commits:

e4d36b5pkgs/sage-conf_relocatable/setup.py: Ignore more files when copying sage_root

@saraedum
Copy link
Member

comment:179

There's an isolated

+        #

Is a comment missing there?

@saraedum
Copy link
Member

comment:180

I don't understand the STICKY business. Why is there a hardcoded /var/tmp there?

@saraedum
Copy link
Member

comment:181

Is the plan to eventually make these wheels available on PyPI?

@saraedum
Copy link
Member

Reviewer: Julian Rüth

@saraedum
Copy link
Member

comment:182

Note to self. I don't really understand what pkgs/sage-conf_relocatable/setup.py does because of the above. The rest looks fine.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jul 14, 2022

comment:183

/var/tmp is a sticky directory, meaning every user can create a new subdirectory, which then securely belongs to them.

The README of https://pypi.org/project/sage-conf/ (section "sage_conf wheels") explains more

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jul 14, 2022

comment:184

Replying to @saraedum:

Is the plan to eventually make these wheels available on PyPI?

Ticket description explains why they can't go to PyPI.

@mkoeppe

This comment has been minimized.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 27, 2022

Changed commit from e4d36b5 to 2eeb402

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 27, 2022

Branch pushed to git repo; I updated commit sha1. New commits:

ecc4a90Merge tag '9.7.beta6' into t/33817/gh_actions__add_test_of_the_modularized_distributions
e82312apkgs/sagemath-{environment,repl}/tox.ini: Update from sagemath-objects
8358976src/bin/sage-update-version: Update install-requires.txt for the distribution packages in pkgs/
b79b5c6build/pkgs/sagemath_objects/dependencies: Restore comment lost in merge
7bb6deebuild/pkgs/python_build: Rename from build/pkgs/build
52e8c41build/bin/sage-build-env[-config]: Do not override SAGE_EDITABLE if it is set already
64b212cpkgs/sagemath-*/tox.ini: Make sagepython-norequirements actually use sage python
2eeb402Merge #33817

@saraedum
Copy link
Member

comment:189

Sorry for not having a look at this ticket for a while. There are merge conflicts now btw.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Dec 15, 2022

Changed commit from 2eeb402 to 1b2d4be

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Dec 15, 2022

Branch pushed to git repo; I updated commit sha1. New commits:

1b2d4beMerge tag '9.8.beta5' into t/31396/relocatable_wheel_version_of_package_sage_conf

@mkoeppe mkoeppe modified the milestones: sage-9.8, sage-9.9 Jan 7, 2023
@mkoeppe mkoeppe removed this from the sage-10.0 milestone Apr 30, 2023
mkoeppe added a commit to mkoeppe/sage that referenced this issue Sep 29, 2023
@mkoeppe
Copy link
Contributor Author

mkoeppe commented Sep 29, 2023

Replaced by #36366.

@mkoeppe mkoeppe closed this as not planned Won't fix, can't repro, duplicate, stale Sep 29, 2023
mkoeppe added a commit to mkoeppe/sage that referenced this issue Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants