Skip to content

Commit

Permalink
Migrating the packaging system to poetry with pyproject.toml
Browse files Browse the repository at this point in the history
- Deleted old setup files `requirements.txt`, `setup.cfg`, `setup.py`, `MANIFEST.in`
- Added poetry files `poetry.toml`, `pyproject.toml`, `poetry.lock`
- Added `.pyenv-version` and `.tool-versions` for `pyenv` and `asdf`
- Updated `Makefile`, `CONTRIBUTING.rst`, `tox.ini`
  • Loading branch information
fredgrub committed Nov 8, 2023
1 parent 368e9ae commit 18f2032
Show file tree
Hide file tree
Showing 12 changed files with 884 additions and 103 deletions.
5 changes: 5 additions & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
3.11
3.10
3.9
3.8
pypy3.9-7.3.12
2 changes: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
python 3.11 3.10 3.9 3.8 pypy3.9-7.3.12

21 changes: 10 additions & 11 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,11 @@ Ready to contribute? Here's how to set up `pipreqs` for local development.
2. Clone your fork locally::

$ git clone [email protected]:your_name_here/pipreqs.git
$ cd pipreqs/

3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development::
3. Pipreqs is developed using Poetry. Refer to the `documentation <https://python-poetry.org/docs/>`_ to install Poetry in your local environment. Next, you should install pipreqs's dependencies::

$ mkvirtualenv pipreqs
$ cd pipreqs/
$ python setup.py develop
$ poetry install --with dev

4. Create a branch for local development::

Expand All @@ -76,11 +75,11 @@ Ready to contribute? Here's how to set up `pipreqs` for local development.

5. When you're done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox::

$ flake8 pipreqs tests
$ python setup.py test
$ tox

To get flake8 and tox, just pip install them into your virtualenv.
$ poetry run flake8 pipreqs tests
$ poetry run python -m unittest discover
$ poetry run tox
To test all versions of python using tox you need to have them installed and for this two options are recommended: `pyenv` or `asdf`.

6. Commit your changes and push your branch to GitHub::

Expand All @@ -99,7 +98,7 @@ Before you submit a pull request, check that it meets these guidelines:
2. If the pull request adds functionality, the docs should be updated. Put
your new functionality into a function with a docstring, and add the
feature to the list in README.rst.
3. The pull request should work for Python 3.7 to 3.11, and PyPy. Check
3. The pull request should work for currently supported Python and PyPy versions. Check
https://travis-ci.org/bndr/pipreqs/pull_requests and make sure that the
tests pass for all supported Python versions.

Expand All @@ -108,4 +107,4 @@ Tips

To run a subset of tests::

$ python -m unittest tests.test_pipreqs
$ poetry run python -m unittest tests.test_pipreqs
13 changes: 0 additions & 13 deletions MANIFEST.in

This file was deleted.

26 changes: 13 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ help:
@echo "clean-pyc - remove Python file artifacts"
@echo "clean-test - remove test and coverage artifacts"
@echo "lint - check style with flake8"
@echo "test - run tests quickly with the default Python"
@echo "test - run tests quickly using the default Python"
@echo "test-all - run tests on every Python version with tox"
@echo "coverage - check code coverage quickly with the default Python"
@echo "docs - generate Sphinx HTML documentation, including API docs"
@echo "release - package and upload a release"
@echo "dist - package"
@echo "install - install the package to the active Python's site-packages"
@echo "install - install the dependencies into the Poetry virtual environment"

clean: clean-build clean-pyc clean-test

Expand All @@ -35,14 +35,13 @@ clean-test:
rm -fr htmlcov/

lint:
flake8 pipreqs tests
poetry run flake8 pipreqs tests

test:
pip install -r requirements.txt
python setup.py test
poetry run python -m unittest discover

test-all:
tox
poetry run tox

coverage:
coverage run --source pipreqs setup.py test
Expand All @@ -58,13 +57,14 @@ docs:
$(MAKE) -C docs html
open docs/_build/html/index.html

release: clean
python setup.py sdist bdist_wheel upload -r pypi
publish: build
poetry publish

dist: clean
python setup.py sdist
python setup.py bdist_wheel
ls -l dist
publish-to-test: build
poetry publish --repository test-pypi

build: clean
poetry build

install: clean
python setup.py install
poetry install --with dev
811 changes: 811 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions poetry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[virtualenvs]
prefer-active-python = true
39 changes: 39 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[tool.poetry]
name = "pipreqs"
version = "0.4.13"
description = "Pip requirements.txt generator based on imports in project"
authors = ["Vadim Kravcenko <[email protected]>"]
license = "Apache-2.0"
readme = ["README.rst", "HISTORY.rst"]
packages = [{include = "pipreqs"}]
repository = "https://github.com/bndr/pipreqs"
keywords = ["pip", "requirements", "imports"]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Natural Language :: English",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11"
]

[tool.poetry.scripts]
pipreqs = "pipreqs.pipreqs:main"

[tool.poetry.dependencies]
python = ">=3.8.1,<3.12"
yarg = "0.1.9"
docopt = "0.6.2"

[tool.poetry.group.dev.dependencies]
flake8 = "^6.1.0"
tox = "^4.11.3"
coverage = "^7.3.2"
sphinx = { version = "^7.2.6", python = ">=3.9" }

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
3 changes: 0 additions & 3 deletions requirements.txt

This file was deleted.

2 changes: 0 additions & 2 deletions setup.cfg

This file was deleted.

58 changes: 0 additions & 58 deletions setup.py

This file was deleted.

5 changes: 2 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[tox]
isolated_build = true
envlist = py38, py39, py310, py311, pypy3, flake8

[gh-actions]
Expand All @@ -12,9 +13,7 @@ python =
[testenv]
setenv =
PYTHONPATH = {toxinidir}:{toxinidir}/pipreqs
commands = python setup.py test
deps =
-r{toxinidir}/requirements.txt
commands = python -m unittest discover

[flake8]
exclude =
Expand Down

0 comments on commit 18f2032

Please sign in to comment.