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

Add helper API #378

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Add helper API #378

wants to merge 5 commits into from

Conversation

Erotemic
Copy link
Contributor

@Erotemic Erotemic commented Jan 5, 2019

As a scikit, scikit-build should strive to make its target area of science simpler. However, unlike other scikits like learn and image, there isn't much of a top-level API. Designing a good top-level "build" API for Python is something that doesn't yet exist. Scikit-build has an opportunity to be the first tool that actually makes writing a setup.py script simple.

As such I wanted to propose a few baseline functions to populate the currently singular API. These functions are contained in a file helper_api.py. The top of that file contains a docstring detailing a use-case that illustrates the usefulness of these API calls. All of these API calls serve the purpose of making it easier to fill out arguments to setuptools.setup.

The API calls are:

  • find_packages - a port from setuptools to populate packages
  • parse_version - parse versions with static analysis and populate version
  • parse_long_description - for populating long_description easier
  • parse_requirements - for populating install_requires easier
  • parse_authors - basic parsing of authors from git

I've currently been copy+pasting these 200ish lines of code between all of my repos, but it seems to me that scikit-build might be the right place for this logic to actually live.

I've exposed the functions in the utils subpackage. I'm not sure where these are best placed in the directory structure, so I'm open to ideas / suggestions here.

@codecov
Copy link

codecov bot commented Jan 5, 2019

Codecov Report

Merging #378 into master will decrease coverage by 5.09%.
The diff coverage is 12.04%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #378     +/-   ##
=========================================
- Coverage   89.88%   84.79%   -5.1%     
=========================================
  Files          27       28      +1     
  Lines        1186     1269     +83     
  Branches      214      235     +21     
=========================================
+ Hits         1066     1076     +10     
- Misses         84      157     +73     
  Partials       36       36
Impacted Files Coverage Δ
skbuild/helper_api.py 12.04% <12.04%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cf83697...050548d. Read the comment docs.

@codecov
Copy link

codecov bot commented Jan 5, 2019

Codecov Report

Merging #378 into master will increase coverage by 0.41%.
The diff coverage is 12.04%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #378      +/-   ##
==========================================
+ Coverage   84.37%   84.79%   +0.41%     
==========================================
  Files          28       28              
  Lines        1338     1269      -69     
  Branches      240      235       -5     
==========================================
- Hits         1129     1076      -53     
- Misses        146      157      +11     
+ Partials       63       36      -27
Impacted Files Coverage Δ
skbuild/helper_api.py 12.04% <12.04%> (ø)
skbuild/constants.py 100% <0%> (ø) ⬆️
skbuild/command/build_ext.py
skbuild/setuptools_wrap.py 96.63% <0%> (+1.12%) ⬆️
skbuild/platform_specifics/abstract.py 95.29% <0%> (+3.54%) ⬆️
skbuild/command/bdist_wheel.py 66.66% <0%> (+3.62%) ⬆️
skbuild/cmaker.py 74.64% <0%> (+4.92%) ⬆️
skbuild/command/generate_source_manifest.py 90% <0%> (+7.24%) ⬆️
skbuild/command/sdist.py 100% <0%> (+8.82%) ⬆️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5b20908...1d2fbc2. Read the comment docs.

@thewtex thewtex requested a review from jcfr January 7, 2019 02:47
@jcfr jcfr force-pushed the dev/helper_api branch from 050548d to efae75a Compare May 14, 2019 06:34
@jcfr jcfr added the Status: Triage Issues/PRs that need to be triaged label May 29, 2019
@Erotemic Erotemic changed the title Add root level utility API Add helper API Sep 16, 2019
@Erotemic
Copy link
Contributor Author

I've updated these functions to be slightly simpler and I moved them to skbuild.utils, which I think makes more sense from a namespace perspective.

I'm also trying out a slightly expanded version of these tools in another PR:
https://github.com/mariusmuja/flann/blob/a8e9f53040f7f01d3e915e4c9669c47428bee1fb/skbuild_template.py This includes additional helpers for working with classifiers, licenses, and shared library extensions. I'm not sure if they are general enough to warrant inclusion, so I've opted to not include them here by default. However, I'm open to maintainer input on this.

@Erotemic
Copy link
Contributor Author

Erotemic commented Jan 6, 2022

@jcfr I was thinking about this PR and it's fit with scikit-build. I was thinking tools like this might be suitable for a more pure-python focused package, the name that popped in my head was scikit-setup.

The main problem with setuptools (and pkg_resources) is that their requirements parser doesn't actually work correctly. While this could be patched in setuptools, it might make sense to have a lighter-weight less monolithic helper library for writing setup.py files. It could also serve as a proof of concept to perhaps get fixes to pkg_resources merged upstream.

I'm also fairly unhappy with current versioning tools like versioneer, and I feel like there could be a better solution.

Of course the risk is that this is yet-another-setup-library, but the goal here isn't to replace setuptools/poetry/pipenv/pyproject.toml (I don't know what the current accepted standard is, if there is one), but instead just provide a few simple functions that are useful during setup, namely I want to be able to write:

        version=parse_version('ubelt/__init__.py'),
        long_description=parse_description(),
        install_requires=parse_requirements('requirements/runtime.txt'),
        extras_require={
            'all': parse_requirements('requirements.txt'),
            'tests': parse_requirements('requirements/tests.txt'),
            'optional': parse_requirements('requirements/optional.txt'),
            'docs': parse_requirements('requirements/docs.txt'),
        },

I want to ensure that specifications of dependencies / versions are not repeated anywhere. I'd also like to provide a "strict" mode for dependency installs that would effectively replace any ">=" in the requirements specs with "==", which I currently do with an external script.

Probably wont act on this anytime soon, but just writing down my thoughts while they are fresh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage Issues/PRs that need to be triaged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants