Generator for bootstrapping a Python library.
generator-python-lib scaffolds a basic Python library, with a build, and example source files, using your responses to a series of command line prompts.
- [✓] Bootstrap Python 3 compatible library.
- [✓] Bootstrap support for writing tests using Python's built-in unittest framework.
- [✓] Bootstrap Tox configuration file tox.ini to support executing tests against multiple Python interpretors.
- [✓] Bootstrap Pylint configuration file
.pylintrcfor checking code quality. - [✓] Bootstrap Git configuration files, .gitattributes and .gitignore.
- [✓] Bootstrap CONTRIBUTING.md file.
- [✓] Bootstrap README.md file.
To install generator-python-lib from the npm registry run:
npm install --global generator-python-libMake sure you have the Yeoman CLI tool, yo, installed globally. You can install Yeoman via the following command:
npm install --global yoYou will also need to have pip and virtualenv installed to work with your scaffolded Python library.
Create a new directory to host your project and navigate into it:
mkdir my-new-lib && cd $_Then run the generator:
yo python-libYou will be prompted for input that will be used to bootstrap your project. Keep in mind that your responses, and the resulting file contents, can be changed at a later date by re-running the generator.
Once your Python library has been scaffolded create a virtual environment:
virtualenv --python=python3 venvNext you'll need to activate the virtual environment by sourcing the activate script created within the virtual environment directory:
source ./venv/bin/activateNow your shell environment is configured to expose all tools and libraries installed within the virtual environment. For example, to install the required development tools, run the following:
pip install -r requirements-dev.txtThis installs, among other things, tox, which can run your library's unit tests against all versions of Python installed on your system. To run tox, and the library's unit tests, run the following:
python setup.py testFor a full list of tasks available through setup.py run:
python setup.py --help-commandsgenerator-python-lib may be integrated into other Yeoman generators through Yeoman's composability feature.
First off you will need to add generator-python-lib to your generator's dependencies:
npm install generator-python-lib --saveTo invoke generator-python-lib add the following code to any method in your generator:
this.composeWith('python-lib', {
options: {}
});If passing options to the generator:
this.composeWith('python-lib', {
options: {
'skip-welcome-message': true
}
});generator-python-lib supports several options; their default values are listed below.
Options may be provided on the command line, such as passing --projectName=my-project-name when calling generator-python-lib directly, or via the options argument passed to composeWith.
When the value for an option is fetched from the working directory's .yo-rc.json file, or passed as a command line argument, this yeoman generator will not prompt you for the value.
Default: UNDEFINED
Should the generator's welcome message be skipped (suppressed)?
Default: [Name of project folder]
Used as the module name for your Python library,
Default: Previously defined value in .yo-rc.json file or UNDEFINED
Your full name.
Default: Previously defined value in .yo-rc.json file or UNDEFINED
Contact e-mail for those trying to reach you as the author of the library.
Default: Previously defined value in .yo-rc.json file or UNDEFINED
Your GitHub username.
Default: Previously defined value in .yo-rc.json file or UNDEFINED
Continuous Integration provider, such as Travis CI (option value of Travis CI).
Read CONTRIBUTING.