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

spkg-configure.m4 for python3 #27824

Closed
dimpase opened this issue May 13, 2019 · 137 comments
Closed

spkg-configure.m4 for python3 #27824

dimpase opened this issue May 13, 2019 · 137 comments

Comments

@dimpase
Copy link
Member

dimpase commented May 13, 2019

Do not install python3 if a sufficiently new version is available in $PATH. This could be a system python3, or the python3 from within a venv.

As suggested in #29032, we make $SAGE_LOCAL a venv (https://docs.python.org/3/library/venv.html) over the system python3 -- if a suitable system python3 is found -- by using the venv.EnvBuilder API.

This is done by the new script build/bin/sage-venv, which we use both during configure (to make sure that we select a system python3 for which venvs work correctly) and during make.

The venv does not include the system site-packages: We continue to install all Python packages into our venv using the existing build infrastructure. We keep the task of using system site-packages for the follow-up ticket #29023.

(Note, we use venv (new since Python 3.3), not virtualenv. So this change is limited to Python 3 builds of Sage.)

CC: @jdemeyer @embray @vbraun @kiwifb @jhpalmieri @videlec

Component: build: configure

Author: Matthias Koeppe, Erik Bray

Branch: 1c845a4

Reviewer: Dima Pasechnik

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

@dimpase dimpase added this to the sage-8.8 milestone May 13, 2019
@dimpase

This comment has been minimized.

@dimpase

This comment has been minimized.

@embray
Copy link
Contributor

embray commented Jun 14, 2019

comment:3

As the Sage-8.8 release milestone is pending, we should delete the sage-8.8 milestone for tickets that are not actively being worked on or that still require significant work to move forward. If you feel that this ticket should be included in the next Sage release at the soonest please set its milestone to the next release milestone (sage-8.9).

@embray embray removed this from the sage-8.8 milestone Jun 14, 2019
@embray
Copy link
Contributor

embray commented Aug 14, 2019

comment:4

For Python packages when installing using the system Python we definitely need a well thought out approach, likely with different options for handling questions such as where to install additional Python packages.

$SAGE_LOCAL already acts as a sort-of virtualenv, but we might still consider using virtualenv/venv in $SAGE_LOCAL (with the --system-site-packages option) as a way of extending sys.path while still using as many system Python packages as possible.

@mkoeppe
Copy link
Contributor

mkoeppe commented Jan 14, 2020

comment:5

See #29013 - "In a python3 build, install all Python packages into a venv"

@mkoeppe

This comment has been minimized.

@mkoeppe
Copy link
Contributor

mkoeppe commented Jan 15, 2020

Dependencies: #29013

@mkoeppe
Copy link
Contributor

mkoeppe commented Jan 15, 2020

comment:6

Narrowed the ticket to py3.

@mkoeppe mkoeppe changed the title spkg-configure.m4 for pythons spkg-configure.m4 for python3 Jan 15, 2020
@mkoeppe
Copy link
Contributor

mkoeppe commented Jan 15, 2020

Branch: public/27824-python3-spkg-configure

@mkoeppe
Copy link
Contributor

mkoeppe commented Jan 15, 2020

comment:8

Here's a version that works. The venv is created in build/make/Makefile target (in #29013, I created the venv in the spkg-postinst script of the python3 spkg.)


New commits:

1363425In a python3 build, install all Python packages into a venv
a394268sage-pip-install: Use PYTHON=sage-python23
a84815bspkg-configure.m4 for python3

@mkoeppe
Copy link
Contributor

mkoeppe commented Jan 15, 2020

Commit: a84815b

@mkoeppe
Copy link
Contributor

mkoeppe commented Jan 15, 2020

Author: Matthias Koeppe

@mkoeppe mkoeppe added this to the sage-9.2 milestone Jan 15, 2020
@dimpase
Copy link
Member Author

dimpase commented Jan 15, 2020

comment:10

how about checking for Py3 deps: sqlite libpng bzip2 xz libffi ?
(I skipped in this list ones that are 2nd order, so no need to check them)

@dimpase
Copy link
Member Author

dimpase commented Jan 15, 2020

comment:11

On Gentoo Python 3 does not have sqlite module by default. I had to do
$ pip install pysqlite3 --user, and still elliptic_curves spkg installation errors out.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 15, 2020

Changed commit from a84815b to 0d0495f

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 15, 2020

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

0d0495fbuild/pkgs/python3/spkg-configure.m4: Add SAGE_SPKG_DEPCHECK for sqlite libpng bzip2 xz libffi

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 15, 2020

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

98dff9dRemove use of --system-site-packages

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 15, 2020

Changed commit from 0d0495f to 98dff9d

@mkoeppe
Copy link
Contributor

