Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

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

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
16 changes: 6 additions & 10 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,15 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
- uses: actions/checkout@v5
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
python-version: '3.14'
- name: Build and publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
uv build
uvx twine upload dist/*
59 changes: 22 additions & 37 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,30 @@ on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
create:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
- uses: actions/checkout@v5
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: "3.13"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install nox
- name: Run linting
run: nox --session lint
run: uvx nox --session lint

typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
- uses: actions/checkout@v5
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: "3.13"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install nox
- name: Run type checking
run: nox --session typecheck
run: uvx nox --session typecheck

build:

Expand All @@ -61,23 +53,20 @@ jobs:
- os: windows-latest
python-version: "3.11"
pandas-version: "2.3.3"
- os: windows-latest
python-version: "3.14"
pandas-version: "2.3.3"


steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
- uses: actions/checkout@v5
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[spark]
pip check
pip install nox
- name: Run unit tests
run: |
nox --session "tests(python='${{ matrix.python-version }}', pandas='${{ matrix.pandas-version }}')"
uvx nox --session "tests(python='${{ matrix.python-version }}', pandas='${{ matrix.pandas-version }}')"
env:
TD_API_KEY: 1/XXX
TD_API_SERVER: https://api.treasure-data.com/
Expand All @@ -87,16 +76,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
- uses: actions/checkout@v5
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
python-version: '3.14'
- name: Build and check dist for PyPI (a.k.a dry run)
run: |
python -m build
twine check dist/*
uv build
uvx twine check dist/*
18 changes: 18 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,24 @@ Consequently, all ``pandas_td`` code should keep running correctly with
`here <https://github.com/treasure-data/pytd/issues/new>`__ if you
noticed any incompatible behaviors.

Development
-----------

For contributors, please see `Contributing Guide <https://pytd-doc.readthedocs.io/en/latest/contributing.html>`__.

This project uses `uv <https://docs.astral.sh/uv/>`__ for fast Python package management:

.. code:: sh

# Install uv
pip install uv

# Sync dependencies
uv sync

# Run tests with nox
uvx nox

.. |Build status| image:: https://github.com/treasure-data/pytd/workflows/Build/badge.svg
:target: https://github.com/treasure-data/pytd/actions/
.. |PyPI version| image:: https://badge.fury.io/py/pytd.svg
Expand Down
89 changes: 57 additions & 32 deletions doc/contributing.rst
Original file line number Diff line number Diff line change
@@ -1,52 +1,77 @@
Contributing to pytd
====================

Code Formatting and Testing
---------------------------
Development Setup
-----------------

We use `black <https://black.readthedocs.io/en/stable/>`__ and
`isort <https://github.com/timothycrosley/isort>`__ as a formatter, and
`flake8 <http://flake8.pycqa.org/en/latest/>`__ as a linter. Our CI
checks format with them.
This project uses `uv <https://docs.astral.sh/uv/>`__ for fast and reliable Python package management.

Note that black requires Python 3.6+ while pytd supports 3.5+, so you
must need to have Python 3.6+ for development.
Installing uv
~~~~~~~~~~~~~

We highly recommend you to introduce
`pre-commit <https://pre-commit.com/>`__ to ensure your commit follows
required format.
.. code:: sh

You can install pre-commit as follows:
# On macOS and Linux:
curl -LsSf https://astral.sh/uv/install.sh | sh

# On Windows:
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"

# Or via pip:
pip install uv

Setting Up Development Environment
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code:: sh

pip install pre-commit
pre-commit install
# Clone the repository
git clone https://github.com/treasure-data/pytd.git
cd pytd

Now, black, isort, and flake8 will check each time you commit changes.
You can skip these check with ``git commit --no-verify``.
# Sync dependencies (installs everything from uv.lock)
uv sync

If you want to check code format manually, you can install them as
follows:
# Run commands in the uv-managed environment
uv run python --version
uv run pytest

.. code:: sh
Code Formatting and Testing
----------------------------

We use `ruff <https://docs.astral.sh/ruff/>`__ for linting and formatting,
and `pyright <https://github.com/microsoft/pyright>`__ for type checking.

pip install black isort flake8
We use `nox <https://nox.thea.codes/>`__ to run tests and checks. Nox is configured
to use uv as the backend for fast virtual environment creation and package installation.

Then, you can run those tool manually;
You can run formatter, linter, and tests by using nox:

.. code:: sh

black pytd
flake8 pytd
isort
# Run all sessions
uvx nox

# Run specific sessions
uvx nox --session lint
uvx nox --session typecheck
uvx nox --session tests

You can run formatter, linter, and test by using nox as the following:
Pre-commit Hooks
~~~~~~~~~~~~~~~~

We highly recommend you to introduce
`pre-commit <https://pre-commit.com/>`__ to ensure your commit follows
required format.

You can install and set up pre-commit as follows:

.. code:: sh

pip install nox # You should install at the first time
nox
uvx pre-commit install

Now, ruff and other checks will run each time you commit changes.
You can skip these checks with ``git commit --no-verify``.

Documenting
-----------
Expand All @@ -72,13 +97,13 @@ The ``doc/`` folder is monitored and automatically published by `Read the Docs <
Releasing
---------

Update version in ``setup.cfg``. Set it to ``1.0.0``, for example:
Update version in ``pyproject.toml``. Set it to ``1.0.0``, for example:

.. code:: ini
.. code:: toml

[metadata]
name = pytd
version = 1.0.0
[project]
name = "pytd"
version = "1.0.0"

Commit and push the latest code, and tag the version:

Expand Down
2 changes: 2 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import nox

nox.options.default_venv_backend = "uv"


@nox.session
def lint(session):
Expand Down
Loading
Loading