Skip to content

Commit

Permalink
Use setuptools_scm
Browse files Browse the repository at this point in the history
Follows up ufoym#47

- on [pypi](https://pypi.org/project/torchsampler/0.1.1/) it's 0.1.1
- on github it's [0.1.0](https://github.com/ufoym/imbalanced-dataset-sampler/releases/tag/v0.1.0)
    - but the attached [wheel](https://github.com/ufoym/imbalanced-dataset-sampler/releases/download/v0.1.0/torchsampler-0.1.1-py3-none-any.whl)
      and [sdist](https://github.com/ufoym/imbalanced-dataset-sampler/releases/download/v0.1.0/torchsampler-0.1.1.tar.gz) are 0.1.1

[`setuptools-scm`](https://pypi.org/project/setuptools-scm/) makes git the single-source of truth
for the version of the package, and works well with the build script in ufoym#47 (which is triggered
by tagging a new version in git).
  • Loading branch information
kousu committed May 22, 2022
1 parent 8330bf3 commit c909262
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/code-format.yml
Expand Up @@ -48,7 +48,10 @@ jobs:
- name: Install dependencies
run: |
pip install --upgrade pip
pip install yapf
# TODO: in the next version of yapf you can use the clearer
# pip install yapf[pyproject]
# see ttps://github.com/google/yapf/pull/964
pip install yapf toml
pip list
shell: bash
- name: yapf
Expand Down
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Expand Up @@ -28,6 +28,8 @@ repos:
rev: v0.32.0
hooks:
- id: yapf
# needed for pyproject.toml: https://github.com/pre-commit/mirrors-yapf/issues/15#issuecomment-814037905
additional_dependencies: [toml]
name: formatting

- repo: https://github.com/PyCQA/flake8
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
@@ -0,0 +1,2 @@
[build-system]
requires = ["setuptools>=45", "wheel", "setuptools_scm>=6.2"]
1 change: 1 addition & 0 deletions requirements.txt
@@ -1,3 +1,4 @@
torch>=1.3
torchvision>=0.5
pandas
importlib_metadata; python_version<'3.8'
3 changes: 2 additions & 1 deletion setup.py
Expand Up @@ -20,7 +20,7 @@

setup(
name='torchsampler',
version=about.__version__,
use_scm_version=True,
url=about.__homepage__,
author=about.__author__,
author_email=about.__author_email__,
Expand All @@ -30,6 +30,7 @@
long_description_content_type='text/markdown',
packages=['torchsampler'],
keywords='sampler,pytorch,dataloader',
setup_requires=['setuptools_scm'],
install_requires=requirements,
python_requires='>=3.6',
include_package_data=True,
Expand Down
6 changes: 6 additions & 0 deletions torchsampler/__about__.py
@@ -1,3 +1,9 @@
from importlib.metadata import version, PackageNotFoundError
try:
__version__ = version("torchsampler")
except PackageNotFoundError:
# package is not installed (i.e. we're probably in the build process itself)
pass
__version__ = "0.1.1"
__author__ = "Ming, et al."
__author_email__ = "a@ufoym.com"
Expand Down

0 comments on commit c909262

Please sign in to comment.