From ff8f3a7cba90ccd88888c2abd98a9141dc9345d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Deuchnord?= Date: Mon, 13 Dec 2021 09:31:53 +0100 Subject: [PATCH] chore: migrate from Pipenv to Poetry (#35) --- .github/workflows/release.yml | 58 +++++++---------------------------- .github/workflows/tests.yml | 36 ++++++---------------- .gitignore | 1 + .gitpod.yml | 4 +-- Makefile | 31 +++---------------- Pipfile | 19 ------------ README.md | 4 +-- kosmorrolib/__version__.py | 26 ---------------- pyproject.toml | 37 ++++++++++++++++++++++ setup.py | 57 ---------------------------------- 10 files changed, 67 insertions(+), 206 deletions(-) delete mode 100644 Pipfile delete mode 100644 kosmorrolib/__version__.py create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9551155..bc1f76a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,66 +1,30 @@ name: Release Application on: - push: - tags: ['v*'] + - release jobs: - release: - name: Create release - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Setup - run: | - sudo apt update - sudo apt install ruby - sudo gem install ronn - - name: Prepare release - id: prepare_release - run: | - changelog="$(git diff $(git describe --abbrev=0 --tags $(git describe --abbrev=0 --tags)^) -- CHANGELOG.md | grep -E '\+[#*]' | sed 's/^+/\n/')" - echo "::set-output name=changelog::$changelog" - - name: Create release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: Version ${{ github.ref }} - draft: true - prerelease: false - body: | - ${{ steps.prepare_release.outputs.changelog }} - - - pip: - name: Release to PyPI + pipy: + name: Build and release to PyPI runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - name: Set up Python uses: actions/setup-python@v1 with: - python-version: '3.7' + python-version: '3.x' - name: Setup environment run: | sudo apt update + python -m pip install --upgrade pip poetry sudo apt install ruby sudo gem install ronn - - name: Install dependencies + - name: Build package run: | - python -m pip install --upgrade pip pipenv twine wheel - pipenv lock --pre - pipenv sync - pipenv run pip freeze > requirements.txt - pip install -r requirements.txt - - name: Build and publish + poetry install + poetry build + - name: Publish package env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_PASSWORD }} run: | - make build - twine upload dist/* - + poetry publish diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b080a61..d693f63 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,11 +14,9 @@ jobs: fail-fast: false matrix: os: - - ubuntu-18.04 - - ubuntu-20.04 - - macos-10.15 + - ubuntu-latest - macos-11.0 - - windows-2019 + - windows-latest python_version: - '3.7' - '3.8' @@ -34,37 +32,23 @@ jobs: python-version: ${{ matrix.python_version }} architecture: x64 - - name: Prepare environment (non-Windows systems) - if: ${{ matrix.os != 'windows-2019' }} + - name: Prepare environment run: | - pip install --upgrade pip pipenv + python3 -m pip install --upgrade pip poetry - - name: Prepare environment (Windows) - if: ${{ matrix.os == 'windows-2019' }} - run: | - python -mpip install --upgrade pip pipenv - - - name: Install dependencies (all systems) + - name: Install dependencies env: PIP_PREFER_BINARY: 1 run: | - pipenv lock --pre - pipenv sync --dev - pipenv install --dev - - - name: Install dependencies (Windows) - if: ${{ matrix.os == 'windows-2019' }} - run: | - pipenv lock -r > requirements.txt - python -mpip install -r requirements.txt + python3 -m poetry install - name: Run doc tests (with coverage) - if: ${{ matrix.os == 'ubuntu-20.04' && matrix.python_version == '3.10' }} + if: ${{ matrix.os == 'ubuntu-latest' && matrix.python_version == '3.10' }} run: | make coverage-doctests - name: Run doc tests (without coverage) - if: ${{ matrix.os != 'ubuntu-20.04' || matrix.python_version != '3.10' }} + if: ${{ matrix.os != 'ubuntu-latest' || matrix.python_version != '3.10' }} run: | make doctests @@ -72,6 +56,6 @@ jobs: env: COVERALLS_PRO_TOKEN: ${{ secrets.COVERALLS_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - if: ${{ matrix.os == 'ubuntu-20.04' && matrix.python_version == '3.10' }} + if: ${{ matrix.os == 'ubuntu-latest' && matrix.python_version == '3.10' }} run: | - pipenv run coveralls --service=github + python3 -m poetry run coveralls --service=github diff --git a/.gitignore b/.gitignore index 8b37576..d2571f9 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ Pipfile.lock # Gitpod-specific: /.vscode/** +poetry.lock diff --git a/.gitpod.yml b/.gitpod.yml index a899705..d711b96 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -8,5 +8,5 @@ vscode: - editorconfig.editorconfig tasks: - - before: pip install -U pip pipenv - init: pipenv lock --pre && pipenv sync --dev --pre + - before: pip install -U pip poetry + init: poetry install diff --git a/Makefile b/Makefile index 945ace9..04f11cf 100644 --- a/Makefile +++ b/Makefile @@ -1,42 +1,19 @@ black: - pipenv run black kosmorrolib setup.py + poetry run black kosmorrolib setup.py .PHONY: tests tests: doctests coverage-doctests: - pipenv run python3 -m coverage run tests.py + python3 -m poetry run coverage run tests.py coverage-report: - pipenv run python3 -m coverage report + python3 -m poetry run coverage report doctests: - pipenv run python3 tests.py - -.PHONY: build -build: - python3 setup.py sdist bdist_wheel - -env: - @if [[ "$$RELEASE_NUMBER" == "" ]]; \ - then echo "Missing environment variable: RELEASE_NUMBER."; \ - echo 'Example: export RELEASE_NUMBER="1.0.0" (without the leading "v")'; \ - exit 1; \ - fi + python3 -m poetry run python tests.py changelog: conventional-changelog -p angular -i CHANGELOG.md -s @echo -e "\e[32m鉁擻e[33m Changelog generated. Don't forget to update the version number before committing.\e[0m" @echo -e " When everything is good, finish the release with 'make tag'." - -tag: env - git add CHANGELOG.md kosmorrolib/__version__.py - git commit -m "build: bump version $$RELEASE_NUMBER" - git tag "v$$RELEASE_NUMBER" - git checkout features - git merge main - git checkout main - - @echo - @echo -e "\e[1mVersion \e[36m$$RELEASE_NUMBER\e[39m successfully tagged!" - @echo -e "Invoke \e[33mgit push origin master features v$$RELEASE_NUMBER\e[39m to finish." diff --git a/Pipfile b/Pipfile deleted file mode 100644 index f146788..0000000 --- a/Pipfile +++ /dev/null @@ -1,19 +0,0 @@ -[[source]] -name = "pypi" -url = "https://pypi.org/simple" -verify_ssl = true - -[dev-packages] -coveralls = "*" -parameterized = "*" -black = "*" -coverage = "*" - -[packages] -skyfield = ">=1.32.0,<2.0.0" -numpy = ">=1.17.0,<2.0.0" -python-dateutil = ">=2.8.0,<3.0.0" -skyfield-data = ">=3.0.0,<4.0.0" - -[requires] -python_version = "3" diff --git a/README.md b/README.md index 71555e0..ef5f822 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,9 @@ Kosmorrolib is available [on PyPI](https://pypi.org/project/kosmorrolib/). To us ### Development environment -First, install [Pipenv](https://pypi.org/project/pipenv/). +To contribute to Kosmorrolib, you will need [Poetry](https://python-poetry.org), a software to manage the project from development to publishing. -Clone this repository and run `pipenv sync` to install all the dependencies. +Clone this repository and run `poetry install` to install the dependencies. And that's all, your development environment is ready for the fight! 馃憦 ## Documentation diff --git a/kosmorrolib/__version__.py b/kosmorrolib/__version__.py deleted file mode 100644 index 114beeb..0000000 --- a/kosmorrolib/__version__.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python3 - -# Kosmorrolib - The Library To Compute Your Ephemerides -# Copyright (C) 2021 J茅r么me Deuchnord -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -__title__ = "kosmorrolib" -__description__ = "A library to compute your ephemerides" -__url__ = "http://kosmorro.space/lib" -__version__ = "1.0.1" -__author__ = "J茅r么me Deuchnord" -__author_email__ = "jerome@deuchnord.fr" -__license__ = "AGPL-v3" -__copyright__ = "2021 - J茅r么me Deuchnord" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..050a23a --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,37 @@ +[tool.poetry] +name = "kosmorrolib" +version = "1.0.1" +authors = ["J茅r么me Deuchnord "] +homepage = "https://kosmorro.space/lib" +repository = "https://github.com/Kosmorro/lib" +documentation = "https://kosmorro.space/lib/doc" +keywords = ["kosmorro", "astronomy", "ephemerides", "ephemeris"] +license = "AGPL-3.0-or-later" +description = "A library to computes the ephemerides." +readme = "README.md" +include = ["CHANGELOG.md"] + +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Topic :: Scientific/Engineering :: Astronomy", + "Topic :: Software Development :: Libraries :: Python Modules", + "Intended Audience :: Developers", + "Intended Audience :: Education", +] + +[tool.poetry.dependencies] +python = "^3.7" +skyfield = "^1.21" +skyfield-data = "^3.0" +numpy = "^1.17" +python-dateutil = "^2.8" + +[tool.poetry.dev-dependencies] +black = "^21.11b1" +parameterized = "^0.8.1" +coverage = "^6.1.2" +coveralls = "^3.3.1" + +[build-system] +requires = ["poetry-core>=1.0.0"] +build-backend = "poetry.core.masonry.api" diff --git a/setup.py b/setup.py deleted file mode 100644 index a7a5059..0000000 --- a/setup.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env python3 - -# Kosmorrolib - The Library To Compute Your Ephemerides -# Copyright (C) 2021 J茅r么me Deuchnord -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -import pathlib -from setuptools import setup, find_packages - -from kosmorrolib.__version__ import __version__ - -HERE = pathlib.Path(__file__).parent -README = (HERE / "README.md").read_text() - -setup( - name="kosmorrolib", - version=__version__, - author="J茅r么me Deuchnord", - author_email="jerome@deuchnord.fr", - url="http://kosmorro.space/lib", - license="AGPL-v3", - description="A library to computes the ephemerides.", - long_description=README, - long_description_content_type="text/markdown", - keywords=["kosmorro", "astronomy", "ephemerides", "ephemeris"], - packages=["kosmorrolib"], - install_requires=[ - "skyfield>=1.21.0,<2.0.0", - "skyfield-data>=3.0.0,<4.0.0", - "numpy>=1.17.0,<2.0.0", - "python-dateutil", - ], - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "Intended Audience :: Education", - "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)", - "Topic :: Software Development :: Libraries :: Python Modules", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Topic :: Scientific/Engineering :: Astronomy", - ], - python_requires=">=3.7", -)