sagemath/sage

make sagelib use setuptools instead of distutils

ohanar opened this issue · 41 comments

Currently the sage library uses distutils. Switching to setuptools will give us the setup.py develop command, which bypasses the need to rebuild the sage library when modifying python files.

See also:
#29845 - PEP 517 buildapi for sage_setup


References:

https://stackoverflow.com/questions/3779915/why-does-python-setup-py-sdist-create-unwanted-project-egg-info-in-project-r

Depends on #29702
Depends on #29803

CC: @kini @jdemeyer @robertwb @kcrisman @mwhansen @jhpalmieri @embray @dimpase @kiwifb

Component: build

Branch/Commit: u/mkoeppe/make_sagelib_use_setuptools_instead_of_distutils @ 93bbbfe

Reviewer: Dima Pasechnik

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

Dependencies: #13031

comment:3

I would imagine that you get problems similar to #12659 . Have you tried this out?

comment:4

Replying to @mwhansen:

I would imagine that you get problems similar to #12659 . Have you tried this out?

Do you mean the sdist issues? No, I have not tried them yet, but I wouldn't doubt that there may be issues with them. Also, as noted in deps, there is an issue with parallel instances of setuptools, so either deps has to be hacked to force sage into the serial build, or we depend on #12994 (my vote is the later, since it is cleaner).

comment:5

I've decided to make #12994 a dependency -- makes it much easier to add setuptool packages to the build system.

Changed dependencies from #13031 to #12994, #13031

Changed dependencies from #12994, #13031 to #12994, #13031, #13197

comment:7

There are some issues with using relative paths with setuptools (which we want for relocation purposes). #13197 fixes these issues.

Changed dependencies from #12994, #13031, #13197 to #11874, #12994, #13031, #13197

comment:9

I am a bit lost on the inter-relations between the tickets #12994, #13190, #13201, #13197 (and perhaps #12659). Could you please clarify the dependencies?

Also, I personally think it would be better to split this in two tickets:
A. Use setuptools
B. Use setup.py develop

comment:10

Replying to @jdemeyer:

I am a bit lost on the inter-relations between the tickets #12994, #13190, #13201, #13197 (and perhaps #12659). Could you please clarify the dependencies?

Also, I personally think it would be better to split this in two tickets:
A. Use setuptools

This should only require #13031.

B. Use setup.py develop

This is more or less #12659 after switching to setuptools, and is where the other dependencies creep up (they aren't strictly necessary, but the alternative is to hack around setuptools, which is less preferable than patching it IMO).

I'll rework the patch to only do A once we have a 5.4 beta (mainly because #13031 more or less needs to be rebased with every development release).

apply to root repo

Attachment: trac13190_root.patch.gz

Attachment: trac13190_scripts.patch.gz

apply to scripts repo

Changed dependencies from #11874, #12994, #13031, #13197 to #11874, #12994, #13031

comment:11

ok, rebased and only does the switch to setuptools (doesn't switch to setup.py develop anymore). Dependencies are now accurate.

Attachment: trac13190_library.patch.gz

apply to sage library

comment:13

Are we trying to make this happen before the git transition or afterward?

comment:14

Certainly after, although I'm not currently convinced that we should proceed in this direction.

comment:18

Any thoughts on this? It hasn't been touched in quite some time despite there being (a likely outdated by now) patch. I can take this issue over and see it to completion if desired.

comment:19

There is at least one problem: setuptools does not support setup(data_files=...), see setuptools #130. It's a good reason to avoid setuptools.

I'm not sure that we need data_files for the Sage library though. Maybe we could use package_data instead. But then that is something which should be investigated.

Changed dependencies from #11874, #12994, #13031 to none

comment:21

I don't know what files need to be installed with the sage package. For the majority of Python-based projects package_data is preferred, but of course Sage is 'special'.

Let me look into what files are installed with the sage package, and I can worry about the details.

comment:22

Hang on, I'm looking at it.

comment:23

I created a new ticket for using package_data.

Dependencies: #20108

comment:24

Replying to @jdemeyer:

There is at least one problem: setuptools does not support setup(data_files=...), see setuptools #130. It's a good reason to avoid setuptools.

I recently learned about the (almost undocumented) setuptools options --old-and-unmanageable. It forces a non-egg build which is exactly what we want. So that would make this ticket possible again.

Changed dependencies from #20108 to none

comment:26

Also, it seems that Sage is no longer using either data_files or package_data. So that discussion has also disappeared.

comment:27

I forget, what is the difference between --old-and-unmanageable and --single-version-externally-managed, where I thought the latter should be sufficient...

Also I do want to use package_data for Sage (see e.g. #21732) but I don't see what the problem is.

comment:28

Replying to @embray:

Also I do want to use package_data for Sage (see e.g. #21732) but I don't see what the problem is.

There is no problem with package_data if you want to use it in the way that it was intended to be used (which may not align with actual use cases).

There is a problem with data_files: setuptools still doesn't really support that. One of the reasons that this ticket stalled was because Sage was using data_files at the time to install Cython-related files. You suggested that it would be easy to use package_data instead (#20108). That didn't actually work, but now we are using custom code (neither data_files not package_data, see #21600) to install those files.

comment:29

Replying to @embray:

I forget, what is the difference between --old-and-unmanageable and --single-version-externally-managed

Mainly that the latter requires a --record argument also.

Changed author from R. Andrew Ohana to none

comment:30

Time to revive this ancient ticket.

Dependencies: #29702

Last 10 new commits:

0a61795Trac #29345: don't force SHELL=bash any longer.
5db5318Trac #29345: remove "break" statements from AC_SEARCH_LIBS.
e810ad1Trac #29345: don't use sage's config.status for the lrcalc build.
93c9921Trac #29345: replace the function that populates the CVXOPT_* variables.
0e66a0aTrac #29345: add Dima's SPKG patches for ksh compatibility.
df3f05ebuild/make/Makefile.in [SCRIPT_PACKAGE_templ]: cd into the SPKG directory; adjust spkg-install scripts
5372065Merge branch 't/29793/script_packages_should_cd_into_the_spkg_directory' into t/29411/make_sagelib_a_script_package
c166b97Merge branch 't/29411/make_sagelib_a_script_package' into t/29702/move_all_code_from_src_setup_py__src_fpickle_setup_py_to_sage_setup
5f33436src/setup.py: from setuptools import setup
93bbbfeAdd src/setup.cfg

Commit: 93bbbfe

Description changed:

--- 
+++ 
@@ -1 +1,9 @@
 Currently the sage library uses distutils. Switching to setuptools will give us the `setup.py develop` command, which bypasses the need to rebuild the sage library when modifying python files.
+
+---
+
+References:
+
+https://stackoverflow.com/questions/3779915/why-does-python-setup-py-sdist-create-unwanted-project-egg-info-in-project-r
+
+

Changed dependencies from #29702 to #29702, #29803

Description changed:

--- 
+++ 
@@ -1,4 +1,8 @@
 Currently the sage library uses distutils. Switching to setuptools will give us the `setup.py develop` command, which bypasses the need to rebuild the sage library when modifying python files.
+
+See also:
+#29845 - PEP 517 buildapi for sage_setup
+
 
 ---
 
comment:37

This ticket is superseded by #29950 and can be closed.

Reviewer: Dima Pasechnik