Opened 3 years ago

Last modified 7 weeks ago

#21507 new task

Make sagelib a PyPI package — at Version 18

Reported by: mkoeppe Owned by:
Priority: major Milestone: sage-7.6
Component: build Keywords: pip, PyPI
Cc: jdemeyer, was, vbraun, vdelecroix, dimpase, fbissey, embray, leif, aenge, nthiery, mmarco, klee, robertwb, infinity0, thansen, defeo, slelievre, gh-timokau, klui Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description (last modified by mkoeppe)

This is a task ticket organizing the steps necessary to eventually provide sagelib via PyPI.

It would be used by a Python user as follows. Let's assume a user has already installed every package that sage-the-distribution provides on their distribution. Then a simple

  pip install sagelib

would install sagelib in the user's Python installation. Then the user could do from sage.all import *.

. . . . . . . . . . . . . . . . .

Here are the first steps:

  • #21480: Make sagelib setup.py self-contained, independent of SAGE_ROOT
  • #21569: Install src/bin/* scripts via setup.py (scripts, console_scripts)
  • #21570: Move non-scripts of src/bin/ elsewhere (and also move their install location)
  • #21508: Clean up src/setup.py to bring it to standard distutils behavior
  • #21516: Fix sagelib sdist (src/setup.py sdist)
  • #21535: Make src/setup.py independent of SAGE_CYTHONIZED
  • #21527: Fix symbolic link to thebe.js

This defines milestone 1. sagelib is now a well-behaved Python package. It can be built and installed as follows (without invoking sage -sh):

export SAGE_LOCAL=/path/to/local/hierarchy/populated/by/sage/distribution
export SAGE_PKGS=/path/to/sage/distribution/source/directory/build/pkgs
$SAGE_LOCAL/bin/python setup.py install   # or pip install . 

. . . . . . . . . . . . . . . . .

Next steps:

  • Remove the dependency on the environment variable SAGE_PKGS (#20382, ...)

This defines milestone 2. sagelib can now be built and installed as follows (without invoking sage -sh):

export SAGE_LOCAL=/path/to/local/hierarchy/populated/by/sage/distribution
$SAGE_LOCAL/bin/python setup.py install   # or pip install . 

. . . . . . . . . . . . . . . . .

Next steps:

  • Remove the dependency on the SAGE_LOCAL environment variable
    • #15105: hardwired paths in src/sage
    • ...

This defines milestone 3. If SAGE_LOCAL is not set, then sagelib will discover system packages and Python packages installed in standard places.

python setup.py install   # or pip install . 

At this point, sagelib will be ready for upload to PyPI.

Change History (18)

comment:1 Changed 3 years ago by mkoeppe

  • Cc was vbraun vdelecroix dimpase added
  • Description modified (diff)

comment:2 Changed 3 years ago by mkoeppe

  • Cc fbissey embray leif added
  • Description modified (diff)

comment:3 Changed 3 years ago by mkoeppe

  • Description modified (diff)

comment:4 Changed 3 years ago by mkoeppe

  • Milestone changed from sage-7.4 to sage-7.5

comment:5 Changed 3 years ago by mkoeppe

  • Description modified (diff)

comment:6 Changed 3 years ago by mkoeppe

  • Description modified (diff)

comment:7 Changed 3 years ago by mkoeppe

  • Description modified (diff)

comment:8 Changed 3 years ago by mkoeppe

  • Cc aenge nthiery added

comment:9 Changed 3 years ago by mkoeppe

  • Cc mmarco klee robertwb added

comment:10 follow-up: Changed 3 years ago by embray

Thanks for taking the lead on this. There's more still be to added to the list of issues, such as providing binary wheels and how that will be handled. I think it will be important to also make more progress on making some hard dependencies optional (that is, allow optional features to fail gracefully if a dependency for that feature is not found).

comment:11 in reply to: ↑ 10 Changed 3 years ago by mkoeppe

Replying to embray:

There's more still be to added to the list of issues, such as providing binary wheels and how that will be handled.

Definitely. I'm hoping that we can use this ticket to organize it.

I think it will be important to also make more progress on making some hard dependencies optional (that is, allow optional features to fail gracefully if a dependency for that feature is not found).

I agree.

comment:12 Changed 3 years ago by mkoeppe

Here's a question for the distutils experts. Is a Python package allowed to install things in bin/? Do any other Python packages do that? Where would one install helper scripts? Is there a Python equivalent of $prefix/libexec?

comment:13 Changed 3 years ago by mkoeppe

  • Description modified (diff)

comment:14 Changed 3 years ago by was

This Python package, which is part of SMC, installs many things to /usr/local/bin using completely standard approaches: https://github.com/sagemathinc/smc/tree/master/src/smc_pyutil. See, in particular, the console_scripts section of setup.py: https://github.com/sagemathinc/smc/blob/master/src/smc_pyutil/setup.py#L58

comment:15 Changed 3 years ago by mkoeppe

Thanks a lot! Following your pointer, I've found this documentation: http://python-packaging.readthedocs.io/en/latest/command-line-scripts.html, which I will refer to alongside the example that you pointed out.

comment:16 Changed 3 years ago by mkoeppe

  • Description modified (diff)

comment:17 Changed 3 years ago by mkoeppe

This now #21569.

comment:18 Changed 3 years ago by mkoeppe

  • Description modified (diff)
Note: See TracTickets for help on using tickets.