mkoeppe commented Jan 15, 2020

comment:14

I've reduced the scope of the ticket, excluding the use of system site packages.

@mkoeppe

This comment has been minimized.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 15, 2020

Changed commit from 98dff9d to 6180132

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 15, 2020

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

6180132build/pkgs/python3/spkg-configure.m4: Find @PYTHON_FOR_VENV@ that has sqlite3 module

@dimpase
Copy link
Member Author

dimpase commented Jan 15, 2020

comment:16

I tried this on gentoo (after a usual struggle to get sqlite3 module built in Python)
and it broke at docbuild, with

RuntimeError: libSingular not found--a working Singular install in $SAGE_LOCAL is required for Sage to work

even though libSingular has built just fine (it's some magic with from sage.env import SINGULAR_SO that is broken, so SINGULAR_SO is None)

@mkoeppe
Copy link
Contributor

mkoeppe commented Mar 22, 2020

comment:93

Breaks python 2 builds

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 22, 2020

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

65a9f02build/make/deps: Do not set PYTHON = python3_venv in a python2 build

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 22, 2020

Changed commit from c570d6b to 65a9f02

@mkoeppe
Copy link
Contributor

mkoeppe commented Mar 22, 2020

comment:96

Ready for review

@mkoeppe
Copy link
Contributor

mkoeppe commented Mar 22, 2020

comment:97

New tests at https://github.com/mkoeppe/sage/actions/runs/60877259; see also #29367

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 23, 2020

Changed commit from 65a9f02 to 1c845a4

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 23, 2020

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

1c845a4build/pkgs/python3/spkg-configure.m4: Do not use venv for python3 if we do a python2 build

@mkoeppe
Copy link
Contributor

mkoeppe commented Mar 23, 2020

@dimpase
Copy link
Member Author

dimpase commented Mar 23, 2020

comment:100

Let's move this, looks good to me.

@dimpase
Copy link
Member Author

dimpase commented Mar 23, 2020

Reviewer: Dima Pasechnik

@mkoeppe
Copy link
Contributor

mkoeppe commented Mar 23, 2020

comment:101

Thanks!

@vbraun
Copy link
Member

vbraun commented Mar 29, 2020

Changed branch from public/27824-python3-spkg-configure to 1c845a4

@mezzarobba
Copy link
Member

Changed commit from 1c845a4 to none

@mezzarobba
Copy link
Member

comment:103

Hello everyone,

When trying to upgrade to 9.1.rc5, I'm seeing an issue that I suspect could be a side effect of this ticket.

For some reason my sage/local/bin/python3.7 was a symlink to the system python binary. Sage decided it wanted to install its own python-3.7.3.p1, but that failed with a permission error on the symlink. After deleting the symlink, python builds and installs correctly. (I let the logs be overwritten, so I won't be able to provide much details — sorry.)

The overall Sage build still fails with an error about six not being found while building setuptools that I haven't yet investigated.

@dimpase
Copy link
Member Author

dimpase commented May 18, 2020

comment:104

if you switch to py3 from py2, you probably need to run ./configure --with-python=3

it is not clear what version you were on, but the changes to the build system were very substantial, so ymmv.

@mkoeppe
Copy link
Contributor

mkoeppe commented May 18, 2020

comment:105

Yes, this is a known limitation. I have created #29708 (Fix switching between --with-system-python3 and --without-system-python3) for it. We shall fix it in 9.2.

pranavrajpal added a commit to pranavrajpal/sage that referenced this issue Jun 18, 2023
Remove crypt from the list of modules that we try to import when
checking whether a given system python will work for our purposes,
since:
- It doesn't work on Windows (so it prevents us from running sagemath on
  Windows)
- Searching the entire repo doesn't find any uses of crypt
- crypt is deprecated anyways (PEP 594 has its removal scheduled for
  Python 3.13)

The check for crypt was added at the same time as the other modules
being checked, but neither the commit message for
6fcd7cd nor the discussion in
Trac sagemath#27824 mentions why crypt specifically was added (Most of the
relevant discussion in that ticket is about the distutils check).
pranavrajpal added a commit to pranavrajpal/sage that referenced this issue Jun 18, 2023
Remove crypt from the list of modules that we try to import when
checking whether a given system python will work for our purposes,
since:
- It doesn't work on Windows (so it prevents us from running sagemath on
  Windows)
- Searching the entire repo doesn't find any uses of crypt
- crypt is deprecated anyways (PEP 594 has its removal scheduled for
  Python 3.13)

The check for crypt was added at the same time as the other modules
being checked, but neither the commit message for
6fcd7cd nor the discussion in
Trac sagemath#27824 mentions why crypt specifically was added (Most of the
relevant discussion in that ticket is about the distutils check).
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

6 participants