Skip to content

Commit

Permalink
Resolve #71, Changed dev_requirements to requirements
Browse files Browse the repository at this point in the history
* Remove dev_requirements
* Changed Dockerfiles
* Remove old comments from setup.py
* Adjust upload.sh for alphanumeric semver
  • Loading branch information
ajwalkiewicz committed Jan 24, 2023
1 parent 5917ef7 commit 44814f2
Show file tree
Hide file tree
Showing 10 changed files with 339 additions and 36 deletions.
7 changes: 2 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

# apline 3.17 and python 3.8
# copied from https://github.com/docker-library/python/blob/f5b7b5a332bd4d2c1518325ab9647b09bf07412f/3.8/alpine3.17/Dockerfile

FROM ubuntu:20.04

# set the working directory
Expand All @@ -27,9 +24,9 @@ RUN apt-get upgrade --yes
RUN apt-get install python3.8 python3-pip --yes

# install dependencies
COPY ./dev_requirements.txt .
COPY ./requirements.txt .

RUN pip install --no-cache-dir --upgrade -r dev_requirements.txt
RUN pip install --no-cache-dir --upgrade -r requirements.txt

# copy the scripts to the folder
COPY . /cochar
Expand Down
6 changes: 0 additions & 6 deletions dev_requirements.txt

This file was deleted.

