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

Switch to pyproject.toml and poetry #180

Merged
merged 25 commits into from
May 10, 2024
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
23 changes: 23 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Build PyDataverse
on: [push]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
name: Build pyDataverse
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name: Setup Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install Python Dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install poetry

poetry install
8 changes: 8 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: Ruff
on: [push, pull_request]
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
16 changes: 16 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Build and publish

on:
release:
types: [released]

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: "Build and publish to PyPi"
uses: JRubics/[email protected]
with:
pypi_token: ${{ secrets.PYPI_TOKEN }}
17 changes: 7 additions & 10 deletions .github/workflows/test_build.yml → .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@ jobs:
custom_test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [
"3.8",
"3.9",
"3.10",
"3.11"
]
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
name: Test pyDataverse
env:
PORT: 8080
Expand All @@ -28,13 +23,15 @@ jobs:
- name: Install Python Dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -r ./requirements/tests.txt
pip install -e .
python3 -m pip install poetry

poetry install --with tests

- name: Run tests
env:
API_TOKEN_SUPERUSER: ${{ steps.dataverse.outputs.api_token }}
API_TOKEN: ${{ steps.dataverse.outputs.api_token }}
BASE_URL: ${{ steps.dataverse.outputs.base_url }}
DV_VERSION: ${{ steps.dataverse.outputs.dv_version }}
run: |
python3 -m pytest
python3 -m poetry run pytest
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,9 @@ src/pyDataverse/docs/source/_build
src/pyDataverse/docs/Makefile
env-config/
wiki/

# Poetry lock
poetry.lock

# Ruff
.ruff_cache/
54 changes: 28 additions & 26 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
default_language_version:
python: python3
python: python3
exclude: ^migrations/
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
exclude: _pytest/(debugging|hookspec).py
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-docstring-first
- id: check-json
- id: check-symlinks
- id: check-xml
- id: check-yaml
- id: detect-private-key
- id: end-of-file-fixer
- id: pretty-format-json
args: [--autofix,--no-sort-keys]
- repo: https://github.com/psf/black
rev: 19.10b0
- id: check-added-large-files
- id: check-case-conflict
- id: check-docstring-first
- id: check-json
- id: check-symlinks
- id: check-xml
- id: check-yaml
- id: detect-private-key
- id: end-of-file-fixer
- id: pretty-format-json
args: [--autofix, --no-sort-keys]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.4
hooks:
- id: black
language_version: python3.6
- repo: https://github.com/asottile/blacken-docs
- id: ruff
args: [--fix]
- id: ruff-format

- repo: https://github.com/asottile/blacken-docs
rev: v1.7.0
hooks:
- id: blacken-docs
- id: blacken-docs
additional_dependencies: [black==19.10b0]

- repo: https://github.com/codespell-project/codespell
# Configuration for codespell is in setup.cfg
rev: v2.2.6
hooks:
- id: codespell
- repo: https://github.com/codespell-project/codespell
# Configuration for codespell is in setup.cfg
rev: v2.2.6
hooks:
- id: codespell
18 changes: 9 additions & 9 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2
version: 2

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: src/pyDataverse/docs/source/conf.py
configuration: pyDataverse/docs/source/conf.py

# Optionally build your docs in additional formats such as PDF and ePub
formats: all
formats: all

# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.6
install:
- requirements: requirements/docs.txt
- method: pip
path: .
system_packages: true
version: 3.6
install:
- requirements: requirements/docs.txt
- method: pip
path: .
system_packages: true
10 changes: 5 additions & 5 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ you created the branch, check the section on
:ref:`updating a PR <contributing_changes_update-pull-request>`.


From here, you now can move forward to
From here, you now can move forward to

- contribute to the documentation (see below)
- contribute to the :ref:`code base <contributing_code>`
Expand Down Expand Up @@ -267,7 +267,7 @@ Some other important things to know about the docs:
- The pyDataverse documentation consists of two parts:

- the docstrings in the code itself and
- the docs in the folder ``src/pyDataverse/doc/``
- the docs in the folder ``pyDataverse/doc/``

