Skip to content

Commit

Permalink
Append '-editable' to version for editable installs
Browse files Browse the repository at this point in the history
This will append '-editable' to the usb.__version__ string
when pyusb is installed via `python setup.py develop` or
`pip install -e .`
  • Loading branch information
ap-- committed Jul 12, 2020
1 parent a62d5ee commit f8fea24
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


import sys
from setuptools import setup
from distutils.version import LooseVersion
from setuptools import __version__ as setuptools_version
Expand All @@ -38,12 +38,29 @@
if LooseVersion(setuptools_version).version[0] < 12:
setuptools_scm += '<2.0'

setup(
name='pyusb',
use_scm_version={

def pyusb_scm_version():
"""append '-editable' to version for editable installs"""
from setuptools_scm.version import get_local_node_and_date

def editable_local_scheme(version):
local_scheme = get_local_node_and_date(version)
# distutils scans sys.argv for matching command classes
# (see `distutils.dist.Distribution._parse_command_opts`)
if "develop" in sys.argv[1:]:
return local_scheme + "-editable"
return local_scheme

return {
"version_scheme": "post-release",
"local_scheme": editable_local_scheme,
"write_to": "usb/_version.py",
},
}


setup(
name='pyusb',
use_scm_version=pyusb_scm_version,
setup_requires=setuptools_scm,
description='Python USB access module',
author='Robert Wlodarczyk',
Expand Down

0 comments on commit f8fea24

Please sign in to comment.