Skip to content

Commit

Permalink
Updated readme and build script
Browse files Browse the repository at this point in the history
  • Loading branch information
Levi Vande Kamp committed Apr 15, 2022
1 parent d92efdd commit a1bf7b4
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 67 deletions.
66 changes: 65 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ A Python 3 interface for code by Cristian Ioan Vasile <[email protected]> from http
See the original readme, pyTWTL-readme.txt, for information on pyTWTL.

This package can be installed directly from GitHub:
```
```bash
pip install git+https://github.com/levivk/pyTWTL-python3@master
```
## Usage
Expand All @@ -17,3 +17,67 @@ alphabet = out['alphabet'] # The alphabet set
dfa_normal = out['normal'] # The normal dfa
dfa_relaxed = out['infinity'] # The relaxed dfa
```

## How to build

If you want to use this on a different architecture or otherwise run into problems that requires rebundling the Python 2 code, below is how you do that.

### Ubuntu

This method runs a Ubuntu 18.04 docker container and runs pyinstaller there. No need to install Python 2.

```bash
# install git, and docker
sudo apt install git docker.io -y

# clone this repository
git clone https://github.com/levivk/pyTWTL-python3
cd pyTWTL-python3/pyinstaller_build

# run the build script
./build.sh

# run the test
./test.sh

# You should get a few hundred lines of yaml output and no errors
```

### MacOS

Tested on macOS Catalina Version 10.15.7 and Monterey Version 12.3

```bash
# install homebrew https://brew.sh/
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# install pyenv
brew install pyenv
echo 'eval "$(pyenv init --path)"' >> ~/.zprofile
echo 'eval "$(pyenv init -)"' >> ~/.zshrc

# Now close your shell and reopen it

# install python 2.7 with dev libraries
env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install 2.7.18
pyenv global 2.7.18

# clone this repository
git clone https://github.com/levivk/pyTWTL-python3
cd pyTWTL-python3/pyinstaller_build

# install dependencies
pip install -r requirements.txt

# run the build script
bash build.sh

# run the test
bash test.sh

# You should get a few hundred lines of yaml output and no errors

# Uninstall python 2.7
pyenv global system
pyenv uninstall 2.7.18
```
13 changes: 7 additions & 6 deletions pyinstaller_build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@
# cd to script dir
cd $(dirname $0)

# copy to respective folder
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
# Use docker to run in Ubuntu 18.04
docker build -t pytwtl .
docker create --name pytwtl-cont pytwtl
sudo docker build -t pytwtl .
sudo docker create --name pytwtl-cont pytwtl
rm -rf ../pyTWTL/bin-linux/*
docker cp pytwtl-cont:/b/dist/twtl_translate/. ../pyTWTL/bin-linux/
docker rm pytwtl-cont
sudo docker cp pytwtl-cont:/b/dist/twtl_translate/. ../pyTWTL/bin-linux/
sudo docker rm pytwtl-cont
# change ownership
sudo chown $(whoami):$(id -gn) -R ../pyTWTL/bin-linux/*

elif [[ "$OSTYPE" == "darwin"* ]]; then
# remove dist and run pyinstaller
rm -rf dist
pyinstaller twtl_translate.spec
# Copy to folder
rm -rf ../pyTWTL/bin-darwin/*
cp -ra dist/twtl_translate/. ../pyTWTL/bin-darwin/
cp -ra dist/twtl_translate/. ../pyTWTL/bin-darwin/
else
echo "Unsupported OS type:" "$OSTYPE"
fi
59 changes: 0 additions & 59 deletions pyinstaller_build/how_to_build.txt

This file was deleted.

12 changes: 11 additions & 1 deletion pyinstaller_build/test.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
#! /bin/bash
cd $(dirname $0)
./dist/twtl_translate/twtl_translate "[H^1 r2]^[0,10]" --kind=both

# cd to script dir
cd $(dirname $0)

if [[ "$OSTYPE" == "linux-gnu"* ]]; then
../pyTWTL/bin-linux/twtl_translate "[H^1 r2]^[0,10]" --kind=both
elif [[ "$OSTYPE" == "darwin"* ]]; then
../pyTWTL/bin-darwin/twtl_translate "[H^1 r2]^[0,10]" --kind=both
else
echo "Unsupported OS type:" "$OSTYPE"
fi

0 comments on commit a1bf7b4

Please sign in to comment.