72 changes: 72 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,73 @@
alabaster==0.7.13
aniso8601==9.0.1
attrs==22.2.0
Babel==2.11.0
black==22.12.0
bleach==6.0.0
certifi==2022.12.7
cffi==1.15.1
charset-normalizer==3.0.1
click==8.1.3
commonmark==0.9.1
cryptography==39.0.0
deepdiff==6.2.3
Deprecated==1.2.13
docutils==0.19
exceptiongroup==1.1.0
Flask==2.2.2
Flask-Limiter==3.1.0
Flask-RESTful==0.3.9
idna==3.4
imagesize==1.4.1
importlib-metadata==6.0.0
importlib-resources==5.10.2
iniconfig==2.0.0
itsdangerous==2.1.2
jaraco.classes==3.2.3
jeepney==0.8.0
Jinja2==3.1.2
jsonschema==4.17.3
keyring==23.13.1
limits==3.2.0
Markdown==3.4.1
MarkupSafe==2.1.2
more-itertools==9.0.0
mypy-extensions==0.4.3
ordered-set==4.1.0
orjson==3.8.5
packaging==23.0
pathspec==0.10.3
pkginfo==1.9.6
pkgutil-resolve-name==1.3.10
platformdirs==2.6.2
pluggy==1.0.0
pycparser==2.21
Pygments==2.14.0
pyrsistent==0.19.3
pytest==7.2.1
pytz==2022.7.1
readme-renderer==37.3
requests==2.28.2
requests-toolbelt==0.10.1
rfc3986==2.0.0
rich==12.6.0
rname==0.3.7
SecretStorage==3.3.3
six==1.16.0
snowballstemmer==2.2.0
sphinx==6.1.3
sphinxcontrib-applehelp==1.0.4
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
tomli==2.0.1
twine==4.0.2
typing-extensions==4.4.0
urllib3==1.26.14
uWSGI==2.0.21
webencodings==0.5.1
Werkzeug==2.2.2
wrapt==1.14.1
zipp==3.11.0
5 changes: 0 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
description="Call of Cthulhu character generator",
long_description=long_description,
long_description_content_type="text/markdown",
# long_description_content_type="text/x-rst",
url="https://github.com/ajwalkiewicz/cochar",
project_urls={
"Documentation": "https://ajwalkiewicz.github.io/cochar/_build/html/index.html"
Expand All @@ -37,8 +36,6 @@
classifiers=[
"License :: OSI Approved :: GNU Affero General Public License v3",
"Operating System :: OS Independent",
# "Programming Language :: Python :: 3.6",
# "Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand All @@ -47,7 +44,5 @@
packages=["cochar"],
include_package_data=True,
install_requires=["rname"],
# packages=find_packages("src"),
# package_dir={'': 'src'},
entry_points={"console_scripts": ["cochar=cochar.__main__:main"]},
)
39 changes: 30 additions & 9 deletions upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,48 @@ echo_help() {
# $VERBOSE && echo -e "$*";
# }

change_version(){
SEMVER_REGEX="^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(\\-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?$"


function validate_version {
if $SOFTWARE_VERSION_FLAG; then
rx="^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"
if [[ ! "$SOFTWARE_VERSION" =~ $rx ]]; then
echo -e "\033[31m\e[1minvalid version format: $SOFTWARE_VERSION\e[0m"
echo_help
local version=$1
if [[ "$version" =~ $SEMVER_REGEX ]]; then
# if a second argument is passed, store the result in var named by $2
if [ "$#" -eq "2" ]; then
local major=${BASH_REMATCH[1]}
local minor=${BASH_REMATCH[2]}
local patch=${BASH_REMATCH[3]}
local prere=${BASH_REMATCH[4]}
local build=${BASH_REMATCH[5]}
eval "$2=(\"$major\" \"$minor\" \"$patch\" \"$prere\" \"$build\")"
else
echo "Version valid"
fi
else
sed -i "s,\"[[:digit:]]\+.[[:digit:]]\+.[[:digit:]]\+\",\"$SOFTWARE_VERSION\",g" setup.py
sed -i "s,\"[[:digit:]]\+.[[:digit:]]\+.[[:digit:]]\+\",\"$SOFTWARE_VERSION\",g" docs/conf.py
sed -i "s,\"[[:digit:]]\+.[[:digit:]]\+.[[:digit:]]\+\",\"$SOFTWARE_VERSION\",g" cochar/__init__.py
error "version $version does not match the semver scheme 'X.Y.Z(-PRERELEASE)(+BUILD)'. See help for more information."
fi
fi
}

change_version(){
local version=$1
if $SOFTWARE_VERSION_FLAG; then
sed -i "s,\"[[:digit:]]\+.[[:digit:]]\+.[[:digit:]]\+.*\",\"$1\",g" setup.py
sed -i "s,\"[[:digit:]]\+.[[:digit:]]\+.[[:digit:]]\+.*\",\"$1\",g" docs/conf.py
sed -i "s,\"[[:digit:]]\+.[[:digit:]]\+.[[:digit:]]\+.*\",\"$1\",g" cochar/__init__.py
echo "Versioin changed to: $1"
fi
}

main(){
# install changes locally that to run tests
pip3 install -e . && \
# run tests, check packages, uploadd packages
pytest -q && \
# change version in all files that contains info about it
# change_version && \
validate_version $SOFTWARE_VERSION && \
change_version $SOFTWARE_VERSION && \
# clean dist directory
rm -rvf -i build && \
rm -rvf -i $(echo dist/*) && \
Expand Down
27 changes: 22 additions & 5 deletions webapp/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
FROM python:3.8-alpine
# Cochar - create a random character for Call of Cthulhu RPG 7th ed.
# Copyright (C) 2023 Adam Walkiewicz

RUN apk add --no-cache --virtual .build-deps build-base linux-headers pcre-dev
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

FROM ubuntu:20.04

# set the working directory
WORKDIR /webapp

RUN apt-get update
RUN apt-get upgrade --yes
RUN apt-get install python3.8 python3-pip --yes

# install dependencies
COPY ./dev_requirements.txt .
RUN pip install --no-cache-dir --upgrade -r dev_requirements.txt
COPY ./requirements.txt .
RUN pip install --no-cache-dir --upgrade -r requirements.txt

# clean .build-deps
# RUN apk del --no-network .build-deps
Expand All @@ -17,4 +35,3 @@ COPY . /webapp

# start the server
CMD ["uwsgi", "--http", "0.0.0.0:80", "--master", "-p", "4", "-w", "wsgi", "--py-autoreload", "3"]
# CMD ["python3", "webapp.py"]
5 changes: 0 additions & 5 deletions webapp/dev_requirements.txt

This file was deleted.

16 changes: 16 additions & 0 deletions webapp/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Cochar - create a random character for Call of Cthulhu RPG 7th ed.
# Copyright (C) 2023 Adam Walkiewicz

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

services:
app:
build: .
Expand Down
74 changes: 74 additions & 0 deletions webapp/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
alabaster==0.7.13
aniso8601==9.0.1
attrs==22.2.0
Babel==2.11.0
black==22.12.0
bleach==6.0.0
certifi==2022.12.7
cffi==1.15.1
charset-normalizer==3.0.1
click==8.1.3
commonmark==0.9.1
cryptography==39.0.0
deepdiff==6.2.3
Deprecated==1.2.13
docutils==0.19
exceptiongroup==1.1.0
Flask==2.2.2
Flask-Limiter==3.1.0
Flask-RESTful==0.3.9
idna==3.4
imagesize==1.4.1
importlib-metadata==6.0.0
importlib-resources==5.10.2
iniconfig==2.0.0
itsdangerous==2.1.2
jaraco.classes==3.2.3
jeepney==0.8.0
Jinja2==3.1.2
jsonschema==4.17.3
keyring==23.13.1
limits==3.2.0
Markdown==3.4.1
MarkupSafe==2.1.2
more-itertools==9.0.0
mypy-extensions==0.4.3
ordered-set==4.1.0
orjson==3.8.5
packaging==23.0
pathspec==0.10.3
pkginfo==1.9.6
pkgutil-resolve-name==1.3.10
platformdirs==2.6.2
pluggy==1.0.0
pycparser==2.21
Pygments==2.14.0
pyrsistent==0.19.3
pytest==7.2.1
pytz==2022.7.1
readme-renderer==37.3
requests==2.28.2
requests-toolbelt==0.10.1
rfc3986==2.0.0
rich==12.6.0
rname==0.3.7
SecretStorage==3.3.3
six==1.16.0
snowballstemmer==2.2.0
sphinx==6.1.3
sphinxcontrib-applehelp==1.0.4
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
tomli==2.0.1
twine==4.0.2
typing-extensions==4.4.0
urllib3==1.26.14
uWSGI==2.0.21
webencodings==0.5.1
Werkzeug==2.2.2
wrapt==1.14.1
zipp==3.11.0
cochar>=1.0.0a0
1 change: 0 additions & 1 deletion webapp/static/README.md

This file was deleted.

Loading

0 comments on commit 44814f2

Please sign in to comment.