Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pip): migrate to publishing pip package using poetry #23

Merged
merged 5 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Publish pip on PyPi

on: workflow_dispatch

jobs:
publish-to-production-pypi:
strategy:
matrix:
os: [ ubuntu-latest ]
python-version: [ "3.9" ]

runs-on: ${{ matrix.os }}

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Publish to production PyPI
run: |
poetry version $(git describe --tags --abbrev=0)
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
poetry publish --build
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [ "main" ]

jobs:
build:
lints-and-tests:

runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -43,4 +43,36 @@ jobs:
- name: Test with pytest
run: |
pip install .
pytest
pytest

publish-package:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs: lints-and-tests

strategy:
matrix:
os: [ ubuntu-latest ]
python-version: [ "3.9" ]

runs-on: ${{ matrix.os }}

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Publish to test PyPI
run: |
poetry version $(git describe --tags --abbrev=0)
poetry config repositories.test-pypi https://test.pypi.org/legacy/
poetry config pypi-token.test-pypi ${{ secrets.TEST_PYPI_TOKEN }}
poetry publish -r test-pypi --build
25 changes: 25 additions & 0 deletions DEVELOP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Publish package to PyPi

Firstly you have to ensure, that package properly builds, publishes and works.
To do this, you must first publish it on https://test.pypi.org

1. Create tag on main branch:
```commandline
git tag <tagname>
```
2. Push created tag to repository
```commandline
git push origin <tagname>
```
After this GitHubActions will automatically build pip package and push it to test PyPi registry
3. Ensure, that installed pip package from https://test.pypi.org works properly
```commandline
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple octreelib==<tagname>
```
4. Publish pip package manually on production PyPi using the following steps:
- Go to Actions page
- Go to "Publish pip on PyPi" workflow on left side of the screen
- Go to "Run workflow" and choose last tag which has been created from tags
- Click "Run workflow"

After this GitHubActions will automatically build pip package and push it to test production registry
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ in the same grid synchronizing their subdivision schemes.
To install the latest version of the library, run

```shell
pip install git+https://github.com/prime-slam/octreelib
pip install octreelib
```

To install a specific version, use **tags**, for example tag `v0.0.3`
To install a specific version, use **tags**, for example tag `0.0.1`

```shell
pip install git+https://github.com/prime-slam/octreelib@v0.0.3
pip install octreelib==0.0.1
```

35 changes: 26 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
[project]
[tool.poetry]
name = "octreelib"
dynamic = ["dependencies"]
version = "0.0.5"
version = "0.0.0"
description = "Library for representing point clouds as OcTrees in SLAM"
authors = [
"Kiselyov Mikhail <[email protected]>",
"Pavel Mokeev <[email protected]>"
]
license = "APACHE"
readme = "README.md"
homepage = "https://github.com/prime-slam/"
repository = "https://github.com/prime-slam/octreelib"
classifiers = [
"License :: OSI Approved :: Apache Software License",
"Intended Audience :: Developers",
"Topic :: Software Development :: Libraries :: Python Modules",
]
exclude = ["test"]
true-real-michael marked this conversation as resolved.
Show resolved Hide resolved

[tool.setuptools]
include-package-data = false
[tool.poetry.dependencies]
python = "^3.9.0"
numpy = "^1.26.0"
k3d = "^2.16.0"

[tool.setuptools.dynamic]
dependencies = { file = ["requirements.txt"] }
[tool.poetry.dev-dependencies]
pytest = "^7.4.2"

[tool.setuptools.packages.find]
exclude = ["test*"]
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
Loading