Skip to content

Commit

Permalink
Add a new fixer for Sage 9.2, which uses Python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
culler committed Dec 23, 2020
1 parent 975abd6 commit 55ae8b6
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 8 deletions.
15 changes: 7 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ Fixing SageMath on macOS
This small module is to help folks install and use SnapPy inside
SageMath, by doing two things:

1) Provide SSL support via openssl so that ``sage -pip install snappy``
works.
1) Provide SSL support via openssl so that ``sage -pip install snappy`` works.

2) Install a recent version of Tk so that the SnapPy's graphics work
in Sage.
2) Install a recent version of Tk so that the SnapPy's graphics work in Sage.

To install, download the either ``fix_mac_sage8.tar.gz`` or
``fix_mac_sage9.tar.gz``, from::
Depending on the version of Sage that you have installed, download one
of ``fix_mac_sage8.tar.gz``, ``fix_mac_sage9.tar.gz`` or ``fix_sage_9_2.tgz`` from::

http://github.com/3-manifolds/fix_mac_sage/releases/latest/

depending on whether you have SageMath 8.* or 9.*, unpack, consult the
README therein and follow the instructions
(Sage 9.2 requires fix_sage_9_2.tgz because it uses Python 3.8 instead of
Python 3.7. Earlier versions of Sage 9 can use fix_mac_sage9.tgz.) Unpack
the tar archive, consult the README therein and follow the instructions.
10 changes: 10 additions & 0 deletions fix_mac_sage9_2/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
This python module fixes the Sage 9 distribution so as to make the
tkinter and ssl modules work. (The ssl module is used by pip.) It
runs an installer which installs Tk 8.6.10 in /Library/Frameworks
and adds some missing libraries to Sage. You will need to run
the Sage 9 python interpreter to make the patch. For example,
if you have installed Sage 9 in your applications folder you
would change to the directory containing the mac_sage9 directory
which contains this README file and run:

/Applications/SageMath-9.0.app/sage -python -m mac_sage9.fix
Empty file added fix_mac_sage9_2/__init__.py
Empty file.
39 changes: 39 additions & 0 deletions fix_mac_sage9_2/fix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import os, subprocess

sage_root = os.environ['SAGE_ROOT']
sage_local = os.path.join(sage_root, 'local')
sage_libdynload = os.path.join(sage_local, 'lib', 'python3.7', 'lib-dynload')
old_libssl = '/usr/local/lib/libssl.1.1.dylib'
new_libssl = os.path.join(sage_local, 'lib', 'libssl.1.1.dylib')
old_libcrypto = '/usr/local/lib/libcrypto.1.1.dylib'
new_libcrypto = os.path.join(sage_local, 'lib', 'libcrypto.1.1.dylib')
ssl_lib = os.path.join(sage_libdynload, '_ssl.so')

from . import __path__
tk_path = '/Library/Frameworks/Tk.framework/Versions/8.6'

def tk_installed():
if os.path.exists(tk_path):
tkconfig = os.path.join(tk_path, 'tkConfig.sh')
output = subprocess.run(['grep', 'TK_PATCH_LEVEL', tkconfig],
capture_output=True).stdout
tk_patch = int(output.split(b"'")[1][1:])
if tk_patch != 10:
return False
else:
return False
return True

if __name__ == '__main__':
here = __path__[0]
print("Installing Tk 8.6.10 in /Library/Frameworks -- please choose the defaults.")
subprocess.run(['open', '-W', os.path.join(here, 'TclTk-8.6.10.pkg')])
print("Adding the _tkinter and _ssl modules to Sage")
subprocess.run(['cp', '-r', os.path.join(here, 'local/'), sage_local])
print('Rewriting id and dependency paths in _ssl, libssl and libcrypto.')
subprocess.run(['install_name_tool', '-id', ssl_lib, ssl_lib])
subprocess.run(['install_name_tool', '-change', old_libssl, new_libssl, ssl_lib])
subprocess.run(['install_name_tool', '-change', old_libcrypto, new_libcrypto, ssl_lib])
subprocess.run(['install_name_tool', '-id', new_libssl, new_libssl])
subprocess.run(['install_name_tool', '-change', old_libcrypto, new_libcrypto, new_libssl])
subprocess.run(['install_name_tool', '-id', new_libcrypto, new_libcrypto])
125 changes: 125 additions & 0 deletions fix_mac_sage9_2/license-openssl-ssleay.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@

LICENSE ISSUES
==============

The OpenSSL toolkit stays under a double license, i.e. both the conditions of
the OpenSSL License and the original SSLeay license apply to the toolkit.
See below for the actual license texts.

OpenSSL License
---------------

/* ====================================================================
* Copyright (c) 1998-2019 The OpenSSL Project. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. All advertising materials mentioning features or use of this
* software must display the following acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
*
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
* endorse or promote products derived from this software without
* prior written permission. For written permission, please contact
* [email protected].
*
* 5. Products derived from this software may not be called "OpenSSL"
* nor may "OpenSSL" appear in their names without prior written
* permission of the OpenSSL Project.
*
* 6. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
*
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This product includes cryptographic software written by Eric Young
* ([email protected]). This product includes software written by Tim
* Hudson ([email protected]).
*
*/

Original SSLeay License
-----------------------

/* Copyright (C) 1995-1998 Eric Young ([email protected])
* All rights reserved.
*
* This package is an SSL implementation written
* by Eric Young ([email protected]).
* The implementation was written so as to conform with Netscapes SSL.
*
* This library is free for commercial and non-commercial use as long as
* the following conditions are aheared to. The following conditions
* apply to all code found in this distribution, be it the RC4, RSA,
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
* included with this distribution is covered by the same copyright terms
* except that the holder is Tim Hudson ([email protected]).
*
* Copyright remains Eric Young's, and as such any Copyright notices in
* the code are not to be removed.
* If this package is used in a product, Eric Young should be given attribution
* as the author of the parts of the library used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* "This product includes cryptographic software written by
* Eric Young ([email protected])"
* The word 'cryptographic' can be left out if the rouines from the library
* being used are not cryptographic related :-).
* 4. If you include any Windows specific code (or a derivative thereof) from
* the apps directory (application code) you must include an acknowledgement:
* "This product includes software written by Tim Hudson ([email protected])"
*
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
*/

Binary file added fix_mac_sage9_2/local/lib/libcrypto.1.1.dylib
Binary file not shown.
Binary file added fix_mac_sage9_2/local/lib/libssl.1.1.dylib
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 55ae8b6

Please sign in to comment.