Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

saun4app/generator-python-lib

Open more actions menu

Repository files navigation

generator-python-lib

Build Status codecov.io Dependency Status devDependency Status Commitizen friendly

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.

Features

  • [✓] 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 .pylintrc for checking code quality.
  • [✓] Bootstrap Git configuration files, .gitattributes and .gitignore.
  • [✓] Bootstrap CONTRIBUTING.md file.
  • [✓] Bootstrap README.md file.

Installation

To install generator-python-lib from the npm registry run:

npm install --global generator-python-lib

Make sure you have the Yeoman CLI tool, yo, installed globally. You can install Yeoman via the following command:

npm install --global yo

You will also need to have pip and virtualenv installed to work with your scaffolded Python library.

Usage

Create a new directory to host your project and navigate into it:

mkdir my-new-lib && cd $_

Then run the generator:

yo python-lib

You 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 venv

Next you'll need to activate the virtual environment by sourcing the activate script created within the virtual environment directory:

source ./venv/bin/activate

Now 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.txt

This 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 test

For a full list of tasks available through setup.py run:

python setup.py --help-commands

Composability

generator-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 --save

To 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
    }
});

Options

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.

skip-welcome-message

Default: UNDEFINED

Should the generator's welcome message be skipped (suppressed)?

projectName

Default: [Name of project folder]

Used as the module name for your Python library,

fullName

Default: Previously defined value in .yo-rc.json file or UNDEFINED

Your full name.

email

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.

githubName

Default: Previously defined value in .yo-rc.json file or UNDEFINED

Your GitHub username.

ciProvider

Default: Previously defined value in .yo-rc.json file or UNDEFINED

Continuous Integration provider, such as Travis CI (option value of Travis CI).

Contributing

Read CONTRIBUTING.

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published
Morty Proxy This is a proxified and sanitized view of the page, visit original site.