python3: split source packages away from compiled packages
authorAlexandru Ardelean <ardeleanalex@gmail.com>
Thu, 2 Mar 2017 16:02:14 +0000 (18:02 +0200)
committerAlexandru Ardelean <ardeleanalex@gmail.com>
Thu, 9 Mar 2017 16:43:47 +0000 (18:43 +0200)
Same as for python.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
lang/python3/Makefile
lang/python3/files/python3-package-install.sh
lang/python3/files/python3-package.mk

index a0711a3f6a5a396c188570883edbb960951446bf..abf0a557fe3a6788072ce5de5e0d039db99e3cd7 100644 (file)
@@ -289,6 +289,7 @@ $(eval $(call HostBuild))
 $(foreach package, $(PYTHON3_PACKAGES),  \
        $(eval $(call Py3Package,$(package))) \
        $(eval $(call BuildPackage,$(package))) \
+       $(eval $(call BuildPackage,$(package)-src)) \
 )
 
 $(eval $(call Py3Package,python3-base))
@@ -298,3 +299,7 @@ $(eval $(call Py3Package,python3))
 $(eval $(call BuildPackage,python3-base))
 $(eval $(call BuildPackage,python3-light))
 $(eval $(call BuildPackage,python3))
+
+$(eval $(call BuildPackage,python3-base-src))
+$(eval $(call BuildPackage,python3-light-src))
+$(eval $(call BuildPackage,python3-src))
index c3de0cc950ce912d7dbd15a431cffcd9562e7a56..cc100518924c1dd8848ea1ed02592bad6a0c3d68 100644 (file)
@@ -34,5 +34,36 @@ process_filespec() {
        )
 }
 
-process_filespec "$1" "$2" "$3"
+src_dir="$1"
+dst_dir="$2"
+python="$3"
+mode="$4"
+filespec="$5"
 
+process_filespec "$src_dir" "$dst_dir" "$filespec" || {
+       echo "process filespec error-ed"
+       exit 1
+}
+
+if [ "$mode" == "sources" ] ; then
+       # Copy only python source files
+       find $dst_dir -not -name "*\.py" | xargs rm -f
+       # Delete empty folders (if the case)
+       find $dst_dir/usr -type d | xargs rmdir &> /dev/null
+       rmdir $dst_dir/usr &> /dev/null
+       exit 0
+fi
+
+# XXX [So that you won't goof as I did]
+# Note: Yes, I tried to use the -O & -OO flags here.
+#       However the generated byte-codes were not portable.
+#       So, we just stuck to un-optimized byte-codes,
+#       which is still way better/faster than running
+#       Python sources all the time.
+$python -m compileall -b -d '/' $dst_dir || {
+       echo "python -m compileall err-ed"
+       exit 1
+}
+# Delete source files and pyc [ un-optimized bytecode files ]
+# We may want to make this optimization thing configurable later, but not sure atm
+find $dst_dir -name "*\.py" | xargs rm -f
index 1ed8b2c18afa7a853b7df1740d384afc89077b7e..a28689aba689b4c74c621c33fc38d48071d94078 100644 (file)
@@ -34,6 +34,17 @@ endif
 
 define Py3Package
 
+  define Package/$(1)-src
+    $(call Package/$(1))
+    TITLE+= (sources)
+    DEPENDS:=$$$$(foreach dep,$$$$(filter +python3-%,$$$$(DEPENDS)),$$$$(dep)-src)
+  endef
+
+  define Package/$(1)-src/description
+    $(call Package/$(1)/description).
+    (Contains the Python3 sources for this package).
+  endef
+
   # Add default PyPackage filespec none defined
   ifndef Py3Package/$(1)/filespec
     define Py3Package/$(1)/filespec
@@ -58,16 +69,22 @@ define Py3Package
        if [ -e files/python3-package-install.sh ] ; then \
                $(SHELL) files/python3-package-install.sh \
                        "$(PKG_INSTALL_DIR)" "$$(1)" \
+                       "$(HOST_PYTHON3_BIN)" "$$(2)" \
                        "$$$$$$$$$$(call shvar,Py3Package/$(1)/filespec)" ; \
        elif [ -e $(STAGING_DIR)/mk/python3-package-install.sh ] ; then \
                $(SHELL) $(STAGING_DIR)/mk/python3-package-install.sh \
                        "$(PKG_INSTALL_DIR)" "$$(1)" \
+                       "$(HOST_PYTHON3_BIN)" "$$(2)" \
                        "$$$$$$$$$$(call shvar,Py3Package/$(1)/filespec)" ; \
        else \
                echo "No 'python3-package-install.sh' script found" ; \
                exit 1 ; \
        fi
   endef
+
+  define Package/$(1)-src/install
+       $$(call Package/$(1)/install,$$(1),sources)
+  endef
 endef
 
 $(call include_mk, python3-host.mk)