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

Don't use make for autogenerated modules in sagelib #21613

Closed
embray opened this issue Sep 29, 2016 · 78 comments
Closed

Don't use make for autogenerated modules in sagelib #21613

embray opened this issue Sep 29, 2016 · 78 comments
Assignees
Milestone

Comments

@embray
Copy link
Contributor

embray commented Sep 29, 2016

Currently there is a src/Makefile at the root of the sagelib sources that is required to be invoked in order to make sure the packages in sage_setup.autogen and that autogenerated sources are placed in the sage sources before running its setup.py install.

#21480 inverts things somewhat by removing the old Makefile (really making it into a no-op for now), but pulling out the sage_setup.autogen stuff into a separate makefile that is still invoked by calling make from the setup.py (in the current version of that ticket it is even called unconditionally). This is pretty non-standard.

The appropriate time to do this would be either just before the build_py command is run, or the build_ext command is run (in the case of autogenerated sources for extension modules).

In the current cases we have its very trivial to check whether or not any of the sources actually need to be regenerated, and this is a pretty normal thing to do in some other complex Python packages. For example, the package responsible for generating the source files (e.g. currently the sage_setup.autogen sub-packages) simply needs to be responsible for knowing what its own source code files are, and knowing the paths for its generated sources--then just compare modtimes. Invoking make is not required at all.

