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).

`setuptools-scm` also replaces most of MANIFEST.in, so this removes the
redundant lines from that too.
  • Loading branch information
kousu committed May 23, 2022
1 parent 8330bf3 commit bfb4841
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci_install-pkg.yml
Expand Up @@ -19,8 +19,6 @@ jobs:

- name: Check package
run: |
pip install check-manifest
check-manifest
python setup.py check --metadata --strict
- name: Create package
Expand Down
19 changes: 3 additions & 16 deletions MANIFEST.in
@@ -1,24 +1,11 @@
# Manifest syntax https://docs.python.org/2/distutils/sourcedist.html
graft wheelhouse
# Manifest syntax https://setuptools.pypa.io/en/latest/deprecated/distutils/commandref.html#sdist-cmd

recursive-exclude __pycache__ *.py[cod] *.orig

# Include the README
include *.md

# Include the license file
include LICENSE

recursive-include torchsampler *.py

# Include the Requirements
include requirements.txt
# FIXME: switching to a src/ layout would obviate the need for this file entirely.
# see https://setuptools.pypa.io/en/latest/userguide/package_discovery.html#src-layout

# Exclude build configs
exclude *.yml
exclude *.yaml

prune .github
prune example*
prune temp*
prune test*
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
12 changes: 12 additions & 0 deletions torchsampler/__about__.py
@@ -1,3 +1,15 @@
import sys

if sys.version_info < (3, 8):
from importlib_metadata import PackageNotFoundError, version
else:
from importlib.metadata import PackageNotFoundError, version

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 bfb4841

Please sign in to comment.