preqs


Namepreqs JSON
Version 0.1.0b3 PyPI version JSON
download
home_pageNone
SummaryA simple (and fast) requirements.txt file generator.
upload_time2024-08-09 11:41:46
maintainerNone
docs_urlNone
authorNone
requires_python>=3.6
licenseGNU GPL-3
keywords build development requirements setup utilities
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # A simple (and fast) requirements.txt file generator

[![PyPI - Version](https://img.shields.io/pypi/v/preqs?style=flat-square)](https://pypi.org/project/preqs)
[![PyPI - Implementation](https://img.shields.io/pypi/implementation/preqs?style=flat-square)](https://pypi.org/project/preqs)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/preqs?style=flat-square)](https://pypi.org/project/preqs)
[![PyPI - Status](https://img.shields.io/pypi/status/preqs?style=flat-square)](https://pypi.org/project/preqs)
[![Static Badge](https://img.shields.io/badge/tests-passing-brightgreen?style=flat-square)](https://pypi.org/project/preqs)
[![Static Badge](https://img.shields.io/badge/code_coverage-100%25-brightgreen?style=flat-square)](https://pypi.org/project/preqs)
[![Static Badge](https://img.shields.io/badge/pylint_analysis-100%25-brightgreen?style=flat-square)](https://pypi.org/project/preqs)
[![PyPI - License](https://img.shields.io/pypi/l/preqs?style=flat-square)](https://opensource.org/license/gpl-3-0)
[![PyPI - Wheel](https://img.shields.io/pypi/wheel/preqs?style=flat-square)](https://pypi.org/project/preqs)

The `preqs` project is a cross-platform, simple, fast and easy-to-use requirements file generator. Your project's imported dependencies are collected into a `requirements.txt` file. No more, no less.


## Installation
Installing `preqs` is quick and easy. As a design feature, the library does not have any external (non-built-in) dependencies.
```
pip install preqs
```

## Usage
The help (or usage) menu can be displayed, as below, using the following command from the terminal:
```
preqs --help
```
Which displays:
```
usage: preqs [PATH] [options]

A simple (and fast) requirements.txt file generator.

positional arguments:
  PATH                  Path to the project's root directory.
                        Alternatively, the path where the search for modules should start.
                        Defaults to the current directory.

options:
  -d, --debug           Print verbose debugging output while processing.
  -i IGNORE_DIRS [IGNORE_DIRS ...], --ignore_dirs IGNORE_DIRS [IGNORE_DIRS ...]
                        One or more director(y|ies) to be ignored when collecting module files.
  -p, --print           Print the detected requirements, rather than creating a file.
  -r, --replace         Replace the current requirements.txt file.
                        
  -h, --help            Display this help and usage, then exit.
  -v, --version         Display the version and exit.

preqs <installed version>
```


## Usage Example
In its simplest form, `preqs` can be run by just calling the program from within your project's root directory, without any arguments. The path from which the Python module discovery begins defaults to the *current directory*. If your project is in another directory, pass that directory's path into the `PATH` argument. The requirements file is saved into the path provided. 

**Notes:** 
- The following examples assume you are already in your project's root directory, therefore `PATH` is not provided.
- Any of the following flags may be combined to form your own requirements cocktail.

### Case 1: Simplest form
Simply generate a requirements file for your project, as:

1. Run `preqs` as:
```bash
preqs
``` 
2. Check the current directory for a `requirements.txt` file containing the project's external dependencies.

### Case 2: Ignoring directories
If you wish to exclude a directory (or directories) from the requirements file, the `--ignore_dirs` flag may be used as:

1. Run `preqs` as:
```bash
preqs --ignore_dirs docs build
```
2. Check the current directory for a `requirements.txt` file containing the project's external dependencies.

### Case 3: Display only (do not generate a file)
In some cases, for example with an existing requirements file you do not want to overwrite, you may wish to *display* the requirements to the terminal. This can be accomplished using the `--print` flag, as:

1. Run `preqs` as:
```bash
preqs --print
```
2. Watch the terminal for an output displaying the project's requirements.

### Case 4: Overwrite an existing requirements file
By default, if a `requirements.txt` file exists, you will be alerted. The existing file will *not* be overwritten. That is, unless you tell `preqs` it's OK.

1. Run `preqs` as:
```bash
preqs --replace
```
2. Check the current directory for a *new* `requirements.txt` file containing the project's external dependencies.


## Additional information

### How is the version number obtained?
The version number you see in the requirements file output is obtained using the built-in `importlib` library. Therefore, the package *must be installed* in the environment being used to run `preqs`.

- By design, we do *not* use PyPI to obtain version numbers as this practice usually involves assuming the latest version - whereas this may not be the case for your project.
- Any packages which are known to be imported by the project, and yet do not appear in the requirements file, *are likely not installed* in the environment. Run `preqs` with the `--print` flag to observe any packages which are imported for which the version number could not be obtained. These 'unknown version' packages are (currently) ignored when the requirements file is written.

### I don't see a specific package in the requirements file.
Refer to the *How is the version number obtained?* question.

### Why should I not just use `pip freeze`?
Many online 'tutorials' for generating a requirements file say to use `pip freeze` and redirect the output to a file called `requirements.txt`. However, this is not good practice for the following reasons:

- *All* of the packages installed in your development environment will be listed in the requirements file. This may include some (or many) packages which your project does not require, thus bloating the end-user's installation and thereby cluttering their environment. Or, the packages you have in your environment, although not used by the project, may be out-of-date; causing the end-user to be forced to install out-of-date packages.
- A true requirements file should contain *only* those packages which are imported and required by the project.
- Only the packages that were installed with `pip install` will be included in the requirements file.


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "preqs",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "build, development, requirements, setup, utilities",
    "author": null,
    "author_email": "The Developers <development@s3dev.uk>",
    "download_url": "https://files.pythonhosted.org/packages/e3/4b/f0b8eb87a0d7499eea96cab06e8cfdabceb3041a1a9a8ee475033e50e415/preqs-0.1.0b3.tar.gz",
    "platform": null,
    "description": "# A simple (and fast) requirements.txt file generator\n\n[![PyPI - Version](https://img.shields.io/pypi/v/preqs?style=flat-square)](https://pypi.org/project/preqs)\n[![PyPI - Implementation](https://img.shields.io/pypi/implementation/preqs?style=flat-square)](https://pypi.org/project/preqs)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/preqs?style=flat-square)](https://pypi.org/project/preqs)\n[![PyPI - Status](https://img.shields.io/pypi/status/preqs?style=flat-square)](https://pypi.org/project/preqs)\n[![Static Badge](https://img.shields.io/badge/tests-passing-brightgreen?style=flat-square)](https://pypi.org/project/preqs)\n[![Static Badge](https://img.shields.io/badge/code_coverage-100%25-brightgreen?style=flat-square)](https://pypi.org/project/preqs)\n[![Static Badge](https://img.shields.io/badge/pylint_analysis-100%25-brightgreen?style=flat-square)](https://pypi.org/project/preqs)\n[![PyPI - License](https://img.shields.io/pypi/l/preqs?style=flat-square)](https://opensource.org/license/gpl-3-0)\n[![PyPI - Wheel](https://img.shields.io/pypi/wheel/preqs?style=flat-square)](https://pypi.org/project/preqs)\n\nThe `preqs` project is a cross-platform, simple, fast and easy-to-use requirements file generator. Your project's imported dependencies are collected into a `requirements.txt` file. No more, no less.\n\n\n## Installation\nInstalling `preqs` is quick and easy. As a design feature, the library does not have any external (non-built-in) dependencies.\n```\npip install preqs\n```\n\n## Usage\nThe help (or usage) menu can be displayed, as below, using the following command from the terminal:\n```\npreqs --help\n```\nWhich displays:\n```\nusage: preqs [PATH] [options]\n\nA simple (and fast) requirements.txt file generator.\n\npositional arguments:\n  PATH                  Path to the project's root directory.\n                        Alternatively, the path where the search for modules should start.\n                        Defaults to the current directory.\n\noptions:\n  -d, --debug           Print verbose debugging output while processing.\n  -i IGNORE_DIRS [IGNORE_DIRS ...], --ignore_dirs IGNORE_DIRS [IGNORE_DIRS ...]\n                        One or more director(y|ies) to be ignored when collecting module files.\n  -p, --print           Print the detected requirements, rather than creating a file.\n  -r, --replace         Replace the current requirements.txt file.\n                        \n  -h, --help            Display this help and usage, then exit.\n  -v, --version         Display the version and exit.\n\npreqs <installed version>\n```\n\n\n## Usage Example\nIn its simplest form, `preqs` can be run by just calling the program from within your project's root directory, without any arguments. The path from which the Python module discovery begins defaults to the *current directory*. If your project is in another directory, pass that directory's path into the `PATH` argument. The requirements file is saved into the path provided. \n\n**Notes:** \n- The following examples assume you are already in your project's root directory, therefore `PATH` is not provided.\n- Any of the following flags may be combined to form your own requirements cocktail.\n\n### Case 1: Simplest form\nSimply generate a requirements file for your project, as:\n\n1. Run `preqs` as:\n```bash\npreqs\n``` \n2. Check the current directory for a `requirements.txt` file containing the project's external dependencies.\n\n### Case 2: Ignoring directories\nIf you wish to exclude a directory (or directories) from the requirements file, the `--ignore_dirs` flag may be used as:\n\n1. Run `preqs` as:\n```bash\npreqs --ignore_dirs docs build\n```\n2. Check the current directory for a `requirements.txt` file containing the project's external dependencies.\n\n### Case 3: Display only (do not generate a file)\nIn some cases, for example with an existing requirements file you do not want to overwrite, you may wish to *display* the requirements to the terminal. This can be accomplished using the `--print` flag, as:\n\n1. Run `preqs` as:\n```bash\npreqs --print\n```\n2. Watch the terminal for an output displaying the project's requirements.\n\n### Case 4: Overwrite an existing requirements file\nBy default, if a `requirements.txt` file exists, you will be alerted. The existing file will *not* be overwritten. That is, unless you tell `preqs` it's OK.\n\n1. Run `preqs` as:\n```bash\npreqs --replace\n```\n2. Check the current directory for a *new* `requirements.txt` file containing the project's external dependencies.\n\n\n## Additional information\n\n### How is the version number obtained?\nThe version number you see in the requirements file output is obtained using the built-in `importlib` library. Therefore, the package *must be installed* in the environment being used to run `preqs`.\n\n- By design, we do *not* use PyPI to obtain version numbers as this practice usually involves assuming the latest version - whereas this may not be the case for your project.\n- Any packages which are known to be imported by the project, and yet do not appear in the requirements file, *are likely not installed* in the environment. Run `preqs` with the `--print` flag to observe any packages which are imported for which the version number could not be obtained. These 'unknown version' packages are (currently) ignored when the requirements file is written.\n\n### I don't see a specific package in the requirements file.\nRefer to the *How is the version number obtained?* question.\n\n### Why should I not just use `pip freeze`?\nMany online 'tutorials' for generating a requirements file say to use `pip freeze` and redirect the output to a file called `requirements.txt`. However, this is not good practice for the following reasons:\n\n- *All* of the packages installed in your development environment will be listed in the requirements file. This may include some (or many) packages which your project does not require, thus bloating the end-user's installation and thereby cluttering their environment. Or, the packages you have in your environment, although not used by the project, may be out-of-date; causing the end-user to be forced to install out-of-date packages.\n- A true requirements file should contain *only* those packages which are imported and required by the project.\n- Only the packages that were installed with `pip install` will be included in the requirements file.\n\n",
    "bugtrack_url": null,
    "license": "GNU GPL-3",
    "summary": "A simple (and fast) requirements.txt file generator.",
    "version": "0.1.0b3",
    "project_urls": {
        "Homepage": "https://github.com/s3dev/preqs",
        "Repository": "https://github.com/s3dev/preqs"
    },
    "split_keywords": [
        "build",
        " development",
        " requirements",
        " setup",
        " utilities"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "274c056d2f2806181bdcb448c90ec41ba334801d6fa96a19b1ac992fb280b044",
                "md5": "41943248a8d845fb1f9dc64c0b565390",
                "sha256": "c5b1a65b504ba35fc839a0ed05b297f07222e637406f4e2071fb9593dfd901fe"
            },
            "downloads": -1,
            "filename": "preqs-0.1.0b3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "41943248a8d845fb1f9dc64c0b565390",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 22869,
            "upload_time": "2024-08-09T11:41:44",
            "upload_time_iso_8601": "2024-08-09T11:41:44.577321Z",
            "url": "https://files.pythonhosted.org/packages/27/4c/056d2f2806181bdcb448c90ec41ba334801d6fa96a19b1ac992fb280b044/preqs-0.1.0b3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e34bf0b8eb87a0d7499eea96cab06e8cfdabceb3041a1a9a8ee475033e50e415",
                "md5": "48974232299026fb8e59ff554b60cef4",
                "sha256": "b2bcc02e480c27383b38e620580d413e2c29644ff5889a4e69136f8cce5086fc"
            },
            "downloads": -1,
            "filename": "preqs-0.1.0b3.tar.gz",
            "has_sig": false,
            "md5_digest": "48974232299026fb8e59ff554b60cef4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 42292,
            "upload_time": "2024-08-09T11:41:46",
            "upload_time_iso_8601": "2024-08-09T11:41:46.170617Z",
            "url": "https://files.pythonhosted.org/packages/e3/4b/f0b8eb87a0d7499eea96cab06e8cfdabceb3041a1a9a8ee475033e50e415/preqs-0.1.0b3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-09 11:41:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "s3dev",
    "github_project": "preqs",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "preqs"
}
        
Elapsed time: 0.31098s