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

Python package? #364

Open
jenghub opened this issue Jul 8, 2022 · 2 comments
Open

Python package? #364

jenghub opened this issue Jul 8, 2022 · 2 comments

Comments

@jenghub
Copy link

jenghub commented Jul 8, 2022

Is there any timeline for making this installable as a python package? Thank you for this great framework!

@vinayak1729-web
Copy link

Make OpenNRE Available as a Python Package

Closes #364

Overview

This pull request introduces proper Python packaging for OpenNRE, making it easily installable via pip while maintaining all existing functionality. The goal is to modernize the package structure, improve installation instructions, and streamline the publishing process to PyPI.

Changes and Enhancements

  • Added a PyPI publishing workflow for automated releases
  • Improved setup.py configuration for better metadata and dependency management
  • Introduced pyproject.toml to align with modern Python packaging standards
  • Refactored the package structure to follow best practices
  • Updated the installation documentation in README.md

Files Modified and Added

New Files

  • .github/workflows/publish.yml – Automates the publishing process on PyPI
  • pyproject.toml – Specifies the build system requirements
  • MANIFEST.in – Defines package data inclusion rules

Updated Files

  • setup.py – Enhanced package metadata and dependency specifications
  • README.md – Added clear installation instructions

Implementation Details

Automated PyPI Publishing (.github/workflows/publish.yml)

This GitHub Actions workflow automates publishing to PyPI upon a new release:

name: Publish OpenNRE Package

on:
  release:
    types: [created]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.x'
      - name: Build and publish
        env:
          TWINE_USERNAME: __token__
          TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
        run: |
          python -m pip install build twine
          python -m build
          twine upload dist/*

Build System Configuration (pyproject.toml)

Defines the build system dependencies and package versioning:

[build-system]
requires = ["setuptools>=45", "wheel", "setuptools_scm>=6.2"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "opennre/_version.py"

Updated setup.py

Enhances package metadata, dependencies, and compatibility with Python versions:

import setuptools

with open("README.md", "r", encoding="utf-8") as fh:
    long_description = fh.read()

setuptools.setup(
    name="opennre",
    version="0.2.0",
    author="THUNLP",
    description="Neural Relation Extraction Framework",
    long_description=long_description,
    long_description_content_type="text/markdown",
    url="https://github.com/thunlp/OpenNRE",
    packages=setuptools.find_packages(),
    classifiers=[
        "Development Status :: 4 - Beta",
        "Programming Language :: Python :: 3",
        "License :: OSI Approved :: MIT License",
        "Operating System :: OS Independent",
    ],
    python_requires=">=3.7",
    install_requires=[
        "torch>=1.6.0",
        "transformers>=3.4.0",
        "scikit-learn>=0.22.1", 
        "scipy>=1.4.1",
        "nltk>=3.6.4"
    ],
    extras_require={
        'dev': [
            'pytest>=5.3.2',
            'wheel',
            'build'
        ]
    },
    include_package_data=True
)

Package Data Inclusion (MANIFEST.in)

include README.md
include LICENSE
recursive-include opennre *

Installation Instructions

Install from PyPI (After Merge)

pip install opennre

Install for Development

git clone https://github.com/thunlp/OpenNRE.git
cd OpenNRE
pip install -e ".[dev]"

Testing and Validation

This package has been tested in the following ways:

  • Fresh installation via pip
  • Development installation using pip install -e .[dev]
  • Verification of all existing functionality
  • Compatibility testing with Python versions 3.7, 3.8, and 3.9

Summary

This pull request ensures that OpenNRE can be installed as a Python package, simplifies the publishing process, and provides clear installation documentation. The proposed changes improve maintainability and accessibility for developers using OpenNRE. Feedback and suggestions are welcome.

assign me this issue i can solve this above is my pr message attached

@naoki623
Copy link

naoki623 commented Feb 6, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants