Skip to content

Commit 78091bb

Browse files
author
Anthony Yang
committed
set up files for pypi
1 parent f8f567a commit 78091bb

15 files changed

+72
-37
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,8 @@ src/harmony/buildversion
1010
*.htm
1111
*.hvm
1212
*.dump
13+
.idea
14+
.vscode
15+
build
16+
17+
*.egg-info

MANIFEST.in

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include charm.c
2+
include harmony
3+
include harmony.bat
4+
include charm.Windows.exe

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
all:
2-
java -jar ~/antlr4/antlr-4.9.2-complete.jar -Dlanguage=Python3 -visitor Harmony.g4 -no-listener
2+
java -jar ~/antlr4/antlr-4.9.2-complete.jar -Dlanguage=Python3 -o harmony_model_checker -visitor Harmony.g4 -no-listener
33
(cd src/harmony; sh gen.scr) > harmony.py
44
(cd src/charm; sh gen.scr) > charm.c
55
gcc -g -std=c99 charm.c -m64 -o charm.exe -lpthread
File renamed without changes.
File renamed without changes.
File renamed without changes.

app.py harmony_model_checker/app.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
import sys
99
import argparse
1010

11-
from harmony import Code, Scope, FrameOp, ReturnOp, optimize, dumpCode, Brief, GenHTML, namestack, PushOp, \
11+
from .harmony import Code, Scope, FrameOp, ReturnOp, optimize, dumpCode, Brief, GenHTML, namestack, PushOp, \
1212
StoreOp, novalue, imported, files, HarmonyCompilerError, State, ContextValue, constants, modules, run, htmldump
13-
from HarmonyParser import HarmonyParser
14-
from src.compiler.parser.HarmonyParserErrorListener import HarmonyParserErrorListener
15-
from src.compiler.parser.HarmonyTokenStream import HarmonyTokenStream
16-
from HarmonyLexer import HarmonyLexer
17-
from src.compiler.visitor import HarmonyVisitorImpl
13+
from harmony_model_checker.HarmonyParser import HarmonyParser
14+
from harmony_model_checker.compiler.parser.HarmonyParserErrorListener import HarmonyParserErrorListener
15+
from harmony_model_checker.compiler.parser.HarmonyTokenStream import HarmonyTokenStream
16+
from harmony_model_checker.HarmonyLexer import HarmonyLexer
17+
from harmony_model_checker.compiler.visitor import HarmonyVisitorImpl
1818

1919

2020
def build_parser(progam_input):
@@ -86,7 +86,7 @@ def do_import(scope, code, module):
8686

8787
found = False
8888
install_path = os.path.dirname(os.path.realpath(__file__))
89-
for directory in [os.path.dirname(namestack[-1]), os.path.join(install_path, "modules"), "."]:
89+
for directory in [os.path.dirname(namestack[-1]), os.path.join(install_path, "../modules"), "."]:
9090
filename = os.path.join(directory, modname + ".hny")
9191
if os.path.exists(filename):
9292
load_file(filename, scope2, code)
@@ -265,7 +265,7 @@ def main():
265265
# see if there is a configuration file
266266
if charm_flag:
267267
# see if there is a configuration file
268-
outfile = os.path.join(install_path, "charm.exe")
268+
outfile = os.path.join(install_path, "../charm.exe")
269269
with open(hvm_file, "w") as fd:
270270
dumpCode("json", code, scope, f=fd)
271271
r = os.system("%s %s %s" % (outfile, " ".join(charm_options), hvm_file))
File renamed without changes.

src/compiler/visitor.py harmony_model_checker/compiler/visitor.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11

22
from antlr4.Token import CommonToken
33

4-
from HarmonyVisitor import HarmonyVisitor
5-
from HarmonyParser import HarmonyParser
6-
from typing import Any
7-
from harmony import *
4+
from harmony_model_checker.HarmonyVisitor import HarmonyVisitor
5+
from harmony_model_checker.HarmonyParser import HarmonyParser
6+
from harmony_model_checker.harmony import *
87
import math
98

109

harmony.py harmony_model_checker/harmony.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"""
3434

3535
version = [
36-
1,2, 102
36+
1,2, 105
3737

3838
]
3939

pyproject.toml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[build-system]
2+
requires = ["setuptools", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+

setup.cfg

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[build-system]
2+
requires = ["setuptools", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[options.entry_points]
6+
console_scripts =
7+
harmony = harmony_model_checker:app.main

setup.py

+39-23
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,45 @@
11
import os
2-
from distutils.core import setup
32

4-
requires = [
5-
"numpy",
6-
"matplotlib",
7-
"antlrdenter",
8-
"antlr4python3runtime",
9-
"automatalib"
10-
]
3+
from setuptools import setup
4+
from setuptools.command.develop import develop
5+
from setuptools.command.install import install
6+
import subprocess
7+
8+
9+
def compile_charm():
10+
subprocess.call([
11+
"gcc", "-g", "-std=c99", "charm.c",
12+
"-m64", "-o", "charm.exe", "-lpthread"
13+
])
14+
15+
16+
class PostDevelopCommand(develop):
17+
"""Post-installation for development mode."""
18+
def run(self):
19+
develop.run(self)
20+
compile_charm()
21+
22+
23+
class PostInstallCommand(install):
24+
def run(self):
25+
install.run(self)
26+
compile_charm()
1127

12-
modules_files = [os.path.join("modules", f) for f in os.listdir("modules")]
13-
code_files = [os.path.join("code", f) for f in os.listdir("code")]
1428

1529
setup(
16-
name='harmony',
17-
version='1.2',
18-
url='https://harmony.cs.cornell.edu/',
19-
author='Robbert van Renesse',
20-
author_email='[email protected]',
21-
description='The Harmony programming language',
22-
long_description=open('README.txt').read(),
23-
requires=requires,
24-
packages=["harmony_lib"],
25-
data_files=[
26-
("modules", modules_files),
27-
("code", code_files)
28-
]
30+
name="harmony_model_checker",
31+
version="1.2.0",
32+
packages=["harmony_model_checker"],
33+
install_requires=[
34+
"numpy",
35+
"matplotlib",
36+
"antlr-denter",
37+
"antlr4-python3-runtime",
38+
"automata-lib"
39+
],
40+
include_package_data=False,
41+
cmdclass={
42+
'develop': PostDevelopCommand,
43+
'install': PostInstallCommand
44+
}
2945
)

0 commit comments

Comments
 (0)