One can do even better by having one of the generated files be a hash of the source files, and compare the hashes instead (this avoids rebuilds when switching between git branches but where the files didn't otherwise change).

CC: @mkoeppe @jdemeyer

Component: build

Author: Erik Bray

Branch: 34ca46c

Reviewer: Matthias Koeppe

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

@embray embray added this to the sage-7.4 milestone Sep 29, 2016
@mkoeppe
Copy link
Contributor

mkoeppe commented Sep 29, 2016

comment:2

From the description:

The appropriate time to do this would be either just before the build_py command is run, or the build_ext command is run (in the case of autogenerated sources for extension modules).

Could you make a ticket on top of #21480 (and probably #21604) that moves the invocation of make -f generate_py_source.mk to the right place?

@jdemeyer
Copy link

comment:3

Replying to @mkoeppe:

Could you make a ticket on top of #21480 (and probably #21604) that moves the invocation of make -f generate_py_source.mk to the right place?

That's not so easy, for the same reason that #21600 is not so easy. We need to pass the list of Python packages, Cython extensions and data_files to setup(). It is harder to get this right if not everything has been generated at that point. We should probably compute the list of packages dynamically in setup().

@jdemeyer
Copy link

comment:4

Again, the title of this ticket does not match the long description. Do you want to get rid of make or just move the invocation of make -f generate_py_source.mk inside setup()?

@embray
Copy link
Contributor Author

embray commented Sep 30, 2016

comment:5

I think it does match but I'm not sure what's unclear.

@embray

This comment has been minimized.

@embray
Copy link
Contributor Author

embray commented Sep 30, 2016

comment:6

I feel like this is not hard, having done it many times before. There's nothing particularly special about sage either in any of these regards.

@embray
Copy link
Contributor Author

embray commented Oct 6, 2016

Changed dependencies from #21480 to #21600

@embray embray self-assigned this Oct 6, 2016
@embray
Copy link
Contributor Author

embray commented Oct 7, 2016

Author: Erik Bray

@embray
Copy link
Contributor Author

embray commented Oct 7, 2016

Commit: edb3cf8

@embray
Copy link
Contributor Author

embray commented Oct 7, 2016

comment:9

Determine directly in the Python code whether or not autogenerated sources need to be built, without requiring a makefile or anything. I think this is simple and clear to anyone who looks at the code.

If in the future we want more full make-like capabilities I've got something in the works for that, but it seems unlikely that anything more complicated than this is needed any time soon.


Last 10 new commits:

7791cd9Remove --buildbase code
74169e7Pass SAGE_SRC to generate_py_source.mk
0394333Add new file to MANIFEST.in
fdedb02Install SAGE_LOCAL/bin/sage instead of SAGE_ROOT/sage as Jupyter kernel
5ba95edClean up stale installed files in install command
35ecf4bRun cythonize() inside build_ext command
2b5fa98Copy extra files to build directory instead of using data_files
7e3a492Rename extra_files -> sage_extra_files
237e965Replace some implicit relative imports with explicit imports.
edb3cf8Do effectively exactly what the makefile for the autogen sources was doing, but purely in Python, removing the use of make.

@embray
Copy link
Contributor Author

embray commented Oct 7, 2016

Branch: u/embray/ticket-21613

@mkoeppe
Copy link
Contributor

mkoeppe commented Oct 9, 2016

comment:10

This looks nice and easy to understand.
But let's get #21600 done before we full review this one.

@mkoeppe
Copy link
Contributor

mkoeppe commented Oct 14, 2016

comment:11

On this ticket, 0394333 needs to be reverted, generate_py_source removed again from MANIFEST.in

(Of course, the manifest is out-of-date in many respects (#21516).)

@embray
Copy link
Contributor Author

embray commented Oct 14, 2016

comment:12

Indeed. I just noticed that MANIFEST.in contains MANIFEST.in, which it really doesn't need to do :)

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 14, 2016

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

9f92cb3Remove generate_py_source.mk from MANIFEST.in as it no longer exists

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 14, 2016

Changed commit from edb3cf8 to 9f92cb3

@mkoeppe
Copy link
Contributor

mkoeppe commented Oct 17, 2016

comment:15

This needs rebasing on top of current develop and possibly some work there.
Building from scratch (with 7.4.rc2 merged) fails for me with:

No such file or directory: '/doesnotexist/sage/libs/pari/paridecl.pxd'

(this is from #21480).

@embray
Copy link
Contributor Author

embray commented Nov 21, 2016

comment:53

I don't really think that belongs here in the first place but okay.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 21, 2016

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

e45216fClean up old autogenerated files before outputting new ones.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 21, 2016

Changed commit from 9750ba7 to e45216f

@embray
Copy link
Contributor Author

embray commented Nov 21, 2016

New commits:

e45216fClean up old autogenerated files before outputting new ones.

@jdemeyer
Copy link

comment:56

In #21820, some paths changed. In particular, the generated files are now in src/sage/libs/cypari2.

@jdemeyer
Copy link

Changed dependencies from #21820 to none

@embray
Copy link
Contributor Author

embray commented Nov 22, 2016

comment:57

Yes, I see that now. Incidentally building still worked, it just built the files in the wrong place.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 22, 2016

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

91fb12eUse sage_src_pari to get the output path for generated files.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 22, 2016

Changed commit from e45216f to 91fb12e

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 22, 2016

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

34ca46cDon't look for the decl.pxi file anymore

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 22, 2016

Changed commit from 91fb12e to 34ca46c

@embray
Copy link
Contributor Author

embray commented Nov 22, 2016

New commits:

91fb12eUse sage_src_pari to get the output path for generated files.
34ca46cDon't look for the decl.pxi file anymore

@mkoeppe
Copy link
Contributor

mkoeppe commented Dec 6, 2016

comment:61

Looks good to me; though the description of this ticket could use updating.

@vbraun
Copy link
Member

vbraun commented Dec 7, 2016

Changed branch from u/embray/ticket-21613 to 34ca46c

@fchapoton
Copy link
Contributor

comment:63

Some changes made here are not py3 compatible, and need to be corrected to be so.

try:

export SAGE_PYTHON3=yes 
make build

@fchapoton
Copy link
Contributor

Changed commit from 34ca46c to none

@fchapoton
Copy link
Contributor

comment:64

proposal fix in #22044

@jdemeyer
Copy link

comment:65

Breakage: #22094.

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

5 participants