- The docstrings provide a clear explanation of the usage of the individual functions, while the documentation consists of tutorial-like overviews per topic together with some other information (what’s new, installation, this page you're viewing right now, etc).
- The docstrings follow the `Numpy Docstring Standard <https://numpydoc.readthedocs.io/en/latest/format.html>`_.
Expand Down Expand Up @@ -298,7 +298,7 @@ to ``upstream/develop``, so you have to branch-off from it too.

There is one exception: If you
want to suggest a change to the docs in the folder
``src/pyDataverse/docs/`` (e. g. fix a typo in
``pyDataverse/docs/`` (e. g. fix a typo in
:ref:`User Guide - Basic Usage <user_basic-usage>`),
you can also pull to ``upstream/master``. This means, you have also to
branch-off from the ``master`` branch.
Expand Down Expand Up @@ -411,7 +411,7 @@ To run black alone, use

.. code-block:: shell

black src/pyDataverse/file_changed.py
black pyDataverse/file_changed.py


.. _contributing_code_type-hints:
Expand All @@ -430,7 +430,7 @@ type hints. After making any change you can ensure your type hints are correct b

.. code-block:: shell

mypy src/pyDataverse/file_changed.py
mypy pyDataverse/file_changed.py


.. _contributing_code_testing-with-ci:
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
recursive-include src/pyDataverse/schemas *
recursive-include pyDataverse/schemas *
5 changes: 1 addition & 4 deletions src/pyDataverse/__init__.py → pyDataverse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@

from __future__ import absolute_import

import urllib3

urllib3.disable_warnings() # noqa

__author__ = "Stefan Kasberger"
__email__ = "[email protected]"
__copyright__ = "Copyright (c) 2019 Stefan Kasberger"
__license__ = "MIT License"
__version__ = "0.3.1"
__version__ = "0.3.2"
__url__ = "https://github.com/GDCC/pyDataverse"
__download_url__ = "https://pypi.python.org/pypi/pyDataverse"
__description__ = "A Python module for Dataverse."
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import os
import sys

sys.path.insert(0, os.path.abspath("../../.."))
sys.path.insert(0, os.path.abspath("../.."))

project = "pyDataverse"
author = "Stefan Kasberger"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Prepare

**Additional Resources**

- CSV templates from ``src/pyDataverse/templates/`` are used (see :ref:`CSV templates <user_csv-templates>`)
- CSV templates from ``pyDataverse/templates/`` are used (see :ref:`CSV templates <user_csv-templates>`)
- Data from ``tests/data/user-guide/`` is used (`GitHub repo <https://github.com/gdcc/pyDataverse/tree/master/tests/data/user-guide>`_)


Expand Down Expand Up @@ -101,10 +101,10 @@ converts boolean values, and loads JSON cells properly.
Once we have the data in Python, we can easily import the data into
pyDataverse.

For this, loop over each Dataset :class:`dict`, to:
For this, loop over each Dataset :class:`dict`, to:

#. Instantiate an empty :class:`Dataset <pyDataverse.models.Dataset>`
#. add the data with :meth:`set() <pyDataverse.models.Dataset.set>` and
#. add the data with :meth:`set() <pyDataverse.models.Dataset.set>` and
#. append the instance to a :class:`list`.

::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ There is also a more detailed tutorial on how to use the CSV templates
for mass imports in the
:ref:`User Guide - Advanced <advanced-usage_data-migration>`.

The CSV templates can be found in ``src/pyDataverse/templates/``
(`GitHub repo <https://github.com/gdcc/pyDataverse/tree/master/src/pyDataverse/templates>`_):
The CSV templates can be found in ``pyDataverse/templates/``
(`GitHub repo <https://github.com/gdcc/pyDataverse/tree/master/pyDataverse/templates>`_):

- `dataverses.csv <https://raw.githubusercontent.com/gdcc/pyDataverse/master/src/pyDataverse/templates/dataverses.csv>`_
- `datasets.csv <https://raw.githubusercontent.com/gdcc/pyDataverse/master/src/pyDataverse/templates/datasets.csv>`_
- `datafiles.csv <https://raw.githubusercontent.com/gdcc/pyDataverse/master/src/pyDataverse/templates/datafiles.csv>`_
- `dataverses.csv <https://raw.githubusercontent.com/gdcc/pyDataverse/master/pyDataverse/templates/dataverses.csv>`_
- `datasets.csv <https://raw.githubusercontent.com/gdcc/pyDataverse/master/pyDataverse/templates/datasets.csv>`_
- `datafiles.csv <https://raw.githubusercontent.com/gdcc/pyDataverse/master/pyDataverse/templates/datafiles.csv>`_


.. _user_csv-templates_usage_create-csv:
Expand Down
File renamed without changes.
Loading
Loading