8000 Add configuration option for appending to sys.path by troyready · Pull Request #179 · cloudtools/stacker · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add configuration option for appending to sys.path #179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 2, 2016
Merged

Add configuration option for appending to sys.path #179

merged 1 commit into from
Aug 2, 2016

Conversation

troyready
Copy link
Contributor

I'd like to be able to store my configs and blueprints in the same repository, e.g.:

README.md
requirements.txt
conf/config.yaml
conf/dev.env
blueprints/__init__.py
blueprints/bastion.py

Currently this isn't possible because util/load_object_from_string only loads from the default sys.path which doesn't include the top level repo directory (only the system paths and the stacker directory under its pip installed location of src/stacker/.

With this commit the yaml configuration file can optionally include a top-level sys_path key which will append its value to sys.path, e.g. sys_path: ./.

@phobologic
Copy link
Member

Thanks @troyready - can you add this to the config docs?

@mwildehahn
Copy link
Contributor

i have the same layout for my configs with the following setup.py:

from setuptools import setup, find_packages

import blueprints

setup(
    name='blueprints',
    version=blueprints.__version__,
    author='Michael Hahn',
    author_email='michael@lunohq.com',
    url='https://github.com/lunohq/secret-stuff.git',
    description='Stacker blueprints',
    packages=find_packages(),
)

I then just install them with:

pip install -e .

which @brianz had talked about here: #41

@mwildehahn
Copy link
Contributor

I don't have a preference though, if this is easier for people, I'm fine with adding it to the config.

@troyready
Copy link
Contributor Author

@phobologic I've added documentation for the new option, should be ready for review again

@mhahn thanks for the background -- I totally hadn't seen that issue. Would be nice to include it in the docs somehow; not sure where the best spot would be

Module Paths
----------------
When setting the ``classpath`` for blueprints/hooks, it is sometimes desirable to
load modules from outside the default ```sys.path`` (e.g., to include modules
Copy link
Member
@phobologic phobologic Aug 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: one too many backticks at the beginning of sys.path. Also, is the backtick syntax valid for RST?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@phobologic good catch, should be fixed now.

rst is new to me, so I was using the syntax from their doc site

This gives the ability to load hooks & blueprints from arbitrary
local paths. E.g.,

```
$ cat conf/config.yaml
sys_path: ./

stacks:
  - name: bastion
...
```

With this set, blueprints/hooks can be kept in the same repo as the
configuration files.
@phobologic
Copy link
Member

Cool - looks good. Thanks @troyready !

@phobologic phobologic merged commit afdd7f9 into cloudtools:master Aug 2, 2016
@troyready troyready deleted the sys_path branch August 2, 2016 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0