{"id":13502008,"url":"https://github.com/damnever/pigar","last_synced_at":"2025-05-13T20:10:47.199Z","repository":{"id":1630907,"uuid":"43437198","full_name":"damnever/pigar","owner":"damnever","description":":coffee: A tool to generate requirements.txt for Python project, and more than that. (IT IS NOT A PACKAGE MANAGEMENT TOOL)","archived":false,"fork":false,"pushed_at":"2024-12-18T02:31:47.000Z","size":463117,"stargazers_count":1720,"open_issues_count":29,"forks_count":90,"subscribers_count":26,"default_branch":"main","last_synced_at":"2025-04-28T10:57:41.774Z","etag":null,"topics":["denpendenies","distribution-search","importerror","pip","pypi","python","requirements"],"latest_commit_sha":null,"homepage":"https://damnever.github.io/pigar/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/damnever.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"damnever","patreon":null,"open_collective":null,"ko_fi":"damnever","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2015-09-30T14:17:28.000Z","updated_at":"2025-04-23T07:49:29.000Z","dependencies_parsed_at":"2023-01-14T11:01:01.035Z","dependency_job_id":"e6ef2a33-c2cd-42d5-8a4c-5f1613b2ebac","html_url":"https://github.com/damnever/pigar","commit_stats":{"total_commits":351,"total_committers":19,"mean_commits":"18.473684210526315","dds":0.6438746438746439,"last_synced_commit":"755aed7132fb950bfa8dd0aa5c19a573edc535d3"},"previous_names":[],"tags_count":46,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damnever%2Fpigar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damnever%2Fpigar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damnever%2Fpigar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damnever%2Fpigar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/damnever","download_url":"https://codeload.github.com/damnever/pigar/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254020608,"owners_count":22000753,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["denpendenies","distribution-search","importerror","pip","pypi","python","requirements"],"created_at":"2024-07-31T22:01:58.268Z","updated_at":"2025-05-13T20:10:47.180Z","avatar_url":"https://github.com/damnever.png","language":"Python","readme":"## pigar\n\n[![](https://img.shields.io/github/actions/workflow/status/damnever/pigar/ci.yml?branch=main\u0026style=flat-square)](https://github.com/damnever/pigar/actions) [![](https://img.shields.io/pypi/v/pigar.svg?style=flat-square)](https://pypi.org/project/pigar)\n\n\n- Generating requirements.txt for Python project.\n   - Handling the difference between different Python versions.\n   - Jupyter notebook (`*.ipynb`) support.\n   - Including the import statements/magic from ``exec``/``eval``/``importlib``, doctest of docstring, etc.\n- Searching ditributions(packages) by the top level import/module names.\n- Checking the latest versions of requirements.\n\n**NOTE**: [Pipenv or other tools](https://packaging.python.org/tutorials/managing-dependencies/#managing-dependencies) is recommended for improving your development flow.\n\n\n### Installation\n\n`pigar` can run on Python 3.7+.\n\nTo install it with `pip`, use:\n```\n[sudo] pip install pigar\n```\nTo install it with ``conda``, use:\n```\nconda install -c conda-forge pigar\n```\nTo get the newest code from GitHub:\n```\npip install git+https://github.com/damnever/pigar.git@[main or other branch] --upgrade\n```\n\n### Usage\n\n- `pigar` can consider most kinds of complicated situations(see [FAQ](#faq)). For example, `pigar v1` has [py2_requirements.txt](https://github.com/damnever/pigar/blob/c68d372fba4a6f98228ec3cf8e273f59d68d0e3c/py2_requirements.txt) and [py3_requirements.txt](https://github.com/damnever/pigar/blob/c68d372fba4a6f98228ec3cf8e273f59d68d0e3c/py3_requirements.txt) for different Python versions.\n\n    ```\n    # Generate requirements.txt for current directory.\n    $ pigar generate\n\n    # Generating requirements.txt for given directory in given file.\n    $ pigar gen -f ../dev-requirements.txt ../\n    ```\n\n    `pigar gen --with-referenced-comments` can list all files which referenced the package/distribution(the line numbers for Jupyter notebook may be a bit confusing), for example:\n    ```\n    # project/foo.py: 2,3\n    # project/bar/baz.py: 2,7,8,9\n    foobar == 3.3.3\n    ```\n\n    If the requirements.txt is overwritten, ``pigar`` will show the difference between the old and the new, use `--dont-show-differences` to disable it.\n\n    **NOTE**, `pigar` will search the packages/distributions in local environment first, then it will do further analysis and search missing packages/distributions on PyPI.\n\n    See also: [EXPERIMENTAL FEATURES](https://github.com/damnever/pigar#experimental-features).\n\n- If you do not know the import name that belongs to a specific distribution (more generally, does `Import Error: xxx` drive you crazy?), such as `bs4` which may come from `beautifulsoup4` or `MySQLdb` which could come from `mysql-python`, try searching for it:\n\n    ```\n    $ pigar search bs4 MySQLdb\n    ```\n\n- Checking for the latest version:\n\n    ```\n    # Specify a requirements file.\n    $ pigar check -f ./requirements.txt\n\n    # Or, you can let pigar searching all *requirements.txt in the current directory\n    # level by itself.\n    $ pigar check\n    ```\n\n- More:\n\n  TIP: `pigar` accepts a prefix for a command, such as `pigar gen`, `pigar c`.\n   ```\n   pigar --help\n   ```\n\n\n### EXPERIMENTAL FEATURES\n\n- `requirement-annotations`\n\n    Some packages may require optional packages/distributions to be installed depending on your usage. To make `pigar` a little bit more useful, use `pigar generate --enable-feature requirement-annotations` in conjunction with comments following the format below:\n    ```python\n    import foo # pigar: required-imports=import_name_bar,import_name_baz\n    import foo # pigar: required-packages=package-name-bar,package-name-baz # Extra comments are allowed.\n    foo(features=['bar', 'baz']) # pigar: required-distributions=package-name-bar,package-name-baz\n    ```\n    If you find the comment intrusive, you can extract those comments into a separate Python file and delete it as needed, for example, 'pigar_annotations.py'.\n\n\n### FAQ\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n  Is `pigar` a dependency management tool?\n  \u003c/summary\u003e\n\n**No.** I've thought about this many times, but there is too much dirty work to be done to make `pigar`'s way reliable.\n\nI like the way `pigar` does the job, but sadly, `pigar` does a bad job of managing dependencies, `pigar` is more like a tool to assist an old project to migrate to a new development workflow.\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n  (1) Why does `pigar` show multiple packages/distributions for the same import name?\n\n  (2) Why does `pigar` generate different packages/distributions for the same import name in different environment?\n  \u003c/summary\u003e\n\n`pigar` can not handle those situations gracefully, you may need to remove the duplicate packages in requirements.txt manually, or select one of them when `pigar` asks you.\nInstall the required packages/distributions(remove others) in local environment should fix it as well.\n\nRelated issues: [#32](https://github.com/damnever/pigar/issues/32), [#68](https://github.com/damnever/pigar/issues/68), [#75](https://github.com/damnever/pigar/issues/75#issuecomment-605639825).\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n  Why can't `pigar` find the packages/distributions that have not been explicit import?\n  \u003c/summary\u003e\n\nSome frameworks may use some magic to import the modules for users automatically, and `pigar` can not handle it, you may need to fix it manually or use the [EXPERIMENTAL FEATURES](https://github.com/damnever/pigar#experimental-features).\n\nRelated issues: [#33](https://github.com/damnever/pigar/issues/33), [#103](https://github.com/damnever/pigar/issues/103)\n\u003c/details\u003e\n\n\n### More\n\n`pigar` does not use regular expressions in such a violent way. Instead, it uses AST, which is a better method for extracting imported names from arguments of `exec`/`eval`/`importlib`, doctest of docstring, etc. However, `pigar` can not solve all the tricky problems, see [FAQ](https://github.com/damnever/pigar#faq).\n\nAlso, `pigar` can detect the difference between different Python versions. For example, you can find `concurrent.futures` from the Python 3.2 standard library, but you will need install `futures` in earlier versions of Python to get `concurrent.futures`, this is not a hardcode.\n\nIf you have any issues or suggestions, [please submit an issue on GitHub](https://github.com/damnever/pigar/issues). [**All contributions are appreciated!**](https://github.com/damnever/pigar/graphs/contributors)\n\n\n### LICENSE\n\n[The BSD 3-Clause License](https://github.com/damnever/pigar/blob/master/LICENSE)\n","funding_links":["https://github.com/sponsors/damnever","https://ko-fi.com/damnever"],"categories":["Python","'예제 모음'에서 어느 정도의 '튜토리얼'이 되기까지"],"sub_categories":["의존성 관리"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdamnever%2Fpigar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdamnever%2Fpigar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdamnever%2Fpigar/lists"}