Base python project
This commit is contained in:
commit
25b282c856
|
@ -0,0 +1,5 @@
|
||||||
|
/testenv/
|
||||||
|
build/*
|
||||||
|
dist/*
|
||||||
|
*.egg-info/*
|
||||||
|
__pycache__
|
|
@ -0,0 +1,5 @@
|
||||||
|
/testenv/
|
||||||
|
/build/
|
||||||
|
/dist/
|
||||||
|
/*.egg-info
|
||||||
|
__pycache__
|
|
@ -0,0 +1,18 @@
|
||||||
|
FROM ubuntu:focal
|
||||||
|
|
||||||
|
RUN apt-get update && \
|
||||||
|
DEBIAN_FRONTEND=noninteractive apt-get install -y python3-pip && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
ADD requirements.txt /tmp/requirements.txt
|
||||||
|
|
||||||
|
RUN pip3 install -r /tmp/requirements.txt
|
||||||
|
|
||||||
|
ADD . /tmp/code/
|
||||||
|
|
||||||
|
RUN cd /tmp/code && \
|
||||||
|
python3 setup.py install
|
||||||
|
|
||||||
|
USER nobody
|
||||||
|
|
||||||
|
ENTRYPOINT ["packagecli"]
|
|
@ -0,0 +1,20 @@
|
||||||
|
DOCKERIMAGE := dockermirror:5000/dpedu/package
|
||||||
|
DOCKEROPTS :=
|
||||||
|
BINARY := dist/package-0.0.0-py3-none-any.whl
|
||||||
|
|
||||||
|
.PHONY: $(BINARY)
|
||||||
|
$(BINARY):
|
||||||
|
python3 setup.py bdist_wheel
|
||||||
|
|
||||||
|
.PHONY: image
|
||||||
|
image:
|
||||||
|
docker build -t $(DOCKERIMAGE) $(DOCKEROPTS) .
|
||||||
|
|
||||||
|
.PHONY: push
|
||||||
|
push: image
|
||||||
|
docker push $(DOCKERIMAGE)
|
||||||
|
|
||||||
|
.PHONY: testenv
|
||||||
|
testenv:
|
||||||
|
virtualenv -p python3 testenv
|
||||||
|
testenv/bin/pip3 install -r requirements.txt
|
|
@ -0,0 +1,11 @@
|
||||||
|
package
|
||||||
|
=======
|
||||||
|
|
||||||
|
Base git repo for a python project
|
||||||
|
|
||||||
|
You'll want to edit:
|
||||||
|
|
||||||
|
* Rename `package` directory
|
||||||
|
* name, description, package module, and scripts in `setup.py`
|
||||||
|
* docker image name in `Makefile`
|
||||||
|
* entrypoint script name in `Dockerfile`
|
|
@ -0,0 +1,34 @@
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import argparse
|
||||||
|
import logging
|
||||||
|
|
||||||
|
|
||||||
|
def cmd_foo(args, parser):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def cmd_bar(args, parser):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def get_args():
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
|
||||||
|
sp_action = parser.add_subparsers(dest="action", help="action to take")
|
||||||
|
|
||||||
|
p_foo = sp_action.add_parser("foo", help="foo action")
|
||||||
|
p_foo.set_defaults(func=cmd_foo)
|
||||||
|
p_foo.add_argument("-c", "--config", help="config file path")
|
||||||
|
|
||||||
|
sp_bar = sp_action.add_subparsers(dest="bar", help="bar action")
|
||||||
|
sp_bar.set_defaults(func=cmd_bar)
|
||||||
|
sp_bar.add_argument("-s", "--shutdown", action="store_true", help="shutdown on program exit")
|
||||||
|
|
||||||
|
return parser.parse_args(), parser
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
args, parser = get_args()
|
||||||
|
args.func(args, parser)
|
|
@ -0,0 +1,27 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
|
||||||
|
from setuptools import setup
|
||||||
|
|
||||||
|
|
||||||
|
__version__ = "0.0.0"
|
||||||
|
|
||||||
|
|
||||||
|
with open("requirements.txt") as f:
|
||||||
|
deps = f.read().split()
|
||||||
|
|
||||||
|
|
||||||
|
setup(name='package',
|
||||||
|
version=__version__,
|
||||||
|
description='description',
|
||||||
|
url='',
|
||||||
|
author='dpedu',
|
||||||
|
author_email='dave@davepedu.com',
|
||||||
|
packages=['package'],
|
||||||
|
install_requires=deps,
|
||||||
|
entry_points={
|
||||||
|
"console_scripts": [
|
||||||
|
"packagecli = package.cli:main",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
zip_safe=False)
|
Loading…
Reference in New Issue