Skip to content

Commit

Permalink
Merge pull request #694 from KnowledgeCaptureAndDiscovery/dev
Browse files Browse the repository at this point in the history
Fix issues about poetry deployment. Update Docker image
  • Loading branch information
dgarijo authored Jan 31, 2025
2 parents 3e74841 + 06b2c43 commit 458a159
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 142 deletions.
41 changes: 22 additions & 19 deletions .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
# This workflows will upload a Python Package using Twine when a release is created
# This workflows will upload a Python Package using poetry when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Publish SOMEF package to PyPi
name: Publish SOMEF package to PyPI

on:
release:
types: [created]

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.x"
- name: Install Poetry
run: curl -sSL https://install.python-poetry.org | python3 -
- name: Update version
run: python update_version.py
- name: Install dependencies
run: poetry install
- name: Configure Poetry for PyPI
run: |
poetry config pypi-token.pypi ${{ secrets.PYPI_PASSWORD }}
- name: Build and publish
run: |
poetry build
poetry publish
18 changes: 15 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
from python:3.10
FROM python:3.10

RUN git clone https://github.com/KnowledgeCaptureAndDiscovery/somef

RUN cd somef && pip install .
RUN curl -sSL https://install.python-poetry.org | python3 -

RUN pip install poetry-plugin-shell

WORKDIR "/somef"

RUN poetry install

RUN poetry run somef configure -a

RUN echo 'source $(poetry env info --path)/bin/activate' >> ~/.bashrc


CMD ["bash", "--login"]

RUN somef configure -a
30 changes: 5 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,51 +124,31 @@ Clone this GitHub repository
git clone https://github.com/KnowledgeCaptureAndDiscovery/somef.git
```

For better dependency management, it is necessary to have Poetry installed beforehand. It can be installed as follows:
We use [Poetry](https://python-poetry.org/) to ensure library compatibility. It can be installed as follows:

```
curl -sSL https://install.python-poetry.org | python3 -
```

This option is recommended over installing Poetry with pip install.

Now Poetry will handle the installation of SOMEF and all its dependencies configured in the TOML file.
Now Poetry will handle the installation of SOMEF and all its dependencies configured in the `toml` file.

Test the correct installation of poetry
To test the correct installation of poetry run:

```
poetry --version
```

We can first review the list of libraries and dependencies configured as necessary for the operation.

```
poetry show
```

Install somef and all their dependencies.

```
cd /somef
poetry install
```

With the following instruction, we can see the environments available in the project and which one is currently active.

```
poetry env list
```

Now we need to access our virtual environment, to do so you have to install the [poetry plugin shell](https://github.com/python-poetry/poetry-plugin-shell) and run the following possible commands:
Now we need to access our virtual environment, to do so you have to install the [poetry plugin shell](https://github.com/python-poetry/poetry-plugin-shell) and run the following command:

- If you want to install the `shell` plugin is via the `self add` command of Poetry
```
poetry self add poetry-plugin-shell
```
- or if you used pipx to install Poetry:
```
pipx inject poetry poetry-plugin-shell
```
- otherwise if you used pip install:
```
pip install poetry-plugin-shell
```
Expand Down
4 changes: 2 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[tool.poetry]
name = "somef"
version = "0.9.6"
version = "0.9.7"
description = "SOftware Metadata Extraction Framework: A tool for automatically extracting relevant software information from readme files."
authors = ["Daniel Garijo <[email protected]>"]
packages = [
{ include = "somef", from = "src" }
]
classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Operating System :: OS Independent",
"License :: OSI Approved :: MIT License",
"Topic :: Software Development :: Libraries :: Python Modules"
Expand All @@ -20,7 +20,7 @@ bs4 = "^0.0.1"
click = "^8.1.7"
click-option-group = "^0.5.6"
matplotlib = "^3.8.2"
nltk = "^3.8.1"
nltk = "^3.9.0"
numpy = "^1.26.3"
pandas = "^2.1.4"
rdflib = "^7.0.0"
Expand All @@ -41,8 +41,6 @@ rdflib-jsonld = "^0.6.2"
requests = "^2.31.0"
scikit-learn = "1.3.2"

[tool.poetry.dev-dependencies]

[tool.poetry.scripts]
somef = "somef.__main__:cli"

Expand Down
85 changes: 0 additions & 85 deletions setup.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/somef/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-

__version__ = "0.9.6"
__version__ = "0.9.7"
2 changes: 1 addition & 1 deletion src/somef/test/test_data/repositories/RDFChess/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.21</version>
<version>1.26.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jdom/jdom -->
<!-- https://mvnrepository.com/artifact/jdom/jdom -->
Expand Down
4 changes: 3 additions & 1 deletion src/somef/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@

# list of those categories to be analyzed with supervised classification.
# supervised_categories = [CAT_DESCRIPTION, CAT_CITATION, CAT_INSTALLATION, CAT_INVOCATION]
supervised_categories = [CAT_DESCRIPTION, CAT_INSTALLATION, CAT_INVOCATION]
# update jan 2025: only description is run, since the installation classifier is a bit noisy.
# we prioritize returning high precision, since some users get confused otherwise.
supervised_categories = [CAT_DESCRIPTION]

# list with all categories
all_categories = [CAT_APPLICATION_DOMAIN, CAT_ACKNOWLEDGEMENT, CAT_CITATION, CAT_CONTRIBUTORS,
Expand Down
30 changes: 30 additions & 0 deletions update_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import re

def get_version(file_path):
"""get version file __init__.py .
Args:
file_path (str): __init__py.
Returns:
str: version.
"""

with open(file_path, 'r') as f:
for line in f:
if line.startswith('__version__'):
return line.split('=')[1].strip().strip('"')


def update_version(toml_path, version_file):
with open(toml_path, 'r') as f:
content = f.read()

new_version = get_version(version_file)
new_content = content.replace("{version-file}", new_version)

with open(toml_path, 'w') as f:
f.write(new_content)


update_version("pyproject.toml", "src/somef/__init__.py")

0 comments on commit 458a159

Please sign in to comment.