-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from jennyfothergill/add/git-version-tracking
Add version tracking through git
- Loading branch information
Showing
5 changed files
with
39 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
# When using setuptools_scm don't track __version__.py | ||
__version__.py | ||
|
||
# scratch dir | ||
scratch | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[build-system] | ||
requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[tool.setuptools_scm] | ||
write_to = "grits/__version__.py" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,109 +1,59 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
from codecs import open | ||
from os import path | ||
|
||
# Example copied with love from: | ||
# https://github.com/kennethreitz/setup.py/blob/master/setup.py | ||
|
||
# Note: To use the 'upload' functionality of this file, you must: | ||
# $ pip install twine | ||
|
||
import io | ||
import os | ||
import sys | ||
from shutil import rmtree | ||
|
||
from setuptools import Command, find_packages, setup | ||
from setuptools import find_packages, setup | ||
|
||
# Package meta-data. | ||
NAME = "grits" | ||
DESCRIPTION = "A toolkit for working with coarse-grained systems" | ||
URL = "https://github.com/cmelab/grits" | ||
EMAIL = "[email protected]" | ||
AUTHOR = "Jenny Fothergill" | ||
REQUIRES_PYTHON = ">=3.7.0" | ||
REQUIRES_PYTHON = ">=3.8" | ||
|
||
# What packages are required for this module to be executed? | ||
REQUIRED = ["mbuild", "numpy"] | ||
|
||
# The rest you shouldn't have to touch too much :) | ||
# ------------------------------------------------ | ||
# Except, perhaps the License and Trove Classifiers! | ||
# If you do change the License, remember to change the Trove Classifier! | ||
|
||
here = os.path.abspath(os.path.dirname(__file__)) | ||
|
||
# Load the package's __version__.py module as a dictionary. | ||
about = {} | ||
with open(os.path.join(here, NAME, "__version__.py")) as f: | ||
exec(f.read(), about) | ||
|
||
|
||
class UploadCommand(Command): | ||
"""Support setup.py upload.""" | ||
|
||
description = "Build and publish the package." | ||
user_options = [] | ||
here = path.abspath(path.dirname(__file__)) | ||
|
||
@staticmethod | ||
def status(s): | ||
"""Prints things in bold.""" | ||
print("\033[1m{0}\033[0m".format(s)) | ||
with open("README.md", "r", encoding="utf-8") as f: | ||
long_description = f.read() | ||
|
||
def initialize_options(self): | ||
pass | ||
|
||
def finalize_options(self): | ||
pass | ||
def myversion(): | ||
from setuptools_scm.version import get_local_dirty_tag | ||
|
||
def run(self): | ||
try: | ||
self.status("Removing previous builds…") | ||
rmtree(os.path.join(here, "dist")) | ||
except OSError: | ||
pass | ||
def clean_scheme(version): | ||
return get_local_dirty_tag(version) if version.dirty else "+clean" | ||
|
||
self.status("Building Source and Wheel (universal) distribution…") | ||
os.system(f"{sys.executable} setup.py sdist bdist_wheel --universal") | ||
return {"local_scheme": clean_scheme} | ||
|
||
self.status("Uploading the package to PyPi via Twine…") | ||
os.system("twine upload dist/*") | ||
|
||
self.status("Pushing git tags…") | ||
os.system(f"git tag v{about['__version__']}") | ||
os.system("git push --tags") | ||
|
||
sys.exit() | ||
|
||
|
||
# Where the magic happens: | ||
setup( | ||
name=NAME, | ||
version=about["__version__"], | ||
description=DESCRIPTION, | ||
use_scm_version=myversion, | ||
author=AUTHOR, | ||
author_email=EMAIL, | ||
python_requires=REQUIRES_PYTHON, | ||
description=DESCRIPTION, | ||
long_description=long_description, | ||
long_description_content_type="text/markdown", | ||
url=URL, | ||
license="GPLv3", | ||
project_urls={ | ||
"Bug Tracker": f"{URL}/issues", | ||
}, | ||
python_requires=REQUIRES_PYTHON, | ||
packages=find_packages(exclude=("tests", "docs", "examples")), | ||
# If your package is a single module, use this instead of 'packages': | ||
# py_modules=['mypackage'], | ||
# entry_points={ | ||
# 'console_scripts': ['mycli=mymodule:cli'], | ||
# }, | ||
package_data={"grits": ["compounds/*"]}, | ||
install_requires=REQUIRED, | ||
include_package_data=True, | ||
license="MIT", | ||
classifiers=[ | ||
# Trove classifiers | ||
# Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers | ||
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.7", | ||
"Programming Language :: Python :: Implementation :: CPython", | ||
"Programming Language :: Python :: Implementation :: PyPy", | ||
"Programming Language :: Python :: 3.8", | ||
], | ||
# $ setup.py publish support. | ||
cmdclass={"upload": UploadCommand}, | ||
) |