Commit dcb80622 authored by Thomas Nadovich's avatar Thomas Nadovich 🌸
Browse files

Merge branch 'feature/unspecifiy-versions' into 'devel'

Feature/unspecifiy versions

Closes #6 and #4

See merge request !3
parents b7870075 d1cbb2cd
Pipeline #16898 passed with stages
in 2 minutes and 41 seconds
......@@ -13,6 +13,7 @@ build/
develop-eggs/
dist/
downloads/
packaging/
eggs/
.eggs/
lib/
......@@ -23,6 +24,14 @@ var/
*.egg-info/
.installed.cfg
*.egg
.idea/
# Auto-generated requirements.txt file
requirements.txt
#pipenv stuff
pipenv
pyproject.toml
# PyInstaller
# Usually these files are written by a python script from a template
......@@ -103,12 +112,16 @@ ENV/
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
# debian build artifacts
scripts/debian/control
scripts/debian/changelog
scripts/debian/*.install
.vscode
*.csv
*.eds
bin/
# vim swap files
*.swp
*.swo
# This file is a template, and might need editing before it works on your project.
# Official language image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/python/tags/
image: "python:3.4"
image: burt/pyinstaller
stages:
- build
- release-job
build:
stage: build
script:
- pip3 install python-dateutil==2.7.3 && pip3 install MarkupSafe
- ./setup.py install
- pipenv install --dev
- pipenv run objdict-generate
#test:
# script:
# - ./setup.py test
release-job:
stage: release-job
script:
- pipenv install --dev
- pipenv run make package
artifacts:
paths:
- packaging/*.deb
name: "${CI_PROJECT_NAME}-${CI_BUILD_TAG}-deb"
only:
- tags
## [dev-1.0.6]
- set up repo to build an executable binary like burt-util
- un-specified package versions
- command is now objdict-generate, not objdict_generate
## [dev-1.0.5]
### Changed
......
SHELL := /bin/bash
WORKSPACE_DIR=$(shell git rev-parse --show-toplevel)
VERSION=$(shell cat objdict_generate/version.py | grep --color=never -oh '[0-9]\+\.[0-9]\+\.[0-9]\+')
BUILD_DIR=${WORKSPACE_DIR}/build
DIST_DIR=${WORKSPACE_DIR}/dist
PACKAGING_DIR=${WORKSPACE_DIR}/packaging
DEBIAN_DIR=${WORKSPACE_DIR}/scripts/debian
NAME=$(shell basename -s .git `git config --get remote.origin.url`)
USERNAME=$(shell git config user.name)
EMAIL=$(shell git config user.email)
OUTDIR=$(PACKAGING_DIR)/$(NAME)-$(VERSION)
DEBIAN_GENERATED_FILES=$(DEBIAN_DIR)/$(NAME).install $(DEBIAN_DIR)/control
RELEASE_TYPE=dev
DEB=$(PACKAGING_DIR)/$(NAME)_$(VERSION)_amd64.deb
PROGRAM_OUTDIR= bin/Debug/
ENTRYPOINT=objdict_generate/scripts/objdict_generate.py
EXE = $(DIST_DIR)/$(NAME)
all: build
.PHONY: build
build: $(EXE)
$(EXE): $(ENTRYPOINT)
pyinstaller $< --onefile -n $(NAME)
.PHONY: package
package: $(DEB)
$(DEB): build $(DEBIAN_GENERATED_FILES)
rm -f $(DEBIAN_DIR)/changelog
export DEBEMAIL=$(EMAIL)
export DEBFULLNAME=$(USERNAME)
mkdir -p $(OUTDIR)/bin/usr/bin
cp $(DIST_DIR)/$(NAME) $(OUTDIR)/bin/usr/bin/
cd $(DEBIAN_DIR)/.. && dch --create --package "$(NAME)" -v $(VERSION) -D UNRELEASED "Latest update"
cp -r $(DEBIAN_DIR) $(OUTDIR)
cd $(OUTDIR) && debuild -us -uc
$(DEBIAN_DIR)/$(NAME).install:
echo "./bin/* ./" > $(DEBIAN_DIR)/$(NAME).install
$(DEBIAN_DIR)/control: $(DEBIAN_DIR)/control.tmpl
NAME=$(NAME) envsubst < $(DEBIAN_DIR)/control.tmpl > $(DEBIAN_DIR)/control
.PHONY: clean
clean:
-rm -rf $(BUILD_DIR) $(PACKAGING_DIR) $(DIST_DIR)
-rm -f $(DEBIAN_DIR)/control
.PHONY: install
install: $(DEB)
sudo dpkg -i $<
.PHONY: uninstall
uninstall:
sudo apt remove $(NAME)
.PHONY: release
release:
git tag -a ${RELEASE_TYPE}-$(VERSION) -m "Release ${RELEASE_TYPE}-${VERSION}"
git push --tags
.PHONY: setup
setup: ~/.pyenv
sudo apt-get update
sudo apt-get install -y \
python3-dev \
python3-pip \
devscripts \
debhelper \
git \
make \
build-essential \
libssl-dev \
zlib1g-dev \
libbz2-dev \
libreadline-dev \
libsqlite3-dev \
wget \
curl \
llvm \
libncurses5-dev \
libncursesw5-dev \
xz-utils \
tk-dev \
libffi-dev \
liblzma-dev \
python-openssl
# pipenv is the only python package that we need to install globably, all the
# other package get installed inside our virtual enviroment
sudo pip3 install importlib-resources==1.0 zipp==1.0
sudo pip3 install pipenv
# we need to manually build python3.9 with the --enable-shared flag
# because otherwise pyinstaller won't be able to find the shared
# python libraries from within pipenv
# https://stackoverflow.com/questions/58548730/how-to-use-pyinstaller-with-pipenv-pyenv
env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.9.5
# lastly, we actually set up the pipenv enviroment
pipenv install --dev -v
requirements.txt:
pipenv lock -r > requirements.txt
~/.pyenv:
# The following pyenv installation is coppied from
# https://gist.github.com/genyrosk/2a6e893ee72fa2737a6df243f6520a6d
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$$PYENV_ROOT/bin:$$PATH"' >> ~/.bashrc
#we need to reload bashrc after making changes.
source ~/.bashrc
[[source]]
verify_ssl = true
url = "https://pypi.org/simple"
name = "pypi"
[dev-packages]
objdict-generate = {path = "."}
nosetests-json-extended = "==0.1.0"
nose = "==1.3.7"
pyinstaller = "==4.0"
[requires]
python_version = "3.9"
[packages]
click = ">=6.6"
click_spinner = "*"
click_didyoumean = "*"
semver = "*"
jinja2 = "*"
canopen = "*"
PyYaml = "*"
configparser = "*"
pykwalify = "*"
arrow = "*"
This diff is collapsed.
......@@ -4,8 +4,8 @@
> information
**Build Status**: [![build status](https://git.barrett.com/burt/tools/objdict-generate/badges/devel/build.svg)](https://git.barrett.com/burt/tools/objdict-generate/commits/devel)
**Coverage Report**: [![coverage report](https://git.barrett.com/burt/software/burt-util/badges/devel/coverage.svg)](https://git.barrett.com/burt/tools/objdict-generate/commits/devel)
**Build Status**: [![build status](https://git.barrett.com/burt/tools/objdict-generate/badges/devel/pipeline.svg)](https://git.barrett.com/burt/tools/objdict-generate/-/commits/devel)
**Coverage Report**: [![coverage report](https://git.barrett.com/burt/tools/objdict-generate/badges/devel/coverage.svg)](https://git.barrett.com/burt/tools/objdict-generate/-/commits/devel)
*Requires*: Python 3.4+
......@@ -13,40 +13,96 @@
### Quick Start
The following commands are all you need:
To install objdict-generate, go to the latest tag in GitLab, download the .deb
installer (inside "release-job" and install with the following command:
```shell-session
$ sudo apt-get install -y python3 python3-pip
$ sudo pip3 install git+https://git.barrett.com/burt/tools/objdict-generate.git
$ sudo dpkg -i objdict-generate*.deb
```
### Development Setup
This project is set up to be developed in a pipenv virtual environment using
python 3.9.5 Since this may be too recent of a version for older development
systems, we use
pyenv to provide it to pipenv. The application can be run locally from the
virtual environment, or 'frozen' into a single-file application using
pyinstaller. This one-file application can then be installed on other systems
by building a .deb installer file using make.
The build server builds the .deb slightly differently. The environment in which
make is run is not a pipenv virtual environment, but rather a docker container
defined in the burt-ci-docker-image project. This docker container is set up so
that its internal global python setup is the same as the one defined by the
pipenv Pipfile. It is not defined by the Pipfile though, and if the Pipfile is
changed, the docker image should be updated as well to keep local & server
builds roughly compatible.
Development can be done in one of two ways
#### Recomended: Pipenv
ipenv is a tool for setting up your python development environment.
First download the repository:
```shell-session
$ git clone https://git.barrett.com/burt/tools/objdict-generate.git && cd objdict-generate
```
To install the dependencies
```shell-session
$ sudo apt-get install -y python3 python3-pip
make setup
```
Now we can run the program in this repo without installing on one of two ways
```shell-session
$ pipenv run objdict-generate
```
or
```
$ pipenv shell
(pipenv) $ objdict-generate
```
All python requirements are managed by the setup.py file and the application can
be installed by running:
You may be prompted to install python3.9 if you do not already have it
installed. Indicate yes when asked.
This allows for faster development because you don't need to do a system wide
install every time you make a change.
#### Advanced: Install after changes
First download the repository:
```shell-session
$ sudo ./setup.py install
$ git clone https://git.barrett.com/burt/tools/objdict-generate.git && cd objdict-generate
```
To verified it is installed properly you can now run the unit tests:
To install the system dependencies
```shell-session
$ sudo ./setup.py test
$ make setup
```
_Note_: Currently _virtualenv_ usage is broken.
The project should be built inside the pipenv virtual environment to ensure
that it is built with the dependencies specified in the Pipfile. To do so run:
```shell-session
$ pipenv install --dev
$ pipenv run make install
```
You may be prompted to install python3.9 if you do not already have it
installed. Indicate yes when asked.
This sets up the virtual environment as a development environment, builds the
package inside the virtual environment, and then installs the built debian
on the system. This method is preferable for testing, as it installs burt-util
at the system level.
## Dependencies
......@@ -60,7 +116,7 @@ _Note_: Currently _virtualenv_ usage is broken.
Reading an object dictionary yaml file and outputting sources:
```bash
$ objdict_generate project/uss-enterprise/uss_enterprise_od.yaml -o project/uss-enterprise/src -d docs -m projects/mainboard/src
$ objdict-generate project/uss-enterprise/uss_enterprise_od.yaml -o project/uss-enterprise/src -d docs -m projects/mainboard/src
```
The above command will read in the yaml file `project/uss-enterprise/uss_enterprise_od.yaml` and in the output directory (`projects/uss-enterprise/sources`) create two files:
......@@ -83,7 +139,7 @@ dictionary should be placed:
Get usage instructions and help:
```bash
$ objdict_generate --help
$ objdict-generate --help
```
## Example yaml file
......
from .version import __version__
from . import util
from . import datatypes
from . import scripts
......@@ -11,6 +11,7 @@ from objdict_generate.util import *
from objdict_generate.datatypes import *
from objdict_generate.resources import get_resource, get_resource_string
from objdict_generate.version import __version__
from pykwalify.core import Core
from collections import OrderedDict
import yaml
......@@ -79,9 +80,11 @@ def generate_eds_section(objdict):
@click.command()
@click.pass_context
@click.version_option(__version__)
@click.option('--doc_dir', '-d', default=".", type=click.Path(exists=True), help="Output directory to put, .eds and .md files")
@click.option('--output_dir', '-o', default=".", type=click.Path(exists=True), help="Output directory to put, .h and .cpp files")
@click.option('--master_dir', '-m', default=None, type=click.Path(exists=True), help="Output directory to put, .h and .cpp files for the master generated files. Defaults to output dir")
@click.option('--master_dir', '-m', default=None, type=click.Path(exists=True), help="Output directory to put, .h and .cpp files for the master generated files. Defaults to output dir")
@click.argument('yaml_files', type=click.Path(exists=True), nargs=-1)
def cli(ctx, doc_dir, output_dir, master_dir, yaml_files):
"""
......
#!/usr/bin/env python3
__version__ = "1.0.5"
__version__ = "1.0.6"
Source: ${NAME}
Section: unknown
Priority: optional
Maintainer: Thomas Nadovich <tn@barrett.com>
Build-Depends: debhelper (>= 8.0.0)
Standards-Version: 3.9.4
Homepage: <insert the upstream URL, if relevant>
Package: ${NAME}
Architecture: amd64
Recommends: gdb-multiarch
Description: ${NAME}
#!/bin/sh
# add symlink from burt-util to bu so both work just like the setup.py does it
ln -sfn /usr/bin/objdict-generate /usr/bin/odg
echo "Completed post install"
#!/bin/sh
rm -f /usr/bin/odg
echo "Completed post remove"
#!/bin/bash
[[ $(which objdict_generate) != "" ]] && \
[[ $(which objdict_generate) != "/usr/bin/objdict_generate" ]] && \
echo "objdict_generate already installed using setup.py" && \
echo "Uninstalling..." && \
pip3 uninstall objdict_generate
exit 0
#!/usr/bin/make -f
# -*- makefile -*-
# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1
%:
dh $@
......@@ -16,25 +16,25 @@ setup(
},
include_package_data=True,
install_requires=[
'click==6.6',
'click_spinner==0.1.8',
'click_didyoumean==0.0.3',
'semver==2.8.1',
'jinja2==2.10',
'canopen==0.8.0',
'PyYaml==4.2b4',
'configparser==3.5.0',
'pykwalify==1.7.0',
'arrow==0.12.1'
'click',
'click_spinner',
'click_didyoumean',
'semver',
'jinja2',
'canopen<3.0.0',
'PyYaml',
'configparser',
'pykwalify',
'arrow'
],
setup_requires=['pytest-runner==4.2'],
tests_require=['pytest==4.0.1', 'coverage==5.0a4'],
setup_requires=['pytest-runner'],
tests_require=['pytest', 'coverage'],
description='Object Dictionary Generator for Barrett Firmware',
author='Christopher Woodall',
author_email='cw@barrett.com',
zip_safe=False,
entry_points={
"console_scripts": [
"objdict_generate=objdict_generate.scripts.objdict_generate:cli",
"objdict-generate=objdict_generate.scripts.objdict_generate:cli",
]},
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment