mirror of
https://git.mirrors.martin98.com/https://github.com/petaflot/pygcode
synced 2025-08-14 09:25:54 +08:00
deployment more mature
This commit is contained in:
parent
5be385e267
commit
1d288e9403
212
deployment/deploy.sh
Executable file
212
deployment/deploy.sh
Executable file
@ -0,0 +1,212 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
source $(which virtualenvwrapper.sh)
|
||||||
|
|
||||||
|
function pyver() {
|
||||||
|
# write python version to stdout
|
||||||
|
$1 -c 'import sys; print("{}.{}.{}".format(*sys.version_info))'
|
||||||
|
}
|
||||||
|
|
||||||
|
function lib_ver() {
|
||||||
|
# Get library vesion number
|
||||||
|
pushd ../src > /dev/null
|
||||||
|
python -c 'import pygcode; print(pygcode.__version__)'
|
||||||
|
popd > /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
# ============ Local Parameters
|
||||||
|
LIB_NAME=pygcode
|
||||||
|
LIB_VER=$(lib_ver)
|
||||||
|
|
||||||
|
# ============ Help Text
|
||||||
|
function show_help() {
|
||||||
|
[ "$@" ] && echo "$@"
|
||||||
|
cat << EOF
|
||||||
|
Usage: ./${0##*/} {build|test|and so on ...}
|
||||||
|
|
||||||
|
This script is to maintain a consistent method of deployment and testing.
|
||||||
|
|
||||||
|
Deployment target: ${LIB_NAME} ${LIB_VER}
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
Setup:
|
||||||
|
setup: Installs packages & sets up environment (requires sudo)
|
||||||
|
|
||||||
|
Compiling:
|
||||||
|
build: Execute setup to build packages (populates ../dist/)
|
||||||
|
creates both 'sdist' and 'wheel' distrobutions.
|
||||||
|
|
||||||
|
Virtual Environments:
|
||||||
|
rmenv py# Remove virtual environment
|
||||||
|
remkenv py# Remove, then create re-create virtual environment
|
||||||
|
|
||||||
|
Deploy:
|
||||||
|
deploy test Upload to PyPi test server
|
||||||
|
deploy prod Upload to PyPi (official)
|
||||||
|
|
||||||
|
Install:
|
||||||
|
install sdist py# Install from local sdist
|
||||||
|
install wheel py# Install from local wheel
|
||||||
|
install pypitest py# Install from PyPi test server
|
||||||
|
install pypi py# Install from PyPi (official)
|
||||||
|
|
||||||
|
Testing:
|
||||||
|
test dev py# Run tests on local dev in a virtual env
|
||||||
|
test installed py# Run tests on installed library in virtual env
|
||||||
|
|
||||||
|
Help:
|
||||||
|
-h | --help display this help message
|
||||||
|
|
||||||
|
py#: when referenced above means
|
||||||
|
'py2' for Python $(pyver python2)
|
||||||
|
'py3' for Python $(pyver python3)
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
# ============ Commands
|
||||||
|
function setup() {
|
||||||
|
# Install pre-requisite tooling
|
||||||
|
sudo pip install -U "pip>=1.4" "setuptools>=0.9" "wheel>=0.21" twine
|
||||||
|
}
|
||||||
|
|
||||||
|
function build() {
|
||||||
|
# Run setup.py to build sdist and wheel distrobutions
|
||||||
|
pushd ..
|
||||||
|
rm -rf build/
|
||||||
|
python setup.py sdist bdist_wheel
|
||||||
|
popd
|
||||||
|
}
|
||||||
|
|
||||||
|
function rmenv() {
|
||||||
|
# Remove virtual environment
|
||||||
|
set_venv_variables $1
|
||||||
|
rmvirtualenv ${env_name}
|
||||||
|
}
|
||||||
|
|
||||||
|
function remkenv() {
|
||||||
|
# Remove virtual environment, then re-create it from scratch
|
||||||
|
set_venv_variables $1
|
||||||
|
rmvirtualenv ${env_name}
|
||||||
|
mkvirtualenv --python=${python_bin} ${env_name}
|
||||||
|
}
|
||||||
|
|
||||||
|
function deploy() {
|
||||||
|
# Deploy compiled distributions to the test|prod server
|
||||||
|
_deployment_env=$1
|
||||||
|
pushd ..
|
||||||
|
twine upload -r ${_deployment_env} dist/${LIB_NAME}-${LIB_VER}*
|
||||||
|
popd
|
||||||
|
}
|
||||||
|
|
||||||
|
function install() {
|
||||||
|
# Install library from a variety of sources
|
||||||
|
_install_type=$1
|
||||||
|
_env_key=$2
|
||||||
|
|
||||||
|
set_venv_variables ${_env_key}
|
||||||
|
workon ${env_name}
|
||||||
|
|
||||||
|
case "${_install_type}" in
|
||||||
|
sdist)
|
||||||
|
# Install from locally compiled 'sdist' file
|
||||||
|
${env_pip_bin} install ../dist/${LIB_NAME}-${LIB_VER}.tar.gz
|
||||||
|
;;
|
||||||
|
wheel)
|
||||||
|
# Install from locally compiled 'wheel' file
|
||||||
|
${env_pip_bin} install ../dist/${LIB_NAME}-${LIB_VER}-py2.py3-none-any.whl
|
||||||
|
;;
|
||||||
|
pypitest)
|
||||||
|
# Install from PyPi test server
|
||||||
|
${env_pip_bin} install -i https://testpypi.python.org/pypi ${LIB_NAME}
|
||||||
|
;;
|
||||||
|
pypi)
|
||||||
|
# Install from official PyPi server
|
||||||
|
${env_pip_bin} install ${LIB_NAME}
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo invalid install type: \"${_install_type}\" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
deactivate
|
||||||
|
}
|
||||||
|
|
||||||
|
function test() {
|
||||||
|
# Run tests
|
||||||
|
|
||||||
|
_test_scope=$1
|
||||||
|
_env_key=$2
|
||||||
|
|
||||||
|
set_venv_variables ${_env_key}
|
||||||
|
|
||||||
|
case "${_test_scope}" in
|
||||||
|
dev)
|
||||||
|
export PYGCODE_TESTSCOPE=local
|
||||||
|
;;
|
||||||
|
installed)
|
||||||
|
export PYGCODE_TESTSCOPE=installed
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo invalid test scope: \"${_test_scope}\" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
pushd ../tests
|
||||||
|
workon ${env_name}
|
||||||
|
${env_python_bin} -m unittest discover -s . -p 'test_*.py' --verbose
|
||||||
|
deactivate
|
||||||
|
popd
|
||||||
|
}
|
||||||
|
|
||||||
|
# ============ Utilities
|
||||||
|
function set_venv_variables() {
|
||||||
|
# on successful exit, environment variables are set:
|
||||||
|
# env_name = virtual environment's name
|
||||||
|
# env_pip_bin = environment's pip binary
|
||||||
|
# env_python_bin = environment's python binary
|
||||||
|
# python_bin = python binary in host environment
|
||||||
|
_env_key=$1
|
||||||
|
|
||||||
|
env_name=${LIB_NAME}_${_env_key}
|
||||||
|
env_pip_bin=${WORKON_HOME}/${env_name}/bin/pip
|
||||||
|
env_python_bin=${WORKON_HOME}/${env_name}/bin/python
|
||||||
|
case "${_env_key}" in
|
||||||
|
py2)
|
||||||
|
python_bin=$(which python2)
|
||||||
|
;;
|
||||||
|
py3)
|
||||||
|
python_bin=$(which python3)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo invalid environment key: \"${_env_key}\" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# ============ Option parsing
|
||||||
|
case "$1" in
|
||||||
|
# Show help on request
|
||||||
|
-h|--help)
|
||||||
|
show_help
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
|
||||||
|
# Valid Commands
|
||||||
|
setup) setup ;;
|
||||||
|
build) build ;;
|
||||||
|
rmenv) rmenv $2 ;;
|
||||||
|
remkenv) remkenv $2 ;;
|
||||||
|
deploy) deploy $2 ;;
|
||||||
|
install) install $2 $3 ;;
|
||||||
|
test) test $2 $3 ;;
|
||||||
|
|
||||||
|
# otherwise... show help
|
||||||
|
*)
|
||||||
|
show_help >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
echo ./${0##*/} completed successfully
|
@ -1,6 +1,6 @@
|
|||||||
Metadata-Version: 1.1
|
Metadata-Version: 1.1
|
||||||
Name: pygcode
|
Name: pygcode
|
||||||
Version: 0.1.0
|
Version: 0.1.1.dev0
|
||||||
Summary: Basic g-code parser, interpreter, and encoder library.
|
Summary: Basic g-code parser, interpreter, and encoder library.
|
||||||
Home-page: https://github.com/fragmuffin/pygcode
|
Home-page: https://github.com/fragmuffin/pygcode
|
||||||
Author: Peter Boin
|
Author: Peter Boin
|
||||||
@ -18,14 +18,16 @@ Description: =======
|
|||||||
Installation
|
Installation
|
||||||
============
|
============
|
||||||
|
|
||||||
Using `PyPi <https://pypi.python.org/pypi/pydemia>`__:
|
Install using ``pip``
|
||||||
|
|
||||||
``pip install pygcode``
|
``pip install pygcode``
|
||||||
|
|
||||||
|
or `download directly from PyPi <https://pypi.python.org/pypi/pygcode>`__
|
||||||
|
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
=====
|
=====
|
||||||
|
|
||||||
Just brainstorming here...
|
|
||||||
|
|
||||||
Writing GCode
|
Writing GCode
|
||||||
-------------
|
-------------
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
README.rst
|
README.rst
|
||||||
setup.cfg
|
setup.cfg
|
||||||
setup.py
|
setup.py
|
||||||
|
scripts/pygcode-norm
|
||||||
src/pygcode/__init__.py
|
src/pygcode/__init__.py
|
||||||
src/pygcode/block.py
|
src/pygcode/block.py
|
||||||
src/pygcode/comment.py
|
src/pygcode/comment.py
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
|
argparse
|
||||||
euclid3
|
euclid3
|
||||||
six
|
six
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
# 1.x - Development Status :: 5 - Production/Stable
|
# 1.x - Development Status :: 5 - Production/Stable
|
||||||
# <any above>.y - developments on that version (pre-release)
|
# <any above>.y - developments on that version (pre-release)
|
||||||
# <any above>*.dev* - development release (intended purely to test deployment)
|
# <any above>*.dev* - development release (intended purely to test deployment)
|
||||||
__version__ = "0.1.0"
|
__version__ = "0.1.1.dev0"
|
||||||
|
|
||||||
__title__ = "pygcode"
|
__title__ = "pygcode"
|
||||||
__description__ = "Basic g-code parser, interpreter, and encoder library."
|
__description__ = "Basic g-code parser, interpreter, and encoder library."
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
import sys
|
|
||||||
import os
|
|
||||||
import inspect
|
|
||||||
|
|
||||||
import unittest
|
|
||||||
|
|
||||||
# Add relative pygcode to path
|
|
||||||
from testutils import add_pygcode_to_path, str_lines
|
|
||||||
add_pygcode_to_path()
|
|
||||||
|
|
||||||
# Units under test
|
|
||||||
from pygcode.file import GCodeFile, GCodeParser
|
|
||||||
|
|
||||||
class GCodeParserTest(unittest.TestCase):
|
|
||||||
FILENAME = 'test-files/vertical-slot.ngc'
|
|
||||||
|
|
||||||
def test_parser(self):
|
|
||||||
parser = GCodeParser(self.FILENAME)
|
|
||||||
# count lines
|
|
||||||
line_count = 0
|
|
||||||
for line in parser.iterlines():
|
|
||||||
line_count += 1
|
|
||||||
self.assertEqual(line_count, 26)
|
|
||||||
parser.close()
|
|
@ -5,14 +5,20 @@ import inspect
|
|||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
# Units Under Test
|
# Units Under Test
|
||||||
_pygcode_in_path = False
|
_pygcode_in_path = False
|
||||||
def add_pygcode_to_path():
|
def add_pygcode_to_path():
|
||||||
global _pygcode_in_path
|
global _pygcode_in_path
|
||||||
if not _pygcode_in_path:
|
if not _pygcode_in_path:
|
||||||
# Add pygcode (relative to this test-path) to the system path
|
if os.environ.get('PYGCODE_TESTSCOPE', 'local') == 'installed':
|
||||||
_this_path = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
# Run tests on the `pip install` installed libray
|
||||||
sys.path.insert(0, os.path.join(_this_path, '..'))
|
pass # nothing to be done
|
||||||
|
else:
|
||||||
|
# Run tests explicitly on files in ../src (ignore any installed libs)
|
||||||
|
# Add pygcode (relative to this test-path) to the system path
|
||||||
|
_this_path = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
||||||
|
sys.path.insert(0, os.path.join(_this_path, '..', 'src'))
|
||||||
|
|
||||||
_pygcode_in_path = True
|
_pygcode_in_path = True
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user