Skip to content

Commit ed258d2

Browse files
committed
Initial SDK release
1 parent d31caeb commit ed258d2

File tree

147 files changed

+50347
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+50347
-0
lines changed

.github/workflows/publish.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Publish workflow for xdk-python
2+
# Triggered by the generator repo via repository_dispatch
3+
# Also supports manual triggering for hotfixes
4+
5+
name: Publish to PyPI
6+
7+
on:
8+
repository_dispatch:
9+
types: [release]
10+
11+
workflow_dispatch:
12+
inputs:
13+
version:
14+
description: 'Version to publish (must match pyproject.toml)'
15+
required: true
16+
type: string
17+
18+
jobs:
19+
publish:
20+
name: Build and Publish
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: write
24+
id-token: write # Required for PyPI trusted publishing
25+
environment:
26+
name: pypi
27+
url: https://pypi.org/project/xdk/
28+
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
- name: Get version
33+
id: version
34+
run: |
35+
if [ "${{ github.event_name }}" = "repository_dispatch" ]; then
36+
VERSION="${{ github.event.client_payload.version }}"
37+
else
38+
VERSION="${{ inputs.version }}"
39+
fi
40+
echo "version=$VERSION" >> $GITHUB_OUTPUT
41+
echo "📦 Publishing version: $VERSION"
42+
43+
- name: Verify version matches pyproject.toml
44+
run: |
45+
TOML_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
46+
if [ "$TOML_VERSION" != "${{ steps.version.outputs.version }}" ]; then
47+
echo "❌ Version mismatch!"
48+
echo " pyproject.toml: $TOML_VERSION"
49+
echo " Requested: ${{ steps.version.outputs.version }}"
50+
exit 1
51+
fi
52+
echo "✅ Version verified: $TOML_VERSION"
53+
54+
- name: Set up Python
55+
uses: actions/setup-python@v5
56+
with:
57+
python-version: '3.11'
58+
59+
- name: Install build tools
60+
run: pip install build
61+
62+
- name: Build package
63+
run: |
64+
python -m build
65+
echo "📦 Built packages:"
66+
ls -la dist/
67+
68+
- name: Publish to PyPI
69+
uses: pypa/gh-action-pypi-publish@release/v1
70+
with:
71+
packages-dir: dist/
72+
73+
- name: Create Git tag
74+
run: |
75+
git config user.name "github-actions[bot]"
76+
git config user.email "github-actions[bot]@users.noreply.github.com"
77+
git tag -a "v${{ steps.version.outputs.version }}" -m "Release v${{ steps.version.outputs.version }}"
78+
git push origin "v${{ steps.version.outputs.version }}"
79+
80+
- name: Create GitHub Release
81+
uses: softprops/action-gh-release@v2
82+
with:
83+
tag_name: v${{ steps.version.outputs.version }}
84+
name: v${{ steps.version.outputs.version }}
85+
generate_release_notes: true
86+
draft: false
87+
prerelease: ${{ contains(steps.version.outputs.version, 'beta') || contains(steps.version.outputs.version, 'alpha') }}
88+
files: |
89+
dist/*
90+
91+
- name: Summary
92+
run: |
93+
echo "# 🎉 Published to PyPI" >> $GITHUB_STEP_SUMMARY
94+
echo "" >> $GITHUB_STEP_SUMMARY
95+
echo "**Version:** \`${{ steps.version.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY
96+
echo "" >> $GITHUB_STEP_SUMMARY
97+
echo "## Install" >> $GITHUB_STEP_SUMMARY
98+
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
99+
echo "pip install xdk==${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
100+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
101+
echo "" >> $GITHUB_STEP_SUMMARY
102+
echo "## Links" >> $GITHUB_STEP_SUMMARY
103+
echo "- [PyPI](https://pypi.org/project/xdk/${{ steps.version.outputs.version }}/)" >> $GITHUB_STEP_SUMMARY
104+
echo "- [GitHub Release](https://github.com/${{ github.repository }}/releases/tag/v${{ steps.version.outputs.version }})" >> $GITHUB_STEP_SUMMARY
105+

.github/workflows/test.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Test workflow for xdk-python
2+
# Runs on every push and pull request
3+
4+
name: Test
5+
6+
on:
7+
push:
8+
branches: [main]
9+
pull_request:
10+
branches: [main]
11+
12+
jobs:
13+
test:
14+
name: Test Python ${{ matrix.python-version }}
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Set up Python ${{ matrix.python-version }}
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
29+
- name: Install uv
30+
uses: astral-sh/setup-uv@v3
31+
32+
- name: Install dependencies
33+
run: uv sync
34+
35+
- name: Run linter
36+
run: uv run ruff check xdk/
37+
38+
- name: Run type checker
39+
run: uv run mypy xdk/ --ignore-missing-imports
40+
continue-on-error: true # Don't fail on type errors for now
41+
42+
- name: Run tests
43+
run: uv run pytest tests/ -v --tb=short
44+
45+
- name: Run tests with coverage
46+
if: matrix.python-version == '3.11'
47+
run: uv run pytest tests/ -v --cov=xdk --cov-report=xml
48+
49+
- name: Upload coverage
50+
if: matrix.python-version == '3.11'
51+
uses: codecov/codecov-action@v4
52+
with:
53+
files: coverage.xml
54+
fail_ci_if_error: false
55+

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<!--
2+
AUTO-GENERATED FILE - DO NOT EDIT
3+
This file was automatically generated by the XDK build tool.
4+
-->
5+
# XDK Python SDK
6+
7+
<!--
8+
Auto-generated README for the X API Python SDK.
9+
10+
This file contains the documentation and usage examples
11+
for the generated Python SDK package.
12+
13+
Generated automatically - do not edit manually.
14+
-->
15+
16+
A Python SDK for the X API.
17+
18+
## Installation
19+
20+
```bash
21+
uv add xdk
22+
```
23+
24+
Or with pip:
25+
```bash
26+
pip install xdk
27+
```
28+
29+
## Usage
30+
31+
```python
32+
from xdk import Client
33+
34+
# Initialize the client
35+
client = Client(
36+
api_key="your_api_key",
37+
api_secret="your_api_secret",
38+
access_token="your_access_token",
39+
access_token_secret="your_access_token_secret"
40+
)
41+
42+
# Use the client to interact with the X API
43+
# For example, to get posts:
44+
posts = client.posts.get(ids=["1234567890"])
45+
46+
# To search for posts:
47+
search_results = client.posts.recent_search(query="python")
48+
49+
# To post a post:
50+
post = client.posts.create(post_data={"text": "Hello, world!"})
51+
```
52+
53+
## Features
54+
55+
- Full support for the X API v2
56+
- Simple and intuitive interface
57+
- Comprehensive documentation
58+
- Type hints for better IDE support
59+
60+
## Documentation
61+
62+
For more information, see the [documentation](https://docs.x.com/xdks/python/overview).
63+
64+
## License
65+
66+
This project is licensed under the MIT License - see the LICENSE file for details.

conf.py

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# AUTO-GENERATED FILE - DO NOT EDIT
2+
# This file was automatically generated by the XDK build tool.
3+
# Any manual changes will be overwritten on the next generation.
4+
# AUTO-GENERATED FILE - DO NOT EDIT
5+
# This file was automatically generated by the XDK build tool.
6+
# Any manual changes will be overwritten on the next generation.
7+
8+
# Configuration file for the Sphinx documentation builder.
9+
#
10+
# For the full list of built-in configuration values, see the documentation:
11+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
12+
13+
import sys
14+
from pathlib import Path
15+
16+
# Add the xdk package to the path so autodoc can find it
17+
sys.path.insert(0, str(Path(__file__).parent.parent))
18+
19+
# -- Project information -----------------------------------------------------
20+
21+
project = "X API SDK"
22+
copyright = "2024, X Developer Platform"
23+
author = "X Developer Platform"
24+
release = "0.2.3-beta"
25+
version = "0.2.3-beta"
26+
27+
# -- General configuration ----------------------------------------------------
28+
29+
extensions = [
30+
"sphinx.ext.autodoc",
31+
"sphinx.ext.autosummary",
32+
"sphinx.ext.viewcode",
33+
"sphinx.ext.napoleon", # Support for Google/NumPy style docstrings
34+
"myst_parser", # Markdown support
35+
]
36+
37+
# Napoleon settings for docstring parsing
38+
napoleon_google_docstring = True
39+
napoleon_numpy_docstring = True
40+
napoleon_include_init_with_doc = False
41+
napoleon_include_private_with_doc = False
42+
napoleon_include_special_with_doc = True
43+
napoleon_use_admonition_for_examples = False
44+
napoleon_use_admonition_for_notes = False
45+
napoleon_use_admonition_for_references = False
46+
napoleon_use_ivar = False
47+
napoleon_use_param = True
48+
napoleon_use_rtype = True
49+
50+
# Autodoc settings
51+
autodoc_default_options = {
52+
"members": True,
53+
"undoc-members": False,
54+
"show-inheritance": True,
55+
"inherited-members": False,
56+
"private-members": False,
57+
"special-members": "__init__",
58+
}
59+
60+
autosummary_generate = True
61+
62+
# MyST parser settings
63+
myst_enable_extensions = [
64+
"colon_fence",
65+
"deflist",
66+
"dollarmath",
67+
"fieldlist",
68+
"html_admonition",
69+
"html_image",
70+
"linkify",
71+
"replacements",
72+
"smartquotes",
73+
"strikethrough",
74+
"substitution",
75+
"tasklist",
76+
]
77+
78+
# Templates path
79+
templates_path = ["_templates"]
80+
81+
# The suffix(es) of source filenames
82+
source_suffix = {
83+
".rst": "restructuredtext",
84+
".md": "markdown",
85+
}
86+
87+
# The master toctree document
88+
master_doc = "index"
89+
90+
# The language for content autogenerated by Sphinx
91+
language = "en"
92+
93+
# -- Options for HTML output --------------------------------------------------
94+
95+
html_theme = "default"
96+
html_static_path = ["_static"]
97+
98+
# -- Options for Markdown output ----------------------------------------------
99+
100+
# Use markdown builder
101+
# This will be set via command line: sphinx-build -b markdown

0 commit comments

Comments
 (0)