From 19b231ee45f21433e500002d0730ab6f65a369e8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl>
Date: Wed, 2 Jun 2021 19:17:00 +0200
Subject: [PATCH] v2.2

---
 .dockerignore          |  1 +
 .travis.yml            | 91 ++++++++++++++++++++++++++++++++++++------
 CHANGELOG.md           |  2 +
 Dockerfile             |  9 +++--
 build-me.sh            | 16 ++++++++
 docs/specification.rst |  3 ++
 minijson.pyx           | 20 +++++-----
 setup.cfg              |  2 +-
 8 files changed, 117 insertions(+), 27 deletions(-)
 create mode 100644 build-me.sh

diff --git a/.dockerignore b/.dockerignore
index 46f8b9a..f1b5f92 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -1 +1,2 @@
 .git
+build-me.sh
diff --git a/.travis.yml b/.travis.yml
index d7c1d7d..fff288f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,4 +1,8 @@
 language: python
+stages:
+  - name: test
+  - name: deploy
+    if: tag is present
 cache: pip
 before_script:
   - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
@@ -13,17 +17,6 @@ after_script:
   - ./cc-test-reporter after-build -t coverage.py --exit-code ${TRAVIS_TEST_RESULT}
 jobs:
   include:
-    - stage: test
-      python: "pypy3.5"
-      before_script:
-        - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
-        - chmod +x ./cc-test-reporter
-        - ./cc-test-reporter before-build
-        - pypy3 -m pip install -r requirements.txt
-        - pypy3 -m pip install pytest coverage pytest-cov
-        - DEBUG=1 pypy3 setup.py install
-      script:
-        - pytest --cov=./ --cov-report=xml
     - stage: test
       python: "3.8"
       script:
@@ -44,6 +37,80 @@ jobs:
       python: "3.9"
       script:
         - pytest --cov=./ --cov-report=xml
-
+    - stage: deploy
+      python: "3.8"
+      before_script:
+        - apt-get update
+        - apt-get install -y patchelf
+        - pip install wheel auditwheel twine doctor-wheel cython
+      script:
+        - python setup.py bdist_wheel
+        - cd dist
+        - doctor-wheel *.whl
+        - auditwheel repair --plat manylinux2014_x86_64 *.whl
+        - cd wheelhouse
+        - twine upload *.whl
+      after_script:
+        - echo "Done"
+    - stage: deploy
+      python: "3.9"
+      before_script:
+        - apt-get update
+        - apt-get install -y patchelf
+        - pip install wheel auditwheel twine doctor-wheel cython
+      script:
+        - python setup.py bdist_wheel
+        - cd dist
+        - doctor-wheel *.whl
+        - auditwheel repair --plat manylinux2014_x86_64 *.whl
+        - cd wheelhouse
+        - twine upload *.whl
+      after_script:
+        - echo "Done"
+    - stage: deploy
+      python: "3.7"
+      before_script:
+        - apt-get update
+        - apt-get install -y patchelf
+        - pip install wheel auditwheel twine doctor-wheel cython
+      script:
+        - python setup.py bdist_wheel
+        - cd dist
+        - doctor-wheel *.whl
+        - auditwheel repair --plat manylinux2014_x86_64 *.whl
+        - cd wheelhouse
+        - twine upload *.whl
+      after_script:
+        - echo "Done"
+    - stage: deploy
+      python: "3.6"
+      before_script:
+        - apt-get update
+        - apt-get install -y patchelf
+        - pip install wheel auditwheel twine doctor-wheel cython
+      script:
+        - python setup.py bdist_wheel
+        - cd dist
+        - doctor-wheel *.whl
+        - auditwheel repair --plat manylinux2014_x86_64 *.whl
+        - cd wheelhouse
+        - twine upload *.whl
+      after_script:
+        - echo "Done"
+    - stage: deploy
+      python: "3.5"
+      before_script:
+        - apt-get update
+        - apt-get install -y patchelf
+        - pip install wheel auditwheel twine doctor-wheel cython
+      script:
+        - python setup.py bdist_wheel
+        - cd dist
+        - doctor-wheel *.whl
+        - auditwheel repair --plat manylinux2014_x86_64 *.whl
+        - cd wheelhouse
+        - twine upload *.whl
+      after_script:
+        - echo "Done"
 
 
diff --git a/CHANGELOG.md b/CHANGELOG.md
index afafa8d..e8325bb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,3 +2,5 @@ Changelog is kept at [GitHub](https://github.com/Dronehub/minijson/releases),
 here's only the changelog for the version in development
 
 # v2.2
+
+* added support for PyPy and Python 3.5
diff --git a/Dockerfile b/Dockerfile
index 437d34a..3b29805 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,13 +1,14 @@
-FROM smokserwis/build:python3
-
-RUN pip install Cython pytest coverage pytest-cov
+FROM pypy:3.5
+RUN apt-get update && \
+    apt-get install -y patchelf
+RUN pypy3 -m pip install Cython pytest coverage pytest-cov auditwheel doctor-wheel twine
 
 ENV DEBUG=1
 
 WORKDIR /tmp/compile
 ADD . /tmp/compile/
 
-RUN python setup.py install && \
+RUN pypy3 setup.py install && \
     chmod ugo+x /tmp/compile/tests/test.sh
 
 CMD ["/tmp/compile/tests/test.sh"]
diff --git a/build-me.sh b/build-me.sh
new file mode 100644
index 0000000..8e2975f
--- /dev/null
+++ b/build-me.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+# Env to set:
+#   * PYPI_USER
+#   * PYPI_PWD
+
+apt-get update
+apt-get install -y patchelf
+pip install auditwheel doctor-wheel twine cython
+git clone https://github.com/Dronehub/minijson.git
+cd minijson
+python setup.py bdist_wheel
+cd dist
+doctor-wheel "*.whl"
+auditwheel repair --plat "manylinux2014_$(uname -m)" "*.whl"
+twine upload "wheelhouse/*.whl"
diff --git a/docs/specification.rst b/docs/specification.rst
index bde7dc7..cdcc72d 100644
--- a/docs/specification.rst
+++ b/docs/specification.rst
@@ -65,3 +65,6 @@ Type Value consists of:
 * If value is 23, then it's False
 * If value is 24, then next what comes is count of bytes, and then bytes follow. This is to be
     interpreted as a signed integer
+
+Coder **should** encode the value as one having the smallest binary representation, but that is not
+required. Decoder **must** parse any arbitrary valid string.
diff --git a/minijson.pyx b/minijson.pyx
index 8eedfe8..1a9428e 100644
--- a/minijson.pyx
+++ b/minijson.pyx
@@ -19,16 +19,16 @@ class DecodingError(MiniJSONError):
     """Error during decoding"""
 
 
-STRUCT_f = struct.Struct('>f')
-STRUCT_d = struct.Struct('>d')
-STRUCT_b = struct.Struct('>b')
-STRUCT_h = struct.Struct('>h')
-STRUCT_H = struct.Struct('>H')
-STRUCT_l = struct.Struct('>l')
-STRUCT_L = struct.Struct('>L')
-
-cdef int float_encoding_mode = 0     # 0 for default FLOAT
-                                     # 1 for default DOUBLE
+cdef:
+    object STRUCT_f = struct.Struct('>f')
+    object STRUCT_d = struct.Struct('>d')
+    object STRUCT_b = struct.Struct('>b')
+    object STRUCT_h = struct.Struct('>h')
+    object STRUCT_H = struct.Struct('>H')
+    object STRUCT_l = struct.Struct('>l')
+    object STRUCT_L = struct.Struct('>L')
+    int float_encoding_mode = 0     # 0 for default FLOAT
+                                    # 1 for default DOUBLE
 
 cpdef void switch_default_float():
     """
diff --git a/setup.cfg b/setup.cfg
index 82ceddd..b8d72bf 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,6 +1,6 @@
 # coding: utf-8
 [metadata]
-version = 2.2a1
+version = 2.2
 name = minijson
 long-description = file: README.md
 long-description-content-type = text/markdown; charset=UTF-8
-- 
GitLab