Issue 5565: simplify python-related makefiles (issue 581080044 by nine.fierce.ballads@gmail.com)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Issue 5565: simplify python-related makefiles (issue 581080044 by nine.fierce.ballads@gmail.com)

nine.fierce.ballads
Reviewers: ,

Description:
https://sourceforge.net/p/testlilyissues/issues/5565/

Avoid encoding unnecessary details of Python compilation into the
build rules.  Remove some cruft.

I hope that these changes will work equally well with Python 2 and 3,
but I have only tested in an environment with 2.

Please review this at https://codereview.appspot.com/581080044/

Affected files (+11, -30 lines):
   M stepmake/stepmake/python-module-rules.make
   M stepmake/stepmake/python-module-targets.make
   M stepmake/stepmake/python-module-vars.make


Index: stepmake/stepmake/python-module-rules.make
diff --git a/stepmake/stepmake/python-module-rules.make  
b/stepmake/stepmake/python-module-rules.make
index  
bf99f8feaa569204a5a343601ff98895705452eb..88c7590060d5929a4f6b5c9ba30a8129f0582394  
100644
--- a/stepmake/stepmake/python-module-rules.make
+++ b/stepmake/stepmake/python-module-rules.make
@@ -1,14 +1,12 @@
-
-$(outdir)/%$(SHARED_MODULE_SUFFIX): $(outdir)/%.lo
- $(LD) -o $@ $< $(SHARED_FLAGS) $(ALL_LDFLAGS)
-
-$(outdir)/%.pyc: $(outdir)/%.py
- PYTHONOPTIMIZE= $(PYTHON) -c 'import py_compile; py_compile.compile  
("$<")'
-
-$(outdir)/%.pyo: $(outdir)/%.py
- $(PYTHON) -O -c 'import py_compile; py_compile.compile ("$<")'
-
+.DELETE_ON_ERROR:
+
+# Different versions of Python compile to different places.  We ignore
+# those details and base build dependencies on the *.py script alone.
+# Whenever the script is updated, we also try to compile it.  If
+# compilation fails, make removes the script (because of
+# .DELETE_ON_ERROR:) so that this recipe will be retried the next time
+# make is invoked.
  $(outdir)/%.py: %.py $(config_make) $(depth)/VERSION
- cat $< | sed $(sed-atfiles) | sed $(sed-atvariables) > $@
+ sed $(sed-atfiles) < $< | sed $(sed-atvariables) > $@
+ PYTHONOPTIMIZE= $(PYTHON) -c 'import py_compile; py_compile.compile  
("$@", doraise=True)'
  chmod 755 $@
-
Index: stepmake/stepmake/python-module-targets.make
diff --git a/stepmake/stepmake/python-module-targets.make  
b/stepmake/stepmake/python-module-targets.make
index  
44bde97e2fb7177a499125fed66a8bf299b21f03..09e6d2e349fbe590a6eae1bb7b4846bd63306973  
100644
--- a/stepmake/stepmake/python-module-targets.make
+++ b/stepmake/stepmake/python-module-targets.make
@@ -1 +1 @@
-default: $(OUT_PY_MODULES) $(OUT_PYC_MODULES) $(OUT_SO_MODULES)
+default: $(OUT_PY_MODULES)
Index: stepmake/stepmake/python-module-vars.make
diff --git a/stepmake/stepmake/python-module-vars.make  
b/stepmake/stepmake/python-module-vars.make
index  
fc6ea3fb8a087de804f6fe5f3943edfbb06ec1d9..14d9742ca57ec87fba7127b1ac8b392efe88983b  
100644
--- a/stepmake/stepmake/python-module-vars.make
+++ b/stepmake/stepmake/python-module-vars.make
@@ -1,19 +1,2 @@
-ALL_LDFLAGS = $(LDFLAGS)
  PY_MODULES_IN = $(call src-wildcard,*.py)
  OUT_PY_MODULES = $(PY_MODULES_IN:%=$(outdir)/%)
-OUT_PYC_MODULES = $(OUT_PY_MODULES:%.py=%.pyc)
-OUT_PYO_MODULES = $(OUT_PY_MODULES:%.py=%.pyo)
-ifeq ($(MINGW_BUILD)$(CYGWIN_BUILD),)
-SHARED_MODULE_SUFFIX = .so
-else
-ifneq ($(CYGWIN_BUILD),)
-SHARED_MODULE_SUFFIX = .dll
-endif
-ifneq ($(MINGW_BUILD),)
-SHARED_MODULE_SUFFIX = .dll
-endif
-endif
-ifneq ($(DARWIN_BUILD),)
-SHARED_FLAGS = -bundle -flat_namespace -undefined suppress
-endif
-OUT_SO_MODULES = $(addprefix $(outdir)/,  
$(C_FILES:.c=$(SHARED_MODULE_SUFFIX)))



_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5565: simplify python-related makefiles (issue 581080044 by nine.fierce.ballads@gmail.com)

Dev mailing list
LGTM.


https://codereview.appspot.com/581080044/diff/578940043/stepmake/stepmake/python-module-rules.make
File stepmake/stepmake/python-module-rules.make (right):

https://codereview.appspot.com/581080044/diff/578940043/stepmake/stepmake/python-module-rules.make#newcode1
stepmake/stepmake/python-module-rules.make:1: .DELETE_ON_ERROR:
Looking into the info file of make it seems that DELETE_ON_ERROR has a
global meaning.  If this is true I suggest that you put it into the
topmost make file.

https://codereview.appspot.com/581080044/

_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5565: simplify python-related makefiles (issue 581080044 by nine.fierce.ballads@gmail.com)

nine.fierce.ballads
In reply to this post by nine.fierce.ballads
On 2019/10/03 04:27:01, lemzwerg wrote:
> Looking into the info file of make it seems that DELETE_ON_ERROR has a
global
> meaning.  If this is true I suggest that you put it into the topmost
make file.

The thought crossed my mind, but there's a lot I don't yet know about
this build system, and I was worried that that change might impact a
workflow in an area I haven't tested.

It looks like make/stepmake.make is an appropriate place to put it,
near where ".SECONDARY:" appears.  I will try moving it there in a
separate commit and test the python rules again.  If any undesirable
side effects are discovered later, only the second commit will need to
be reverted.


https://codereview.appspot.com/581080044/

_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel