wip: add setup.py, README.md and debian packaging
authorClaudio Luck <claudio.luck@pep.foundation>
Tue, 04 Sep 2018 17:09:43 +0200
changeset 56 d48cf08cf448
parent 55 e76930ea6464
child 57 2f4ad3800a3f
wip: add setup.py, README.md and debian packaging
Makefile
README.md
debian/changelog
debian/compat
debian/control
debian/rules
debian/source/format
debian/watch
setup.py
--- a/Makefile	Tue Sep 04 17:00:00 2018 +0200
+++ b/Makefile	Tue Sep 04 17:09:43 2018 +0200
@@ -1,5 +1,7 @@
 YML_PATH=
 YML2C=yml2c
+PKGVER=$(shell python setup.py -V)
+DEBVER=1
 
 all: homepage
 
@@ -16,5 +18,18 @@
 %.html: %.en.yhtml2 heading.en.yhtml2 homepage.en.yhtml2
 	$(YML2C) $< -o $@
 
+.PHONY: deb
+deb:  YML2_$(PKGVER).orig.tar.gz python-yml2_$(PKGVER)-$(DEBVER)_all.deb
+
+YML2_$(PKGVER).orig.tar.gz:
+	python setup.py sdist
+	mv -f dist/YML2-$(PKGVER).tar.gz YML2_$(PKGVER).orig.tar.gz
+
+python-yml2_$(PKGVER)-$(DEBVER)_all.deb:
+	python setup.py --command-packages=stdeb.command bdist_deb
+	mv -f deb_dist/python-yml2_$(PKGVER)-$(DEBVER)_all.deb .
+
 clean:
 	rm -f *.html *.pyc *.pyo
