-
-
Notifications
You must be signed in to change notification settings - Fork 2
feat: implement optional dependencies and modernize packaging (issue #96) #119
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
95160f9
feat: implement optional dependencies and modernize packaging (issue …
httpdss e7e4083
feat: add auto-version update job to publish-pypi workflow
httpdss 41977fb
chore: update pyproject.toml
httpdss 6476a36
chore: update publish workflow
httpdss 15be719
chore: update publish workflow
httpdss 8da11ac
chore: add dist folder to .gitignore
httpdss 5110805
chore: remove dist folder
httpdss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,103 @@ | ||||||||
| name: publish-pypi | ||||||||
|
|
||||||||
| on: | ||||||||
| release: | ||||||||
| types: [published] | ||||||||
| workflow_dispatch: | ||||||||
| inputs: | ||||||||
| upload: | ||||||||
| description: 'Upload to PyPI' | ||||||||
| required: false | ||||||||
| default: 'true' | ||||||||
|
|
||||||||
| jobs: | ||||||||
| update-version: | ||||||||
| runs-on: ubuntu-latest | ||||||||
| permissions: | ||||||||
| contents: write | ||||||||
| if: github.event_name == 'release' | ||||||||
|
|
||||||||
| steps: | ||||||||
| - uses: actions/checkout@v5 | ||||||||
| with: | ||||||||
| ref: main | ||||||||
|
|
||||||||
| - name: Extract version from tag | ||||||||
| id: version | ||||||||
| run: | | ||||||||
| VERSION=${{ github.event.release.tag_name }} | ||||||||
| VERSION=${VERSION#v} # Remove 'v' prefix if present | ||||||||
| echo "version=$VERSION" >> $GITHUB_OUTPUT | ||||||||
|
|
||||||||
| - name: Update pyproject.toml | ||||||||
| run: | | ||||||||
| sed -i 's/version = "[^"]*"/version = "${{ steps.version.outputs.version }}"/' pyproject.toml | ||||||||
|
|
||||||||
| - name: Commit and push version update | ||||||||
| run: | | ||||||||
| git config user.name "github-actions[bot]" | ||||||||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||||||||
| git add pyproject.toml | ||||||||
| git commit -m "chore: bump version to ${{ steps.version.outputs.version }}" | ||||||||
| git push origin main | ||||||||
|
|
||||||||
| build: | ||||||||
| needs: update-version | ||||||||
| runs-on: ubuntu-latest | ||||||||
|
|
||||||||
| steps: | ||||||||
| - uses: actions/checkout@v5 | ||||||||
|
|
||||||||
|
||||||||
| with: | |
| ref: main |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ __pycache__ | |
| *.log | ||
| example_project/ | ||
| build/* | ||
| dist/ | ||
|
|
||
| # MkDocs generated documentation | ||
| site/docs/ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| [build-system] | ||
| requires = ["setuptools>=65.0", "wheel"] | ||
| build-backend = "setuptools.build_meta" | ||
|
|
||
| [project] | ||
| name = "struct" | ||
| version = "1.0.0" | ||
| description = "A structured data processing tool" | ||
| readme = "README.md" | ||
| license = {text = "MIT"} | ||
| authors = [{name = "httpdss"}] | ||
| classifiers = [ | ||
| "Development Status :: 4 - Beta", | ||
| "Intended Audience :: Developers", | ||
| "License :: OSI Approved :: MIT License", | ||
| "Programming Language :: Python :: 3", | ||
| "Programming Language :: Python :: 3.8", | ||
| "Programming Language :: Python :: 3.9", | ||
| "Programming Language :: Python :: 3.10", | ||
| "Programming Language :: Python :: 3.11", | ||
| "Programming Language :: Python :: 3.12", | ||
| ] | ||
| requires-python = ">=3.8" | ||
| keywords = ["data", "structure", "processing"] | ||
|
|
||
| dependencies = [ | ||
| "PyYAML>=6.0", | ||
| "requests>=2.28.0", | ||
| "openai>=1.0.0", | ||
| "python-dotenv>=0.21.0", | ||
| "jinja2>=3.1.0", | ||
| "PyGithub>=1.58.0", | ||
| "shtab>=1.6.0", | ||
| "colorlog>=6.7.0", | ||
| "pydantic-ai>=0.1.0", | ||
| "fastmcp>=2.0.0", | ||
| ] | ||
|
|
||
| [project.optional-dependencies] | ||
| s3 = [ | ||
| "boto3>=1.26.0", | ||
| ] | ||
| gcs = [ | ||
| "google-cloud-storage>=2.10.0", | ||
| "google-api-core>=2.11.0", | ||
| ] | ||
| cloud = [ | ||
| "struct[s3]", | ||
| "struct[gcs]" | ||
| ] | ||
| dev = [ | ||
| "pytest>=7.0.0", | ||
| "pytest-cov>=4.0.0", | ||
| "black>=22.0.0", | ||
| "flake8>=4.0.0", | ||
| "mypy>=0.990", | ||
| ] | ||
|
|
||
| [project.urls] | ||
| Homepage = "https://github.com/httpdss/struct" | ||
| Repository = "https://github.com/httpdss/struct.git" | ||
|
|
||
| [project.scripts] | ||
| struct = "struct_module.main:main" | ||
|
|
||
| [tool.setuptools] | ||
| include-package-data = true | ||
|
|
||
| [tool.setuptools.packages.find] | ||
| where = ["."] # Look for packages in root directory | ||
| include = ["struct_module*"] | ||
|
|
||
| [tool.setuptools.package-data] | ||
| struct_module = ["contribs/*.yaml"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,23 @@ | ||
| PyYAML | ||
| requests | ||
| openai | ||
| python-dotenv | ||
| jinja2 | ||
| PyGithub | ||
| shtab | ||
| colorlog | ||
| boto3 | ||
| google-cloud | ||
| google-api-core | ||
| cachetools | ||
| pydantic-ai | ||
| fastmcp>=2.0 | ||
| # Core dependencies (always installed) | ||
| PyYAML>=6.0 | ||
| requests>=2.28.0 | ||
| openai>=1.0.0 | ||
| python-dotenv>=0.21.0 | ||
| jinja2>=3.1.0 | ||
| PyGithub>=1.58.0 | ||
| shtab>=1.6.0 | ||
| colorlog>=6.7.0 | ||
| pydantic-ai>=0.1.0 | ||
| fastmcp>=2.0.0 | ||
|
|
||
| # Optional: AWS S3 support | ||
| # Install with: pip install struct[s3] | ||
| # boto3>=1.26.0 | ||
|
|
||
| # Optional: Google Cloud Storage support | ||
| # Install with: pip install struct[gcs] | ||
| # google-cloud-storage>=2.10.0 | ||
| # google-api-core>=2.11.0 | ||
|
|
||
| # Optional: Both cloud providers | ||
| # Install with: pip install struct[cloud] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,5 @@ | ||
| from setuptools import setup, find_packages | ||
| # This file is maintained only for backwards compatibility. | ||
| # Configuration is now in pyproject.toml (PEP 517/518). | ||
| from setuptools import setup | ||
|
|
||
| def parse_requirements(filename): | ||
| with open(filename, 'r') as file: | ||
| lines = file.readlines() | ||
| return [line.strip() for line in lines if line and not line.startswith('#')] | ||
|
|
||
| setup( | ||
| name='struct', | ||
| version='1.0.0', | ||
| packages=find_packages(), | ||
| install_requires=parse_requirements('requirements.txt'), | ||
| entry_points={ | ||
| 'console_scripts': [ | ||
| 'struct = struct_module.main:main', | ||
| ], | ||
| }, | ||
| include_package_data=True, | ||
| package_data={ | ||
| '': ['struct_module/contribs/*.yaml'], | ||
| }, | ||
| ) | ||
| setup() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 'build' job has an unconditional dependency on 'update-version', but 'update-version' only runs when 'github.event_name == release'. For workflow_dispatch events, the 'build' job will be skipped because its dependency never runs. Either make the 'needs' conditional or ensure 'update-version' runs for both event types.