aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranklin Wei <franklin@rockbox.org>2019-12-25 22:14:11 -0500
committerFranklin Wei <franklin@rockbox.org>2019-12-25 22:14:11 -0500
commitee860b8ad99670b2c6ac4a059b8dad12fd61b1d2 (patch)
tree36a726536401bdea706efe4759363301ffd9fb34
parent5cc5807b25d0c5d0819a2b16500fa54f10f160a4 (diff)
downloadrastercarve-ee860b8ad99670b2c6ac4a059b8dad12fd61b1d2.zip
rastercarve-ee860b8ad99670b2c6ac4a059b8dad12fd61b1d2.tar.gz
rastercarve-ee860b8ad99670b2c6ac4a059b8dad12fd61b1d2.tar.bz2
rastercarve-ee860b8ad99670b2c6ac4a059b8dad12fd61b1d2.tar.xz
Package for PyPI.
-rw-r--r--.gitignore129
-rw-r--r--README.md8
-rw-r--r--rastercarve/__init__.py16
-rwxr-xr-xrastercarve/__main__.py (renamed from src/rastercarve.py)21
-rwxr-xr-xsetup.py30
5 files changed, 184 insertions, 20 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b6e4761
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,129 @@
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+.eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+wheels/
+pip-wheel-metadata/
+share/python-wheels/
+*.egg-info/
+.installed.cfg
+*.egg
+MANIFEST
+
+# PyInstaller
+# Usually these files are written by a python script from a template
+# before PyInstaller builds the exe, so as to inject date/other infos into it.
+*.manifest
+*.spec
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.nox/
+.coverage
+.coverage.*
+.cache
+nosetests.xml
+coverage.xml
+*.cover
+*.py,cover
+.hypothesis/
+.pytest_cache/
+
+# Translations
+*.mo
+*.pot
+
+# Django stuff:
+*.log
+local_settings.py
+db.sqlite3
+db.sqlite3-journal
+
+# Flask stuff:
+instance/
+.webassets-cache
+
+# Scrapy stuff:
+.scrapy
+
+# Sphinx documentation
+docs/_build/
+
+# PyBuilder
+target/
+
+# Jupyter Notebook
+.ipynb_checkpoints
+
+# IPython
+profile_default/
+ipython_config.py
+
+# pyenv
+.python-version
+
+# pipenv
+# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
+# However, in case of collaboration, if having platform-specific dependencies or dependencies
+# having no cross-platform support, pipenv may install dependencies that don't work, or not
+# install all needed dependencies.
+#Pipfile.lock
+
+# PEP 582; used by e.g. github.com/David-OConnor/pyflow
+__pypackages__/
+
+# Celery stuff
+celerybeat-schedule
+celerybeat.pid
+
+# SageMath parsed files
+*.sage.py
+
+# Environments
+.env
+.venv
+env/
+venv/
+ENV/
+env.bak/
+venv.bak/
+
+# Spyder project settings
+.spyderproject
+.spyproject
+
+# Rope project settings
+.ropeproject
+
+# mkdocs documentation
+/site
+
+# mypy
+.mypy_cache/
+.dmypy.json
+dmypy.json
+
+# Pyre type checker
+.pyre/
diff --git a/README.md b/README.md
index 6ea8461..21ad837 100644
--- a/README.md
+++ b/README.md
@@ -3,16 +3,12 @@
This is a little Python script I wrote to generate 3-axis toolpaths to
engrave raster images.
-## Dependencies
+## Installation
-You just need Python 3, OpenCV, tqdm, and NumPy (i.e. `pip install
-...`).
+`pip install rastercarve`
## Usage
-The program should be self-documenting. Run `src/rastercarve.py
---help` or see the output below.
-
```
usage: rastercarve.py [-h] (--width WIDTH | --height HEIGHT) [-f FEED_RATE]
[-p PLUNGE_RATE] [--rapid RAPID_RATE] [-z SAFE_Z]
diff --git a/rastercarve/__init__.py b/rastercarve/__init__.py
new file mode 100644
index 0000000..f0d4840
--- /dev/null
+++ b/rastercarve/__init__.py
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Rastercarve
+#
+# Copyright (C) 2019 Franklin Wei
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+# KIND, either express or implied.
+
+__version__ = '1.0.0'
diff --git a/src/rastercarve.py b/rastercarve/__main__.py
index 73135e1..836f4d9 100755
--- a/src/rastercarve.py
+++ b/rastercarve/__main__.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-##############################################################################
-# Rastercarve 1.0
+
+# Rastercarve
#
# Copyright (C) 2019 Franklin Wei
#
@@ -13,24 +13,16 @@
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
-"""
-rastercarve: a raster engraving G-code generator
-
-Usage: rastercarve.py IMAGE
+import math
+import sys
-This program outputs G-code to engrave a bitmap image on a 3-axis
-milling machine.
-"""
+from __init__ import __version__
import argparse
import cv2 # image scaling
-import math
import numpy as np # a little vector stuff
-import sys
from tqdm import tqdm # progress bar
-__version__ = '1.0'
-
glob_args = None
##### Default parameters
@@ -316,7 +308,8 @@ def doEngrave():
eprint("%d suppressed debug message(s)." % (debug_msgs))
def main():
- parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter,
+ parser = argparse.ArgumentParser(prog='rastercarve',
+ formatter_class=argparse.ArgumentDefaultsHelpFormatter,
description='Generate G-code to engrave raster images.',
epilog='Defaults are usually safe to leave unchanged.')
parser.add_argument('filename', help='input image (any OpenCV-supported format)')
diff --git a/setup.py b/setup.py
new file mode 100755
index 0000000..3169fb6
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+import setuptools
+from rastercarve import __version__
+
+with open("README.md", "r") as fh:
+ long_description = fh.read()
+
+setuptools.setup(
+ name="rastercarve", # Replace with your own username
+ version=__version__,
+ author="Franklin Wei",
+ author_email="franklin@rockbox.org",
+ description="Generate G-code to engrave raster images.",
+ long_description=long_description,
+ long_description_content_type="text/markdown",
+ url="https://github.com/built1n/rastercarve",
+ packages=setuptools.find_packages(),
+ classifiers=[
+ "Programming Language :: Python :: 3",
+ "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)",
+ "Operating System :: OS Independent",
+ ],
+ python_requires='>=3.6',
+ install_requires=["opencv-python", "numpy", "tqdm", "argparse"],
+ entry_points={
+ "console_scripts": [
+ "rastercarve=rastercarve.__main__:main",
+ ]
+ }
+)