+	rm -f YML2_$(PKGVER).orig.tar.gz
+	rm -f python-yml2_$(PKGVER)-$(DEBVER)_all.deb
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.md	Tue Sep 04 17:09:43 2018 +0200
@@ -0,0 +1,144 @@
+## What is YML?
+
+Well, it's the idea not to need to define a grammar first when you want to use a Domain Specific Language. For that purpose, YML is being translated into XML. Let's make an example.
+
+Everything which comes close to a C like language, parses without a grammar definition:
+
+This:
+
+    template< class T > T max(T a, T b);
+
+Parses to:
+
+    <?xml version='1.0' encoding='UTF-8'?>
+    <template>
+      <generic>
+        <class/>
+        <T/>
+      </generic>
+      <T>
+        <max>
+          <parm>
+            <T/>
+            <a/>
+          </parm>
+          <parm>
+            <T/>
+            <b/>
+          </parm>
+        </max>
+      </T>
+    </template>
+
+Instead of defining grammars, you test out and play around until the results are matching your needs. If the resulting tree does not fit what you're expecting, change it by patching the grammar with `decl`:
+
+This:
+
+    module A {
+        interface B {
+            attribute long n;
+        };
+    };
+
+Parses to:
+
+    <?xml version='1.0' encoding='UTF-8'?>
+    <module>
+      <A>
+        <interface>
+          <B>
+            <attribute>
+              <long>
+                <n/>
+              </long>
+            </attribute>
+          </B>
+        </interface>
+      </A>
+    </module>
+
+This does not look like what we want. So we tell YML that we have a module name after the module, an interface name after the interface and type and name after the attribute:
+
+This:
+
+    decl module @name;
+    decl interface @name;
+    decl attribute @type @name;
+
+    module A {
+        interface B {
+            attribute long n;
+        };
+    };
+
+Parses to:
+
+    <?xml version='1.0' encoding='UTF-8'?>
+    <module name="A">
+      <interface name="B">
+        <attribute type="long" name="n"/>
+      </interface>
+    </module>
+
+What can I do with YML?
+
+With YML you can:
+
+  * use a C-like DSL without writing a grammar first
+  * generate code out of this DSL using YSLT
+  * generate code out of UML using YSLT on XMI
+  * generate code out of any XML based language like SVG using YSLT
+  * define a wiki like language in just a few lines like YHTML does
+  * replace bad designed and complicated XML languages with simpler C-like ones
+  * ... and much more.
+
+How it works: Replacing angle brackets with some Python
+
+Just writing down what I wanted to have instead of XML for a sample:
+
+    <list name="List of goods">
+        <head>
+            <columTitle>
+                Goods
+            </columnTitle>
+            <columnTitle>
+                Price
+            </columnTitle>
+        </head>
+        <row>
+            <value>
+                Beer
+            </value>
+            <value>
+                20
+            </value>
+        </row>
+        <row>
+            <value>
+                Wine
+            </value>
+            <value>
+                30
+            </value>
+        </row>
+    </list>
+
+Something like that should be more easy, say, like this:
+
+    list "List of goods" {
+        head title "Goods", title "Price";
+        row value "Beer", value 20;
+        row value "Wine", value 30;
+    }
+
+### Y Languages
+
+The latter is what I call an Y language – a language specified in YML. How could this be achieved? Well, what's to do? To have the required information, how to build XML from the script above, we need:
+
+  * the information, that “list of goods” is an attribute named `name`, while `Goods` is the text value of a tag
+  * `title` shout be written out as `columnTitle`
+
+How to do that? Let's invent a simple definition language for that information:
+
+    decl list(name);
+    decl title alias columnTitle;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/changelog	Tue Sep 04 17:09:43 2018 +0200
@@ -0,0 +1,5 @@
+yml2 (5.8-1) unstable; urgency=low
+
+  * source package automatically created by stdeb 0.8.5
+
+ -- Volker Birk <vb@pep.foundation>  Tue, 04 Sep 2018 17:29:10 +0200
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/compat	Tue Sep 04 17:09:43 2018 +0200
@@ -0,0 +1,1 @@
+9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/control	Tue Sep 04 17:09:43 2018 +0200
@@ -0,0 +1,18 @@
+Source: yml2
+Maintainer: Volker Birk <vb@pep.foundation>
+Section: python
+Priority: optional
+Build-Depends: dh-python, python-setuptools (>= 0.6b3), python-all (>= 2.6.6-3), debhelper (>= 9)
+Standards-Version: 3.9.6
+Homepage: https://pep.foundation/dev/repos/yml2
+
+Package: python-yml2
+Architecture: all
+Depends: ${misc:Depends}, ${python:Depends}
+Description: YML 2 compiler
+ .
+ YML2 caters the idea not to need to define a grammar first when you want to
+ use a Domain Specific Language. For that purpose, YML is being translated into
+ XML. Let's make an example.
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/rules	Tue Sep 04 17:09:43 2018 +0200
@@ -0,0 +1,8 @@
+#!/usr/bin/make -f
+
+# This file was automatically generated by stdeb 0.8.5 at
+# Tue, 04 Sep 2018 17:29:10 +0200
+export PYBUILD_NAME=yml2
+%:
+	dh $@ --with python2 --buildsystem=pybuild
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/source/format	Tue Sep 04 17:09:43 2018 +0200
@@ -0,0 +1,1 @@
+3.0 (quilt)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/watch	Tue Sep 04 17:09:43 2018 +0200
@@ -0,0 +1,4 @@
+# please also check http://pypi.debian.net/YML2/watch
+version=3
+opts=uversionmangle=s/(rc|a|b|c)/~$1/ \
+http://pypi.debian.net/YML2/YML2-(.+)\.(?:zip|tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz)))
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/setup.py	Tue Sep 04 17:09:43 2018 +0200
@@ -0,0 +1,36 @@
+# -*- coding: utf-8 -*-
+
+import sys
+from setuptools import setup
+
+sys.path.insert(0, '.')
+from yml2 import yml2c
+caption = yml2c.__doc__.split('\n')[0]
+short_desc, version = map(lambda s: s.strip(), caption.split('version', 1))
+
+with open('README.md', 'r') as fh:
+    long_desc = fh.read().strip()
+
+setup(
+        name='YML2',
+        version=version,
+        description=short_desc,
+        long_description=long_desc,
+        author="Volker Birk",
+        author_email="vb@pep.foundation",
+        url="https://pep.foundation/dev/repos/yml2",
+        zip_safe=False,
+        packages=["yml2"],
+        install_requires=['lxml'],
+        package_data = {
+            '': ['gpl-2.0.txt', '*.css', '*.yhtml2'],
+            'yml2': ['*.yml2', '*.ysl2'],
+        },
+        entry_points = {
+            'console_scripts': [
+                'yml2c=yml2.yml2c:main',
+                'yml2proc=yml2.yml2proc:main'
+            ],
+        }
+    )
+