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

[REF] Migrate from setup.py to pyproject.toml (fixes #122) #123

Merged
merged 3 commits into from
Aug 5, 2024

Conversation

kourbou
Copy link
Contributor

@kourbou kourbou commented Jul 28, 2024

Hello! I agree with @wiseodd that requiring packaging to be installed during build time makes it difficult to use curvlinops in downstream packages such as laplace-torch, and makes the installation process a little confusing.

I've moved the version check in setup.py directly into pyproject.toml using the new standard for setuptools-based packages:

Unfortunately, flake8 and darglint do not yet support pyproject.toml but their flags can remain in the setup.cfg file until support is added. (Although, I recommend eventually migrating to ruff since it can accomplish both tasks.)

Fixes #122.

@wiseodd
Copy link
Collaborator

wiseodd commented Jul 28, 2024

Thanks @kourbou for making my job easier! I think @f-dangel won't be mad if you also replace black, darglint, flake, etc. with ruff in this PR ;)

@f-dangel
Copy link
Owner

Hi, thanks for setting this up!

Please go ahead and introduce ruff if you like.

I'll have time to review this during the week. @wiseodd could you also take a look?

@coveralls
Copy link

coveralls commented Jul 29, 2024

Pull Request Test Coverage Report for Build 10221782460

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 88.896%

Totals Coverage Status
Change from base Build 9786205146: 0.0%
Covered Lines: 1337
Relevant Lines: 1504

💛 - Coveralls

@wiseodd
Copy link
Collaborator

wiseodd commented Jul 30, 2024

LGTM so far. One thing I'm confused about is why doesn't this have the same problem as before, i.e. requiring packaging. The build backend remains the same and this PR is supposedly only translating setup.cfg -> pyproject.toml.

@kourbou
Copy link
Contributor Author

kourbou commented Jul 30, 2024

@f-dangel Okay, I can look into adding ruff into the project later this month, although I would prefer if it was a separate PR if it's okay with you since the tool is quite opinionated and it might involve discussing lint rules and the such.

@wiseodd AFAIU the requirement on packaging was solely for the purpose of checking the version of setuptools. It was previously imported inside of setup.py to parse the version number but I've removed setup.py entirely since we can now make this check directly from pyproject.toml. I've also bumped the version to guarantee pyproject.toml support.

[build-system]
requires = ["setuptools >= 61.0", "setuptools_scm"]
...

Copy link
Owner

@f-dangel f-dangel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nit, otherwise looks good to me!

.readthedocs.yaml Outdated Show resolved Hide resolved
@f-dangel
Copy link
Owner

@f-dangel Okay, I can look into adding ruff into the project later this month, although I would prefer if it was a separate PR if it's okay with you since the tool is quite opinionated and it might involve discussing lint rules and the such.

Sounds good.

@kourbou
Copy link
Contributor Author

kourbou commented Aug 2, 2024

One nit, otherwise looks good to me!

I removed the post-install step in .readthedocs.yaml, it seems to work without the version pinned now. Will come back with another PR for Ruff.

@f-dangel
Copy link
Owner

f-dangel commented Aug 5, 2024

Thanks! I am adding 'create a new release' to my TODO list for the coming weeks.

@f-dangel f-dangel merged commit ce9999c into f-dangel:main Aug 5, 2024
7 checks passed
@kourbou kourbou deleted the use-pyproject-toml branch August 5, 2024 11:41
@kourbou
Copy link
Contributor Author

kourbou commented Aug 17, 2024

@f-dangel Unfortunately I don't have time to make a PR and test if Ruff can replace all the project's linting needs, but adding it as a dependency and pasting the following into pyproject.toml should get you 90% of the way there:

[tool.ruff]
# An extremely fast Python linter, written in Rust.
# https://docs.astral.sh/ruff/

# Additional file patterns to omit from formatting and linting.
extend-exclude = ["docs/rtd"]

# Line length to use when enforcing long-lines violations.
line-length = 97 # = 88 + 10% (B950)

[tool.ruff.lint]

# Rule codes or prefixes to enable, in addition to those specified by `select`.
extend-select = [
    "B",   # flake8-bugbear
    "C",   # pylint-convention
    "E",   # pycodestyle-error
    "W",   # pycodestyle-warning
    "C90", # mccabe
    "I",   # isort
    "DOC", # pydocstyle
    # Not implemented: https://github.com/astral-sh/ruff/issues/5713
    # "P",   # flake8-string-format
    # Not implemented: https://github.com/astral-sh/ruff/issues/458
    # "DAR", # darglint
]

# Rule codes or prefixes to ignore.
ignore = [
    "C408", # unnecessary-collection-call
    "E203", # whitespace-before-punctuation
    "E231", # missing-whitespace
    "W291", # trailing-whitespace
    "B905", # zip-without-explicit-strict
]

# Mappings from file pattern to rule codes or prefixes to exclude.
per-file-ignores = { "test/**.py" = ["I001"] }

[tool.ruff.lint.mccabe]

# The maximum McCabe complexity to allow before triggering C901 errors.
max-complexity = 10

[tool.ruff.lint.pydocstyle]

# Whether to use Google-style, NumPy-style conventions, or the PEP 257 defaults
# when analyzing docstring sections.
convention = "google"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error when installing curvlinops as dependency
4 participants