Skip to content

Commit d8cba03

Browse files
authored
Merge pull request #22 from sumanjeet0012/feat/modernize-setup
Modernize repository setup: migrate to pyproject.toml, Python 3.10+, GitHub Actions
2 parents 4958443 + bd816d0 commit d8cba03

32 files changed

+2084
-986
lines changed

.github/workflows/tox.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Run tox
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
9+
defaults:
10+
run:
11+
shell: bash
12+
13+
jobs:
14+
tox:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
19+
toxenv: [core, lint]
20+
include:
21+
- python-version: "3.10"
22+
toxenv: docs
23+
fail-fast: false
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: actions/setup-python@v5
27+
with:
28+
python-version: ${{ matrix.python-version }}
29+
- name: Set TOXENV
30+
run: |
31+
if [[ "${{ matrix.toxenv }}" == "docs" ]]; then
32+
echo "TOXENV=docs" >> "$GITHUB_ENV"
33+
else
34+
python_version="${{ matrix.python-version }}"
35+
echo "TOXENV=py${python_version//./}-${{ matrix.toxenv }}" >> "$GITHUB_ENV"
36+
fi
37+
- run: |
38+
python -m pip install --upgrade pip
39+
python -m pip install "tox>=4.10"
40+
- run: |
41+
python -m tox run -e "$TOXENV" -r
42+
43+
windows:
44+
runs-on: windows-latest
45+
strategy:
46+
matrix:
47+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
48+
toxenv: [core, lint]
49+
fail-fast: false
50+
steps:
51+
- uses: actions/checkout@v4
52+
- name: Set up Python ${{ matrix.python-version }}
53+
uses: actions/setup-python@v5
54+
with:
55+
python-version: ${{ matrix.python-version }}
56+
- name: Set TOXENV
57+
shell: bash
58+
run: |
59+
python_version="${{ matrix.python-version }}"
60+
echo "TOXENV=py${python_version//./}-${{ matrix.toxenv }}" >> "$GITHUB_ENV"
61+
- name: Install dependencies
62+
run: |
63+
python -m pip install --upgrade pip
64+
python -m pip install "tox>=4.10"
65+
- name: Test with tox
66+
shell: bash
67+
run: |
68+
python -m tox run -e "$TOXENV" -r

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ __pycache__/
99
# Distribution / packaging
1010
.Python
1111
env/
12+
venv/
1213
build/
1314
develop-eggs/
1415
dist/

.pre-commit-config.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
exclude: '.project-template|docs/conf.py|.*pb2\..*'
2+
repos:
3+
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
rev: v5.0.0
5+
hooks:
6+
- id: check-yaml
7+
- id: check-toml
8+
- id: end-of-file-fixer
9+
- id: trailing-whitespace
10+
- repo: https://github.com/asottile/pyupgrade
11+
rev: v3.15.0
12+
hooks:
13+
- id: pyupgrade
14+
args: [--py310-plus]
15+
- repo: https://github.com/astral-sh/ruff-pre-commit
16+
rev: v0.11.10
17+
hooks:
18+
- id: ruff
19+
args: [--fix, --exit-non-zero-on-fix]
20+
- id: ruff-format
21+
- repo: local
22+
hooks:
23+
- id: mypy-local
24+
name: run mypy with all dev dependencies present
25+
entry: mypy -p multicodec
26+
language: system
27+
always_run: true
28+
pass_filenames: false
29+
require_serial: false

.readthedocs.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Read the Docs configuration file for Sphinx projects
2+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3+
4+
version: 2
5+
6+
build:
7+
os: ubuntu-24.04
8+
tools:
9+
python: "3.10"
10+
11+
sphinx:
12+
configuration: docs/conf.py
13+
fail_on_warning: true
14+
15+
python:
16+
install:
17+
- method: pip
18+
path: .
19+
extra_requirements:
20+
- dev
21+
22+
formats:
23+
- epub
24+
- htmlzip

.readthedocs.yml

Lines changed: 0 additions & 4 deletions
This file was deleted.

.travis.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

CONTRIBUTING.rst

Lines changed: 59 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,38 +59,77 @@ Get Started!
5959

6060
Ready to contribute? Here's how to set up `multicodec` for local development.
6161

