Skip to content

Commit

Permalink
Fixes #182 detect existing virtualenv instead of creating a new envir…
Browse files Browse the repository at this point in the history
…onment (#184)
  • Loading branch information
pri22296 authored and mariobehling committed Jun 29, 2017
1 parent 8b59cb9 commit dc0bb7d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
1 change: 0 additions & 1 deletion .utility/deploy_docs.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/bin/bash

if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
pip install --user virtualenv
cp ./generate_ci.sh ./generate_copy.sh
chmod +x ./generate_copy.sh
./generate_copy.sh
Expand Down
11 changes: 0 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,13 @@ Currently Yaydoc only supports publishing to ghpages. More publishers to be adde
## Travis Configuration
Add the following content to the `.travis.yml` file in the root directory of your repository.

**If the primary language is Python**

```yaml
deploy:
- provider: script
skip_cleanup: true
script: wget -O - https://raw.githubusercontent.com/fossasia/yaydoc/master/generate_ci.sh | bash
```

**For Languages other than Python**

```yaml
deploy:
- provider: script
skip_cleanup: true
script: pip install --user virtualenv && wget -O - https://raw.githubusercontent.com/fossasia/yaydoc/master/generate_ci.sh | bash
```

## Using SSH
Additionally If you have ssh setup on your repository, yaydoc prioritizes it over Github Personal token. To setup ssh follow these steps.

Expand Down
17 changes: 13 additions & 4 deletions generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ do
esac
done

# https://stackoverflow.com/a/15454916/4127836
INVENV=$(python -c 'import sys; print ("true" if hasattr(sys, "real_prefix") else "false")')

# Ensures that BASE has contents of yaydoc repository
# and change current directory to git repository.
if [ "${WEBUI:-false}" == "true" ]; then
Expand Down Expand Up @@ -42,10 +45,16 @@ ROOT_DIR=$(pwd)

if [ -z "$ON_HEROKU" ]; then
# Create an isolated Python environment
echo -e "Creating an isolated Python environment\n"
virtualenv -q --python=python $HOME/yaydocvenv
source $HOME/yaydocvenv/bin/activate
echo -e "Python environment created successfully!\n"
if [ "$INVENV" == "false" ]; then
echo -e "Installing virtualenv\n"
pip install -q --user virtualenv
echo -e "Installation successful\n"

echo -e "Creating an isolated Python environment\n"
virtualenv -q --python=python $HOME/yaydocvenv
source $HOME/yaydocvenv/bin/activate
echo -e "Python environment created successfully!\n"
fi

# Install packages required for documentation generation
echo -e "Installing packages required for documentation generation\n"
Expand Down
4 changes: 3 additions & 1 deletion generate_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ function clean() {
cd $ROOT_DIR
rm -rf $BUILD_DIR
rm -rf $BASE
deactivate
if [ "$INVENV" == "false" ]; then
deactivate
fi
}

# Generate documentation
Expand Down

0 comments on commit dc0bb7d

Please sign in to comment.