feat: add structure for pypi release

This commit is contained in:
2021-07-20 00:41:46 -04:00
parent ac31d483ac
commit 91f55f517a
5 changed files with 49 additions and 9 deletions

View File

@@ -2,14 +2,14 @@
[![Total alerts](https://img.shields.io/lgtm/alerts/g/gio101046/dopey.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/gio101046/dopey/alerts/)
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/gio101046/dopey.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/gio101046/dopey/context:python)
The dopey brainf\*ck interpreter was created as a side project to become familiar with Python 3. The goal was to fully implement all the features of brainf\*ck as defined in this [wiki page](https://en.wikipedia.org/wiki/Brainfuck#Language_design) into dopey.
Dopey is a brainf\*ck interpreter. It fully implements all the features of brainf\*ck as defined [here](https://en.wikipedia.org/wiki/Brainfuck#Language_design).
## Demo
![gif](https://i.imgur.com/9HbBB1k.gif)
![gif](https://i.imgur.com/QR9qh0e.gif)
## Implemetation Limitations
The dopey is limited to a memory buffer of **30,000** byte cells all initialized to zero. Any attempts to move the pointer past the bounds of the memory buffer will result in an exception being raised. Attempting to print any cell with a value outside of the defined ASCII characters may also result in an exception.
Dopey is limited to a memory buffer of **30,000** byte cells all initialized to zero. Any attempts to move the pointer past the bounds of the memory buffer will result in an exception being raised. Attempting to print any cell with a value outside of the defined ASCII characters may also result in an exception.
## Requirements
@@ -25,13 +25,16 @@ or in some systems
python3 --version
```
## Running dopey
## Installing
Clone the Github repository and from your terminal move to the root of the project and run the following lines:
You can install dopey using `pip`. From the command line:
```bash
chmod +x dopey.py
./dopey.py my_file.bf
# use pip python package manager to install dopey
$ pip install dopey
# run dopey using python
$ python -m dopey my-bf-file.bf
```
You can also import an interpreter class included with dopey and use it in your own python scripts.

4
dopey/__init__.py Normal file
View File

@@ -0,0 +1,4 @@
from dopey.dopey import Interpreter
# version of the dopey package
__version__ = "1.0.0"

4
dopey/__main__.py Normal file
View File

@@ -0,0 +1,4 @@
from dopey.dopey import _main
if __name__ == "__main__":
_main()

View File

@@ -141,7 +141,7 @@ class Interpreter:
if len(_Operation.loop_stack):
raise MismatchBracketException
def main() -> None:
def _main() -> None:
file_location = None
if len(sys.argv) != 2:
print("Invalid or missing arguments...")
@@ -157,4 +157,4 @@ def main() -> None:
interpreter.execute(str_program)
if __name__ == "__main__":
main()
_main()

29
setup.py Normal file
View File

@@ -0,0 +1,29 @@
import pathlib
from setuptools import setup
HERE = pathlib.Path(__file__).parent
README = (HERE / "README.md").read_text()
setup(
name="dopey",
version="1.0.1",
description="A brainfuck interpreter made using python.",
long_description=README,
long_description_content_type="text/markdown",
url="https://github.com/gio101046/dopey",
author="Giovani Rodriguez",
author_email="me@grodriguez.dev",
license="MIT",
classifiers=[
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
],
packages=["dopey"],
include_package_data=True,
entry_points={
"console_scripts": [
"dopey=dopey.dopey:_main",
]
},
)