62-
1. Fork the `multicodec` repo on GitHub.
62+
1. Fork the `py-multicodec` repo on GitHub.
6363
2. Clone your fork locally::
6464

65-
$ git clone [email protected]:your_name_here/multicodec.git
65+
$ git clone [email protected]:your_name_here/py-multicodec.git
6666

67-
3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development::
67+
3. Install your local copy into a virtualenv. Create and activate a virtual environment::
6868

69-
$ mkvirtualenv multicodec
70-
$ cd multicodec/
71-
$ python setup.py develop
69+
$ python -m venv venv
70+
$ source venv/bin/activate # On Windows: venv\Scripts\activate
71+
$ pip install -e ".[dev]"
7272

73-
4. Create a branch for local development::
73+
4. Install pre-commit hooks (optional but recommended)::
74+
75+
$ pre-commit install
76+
77+
This will set up git hooks to automatically run linting and formatting checks
78+
before each commit.
79+
80+
5. Create a branch for local development::
7481

7582
$ git checkout -b name-of-your-bugfix-or-feature
7683

7784
Now you can make your changes locally.
7885

79-
5. When you're done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox::
86+
6. When you're done making changes, check that your changes pass linting and the
87+
tests, including testing other Python versions with tox::
8088

81-
$ flake8 multicodec tests
82-
$ python setup.py test or py.test
89+
$ make lint
90+
$ make test
8391
$ tox
8492

85-
To get flake8 and tox, just pip install them into your virtualenv.
93+
Or run pre-commit manually on all files::
94+
95+
$ pre-commit run --all-files
96+
97+
If you installed pre-commit hooks (step 4), they will run automatically on commit.
98+
99+
Development Workflow Commands
100+
-------------------------------
101+
102+
The project provides several ``make`` targets to help with development:
103+
104+
* ``make fix`` - Automatically fix formatting and linting issues using ruff.
105+
Use this when you want to auto-fix code style issues.
86106

87-
6. Commit your changes and push your branch to GitHub::
107+
* ``make lint`` - Run all pre-commit hooks on all files to check for code quality
108+
issues. This includes YAML/TOML validation, trailing whitespace checks, pyupgrade,
109+
ruff linting and formatting, and mypy type checking.
110+
111+
* ``make typecheck`` - Run mypy type checking only. Use this when you want to
112+
quickly check for type errors without running all other checks.
113+
114+
* ``make test`` - Run the test suite with pytest using the default Python version.
115+
For testing across multiple Python versions, use ``tox`` instead.
116+
117+
* ``make pr`` - Run a complete pre-PR check: clean build artifacts, fix formatting,
118+
run linting, type checking, and tests. This is the recommended command to run
119+
before submitting a pull request.
120+
121+
* ``make coverage`` - Run tests with coverage reporting and open the HTML report
122+
in your browser.
123+
124+
For a full list of available commands, run ``make help``.
125+
126+
7. Commit your changes and push your branch to GitHub::
88127

89128
$ git add .
90129
$ git commit -m "Your detailed description of your changes."
91-
$ git push origin name-of-your-bugfix-or-feature
130+
$ git push -u origin name-of-your-bugfix-or-feature
92131

93-
7. Submit a pull request through the GitHub website.
132+
8. Submit a pull request through the GitHub website.
94133

95134
Pull Request Guidelines
96135
-----------------------
@@ -101,14 +140,17 @@ Before you submit a pull request, check that it meets these guidelines:
101140
2. If the pull request adds functionality, the docs should be updated. Put
102141
your new functionality into a function with a docstring, and add the
103142
feature to the list in README.rst.
104-
3. The pull request should work for Python 2.6, 2.7, 3.3, 3.4 and 3.5, and for PyPy. Check
105-
https://travis-ci.org/multiformats/py-multicodec/pull_requests
143+
3. The pull request should work for Python 3.10, 3.11, 3.12, 3.13, and 3.14. Check
144+
https://github.com/multiformats/py-multicodec/actions
106145
and make sure that the tests pass for all supported Python versions.
107146

108147
Tips
109148
----
110149

111150
To run a subset of tests::
112151

113-
$ py.test tests.test_multicodec
152+
$ pytest tests/test_multicodec.py
153+
154+
To run tests with coverage::
114155

156+
$ make coverage

LICENSE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
88
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
99

1010
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11-

0 commit comments

Comments
 (0)