Skip to content

Commit

Permalink
[+] support extras/ directory for custom python modules
Browse files Browse the repository at this point in the history
  • Loading branch information
ownport committed Mar 6, 2019
1 parent d728ee2 commit 4cfca34
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.2.2

- [x] added extras/ directory for custom python modules

## 0.2.1

- [x] Ansible-2.7.8
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

VERSION ?= 'v0.2.1'
VERSION ?= 'v0.2.2'
TARBALL_NAME ?= portable-ansible-$(VERSION)


Expand Down Expand Up @@ -28,6 +28,7 @@ post-clean:
deps:
@ mkdir -p $(shell pwd)/target/ansible/ && \
cp $(shell pwd)/templates/__main__.py $(shell pwd)/target/ansible/
@ mkdir -p $(shell pwd)/target/ansible/extras/
# @ cp $(shell pwd)/templates/ansible-compat-six-init.py $(shell pwd)/ansible/ansible/compat/six/__init__.py


Expand Down
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Ansible package with required python modules. No need to install, just download,

## Included in the distribution

Version: 0.2.1
Version: 0.2.2

| Package | Version |
| -------- | ------- |
Expand Down Expand Up @@ -40,6 +40,17 @@ $ ln -s ansible ansible-playbook
$ python ansible-playbook playbook.yml
```

## Supporting additional python packages

Install python packages into `ansible/extras` directory
```
pip install -t ansible/extras <package>
```
or
```
pip install -t ansible/extras -r requirements.txt
```

## For developers

to create tarball with required packages just run
Expand Down
12 changes: 11 additions & 1 deletion templates/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,17 @@ def clean_syspath(*paths):


sys.path = clean_syspath()
sys.path.insert(0, os.path.dirname(os.path.realpath(os.path.abspath(__file__))))

ansible_path = os.path.dirname(os.path.realpath(os.path.abspath(__file__)))
sys.path.insert(0, ansible_path)

# add extras/ directory in ansible path for custom python packages
if sys.platform in ['win32', 'cygwin']:
sys.path.insert(0, ansible_path + '\\extras')
elif sys.platform in ['darwin']:
sys.path.insert(0, ansible_path + '/extras')
else:
sys.path.insert(0, ansible_path + '/extras')


__requires__ = ['ansible']
Expand Down

0 comments on commit 4cfca34

Please sign in to comment.