summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonny Pfannschmidt <opensource@ronnypfannschmidt.de>2020-05-21 22:46:00 +0200
committerGitHub <noreply@github.com>2020-05-21 22:46:00 +0200
commitea08eddf6015ac07a52f531261fad62c82da4125 (patch)
treebbcac7ef36a5bfc553f2681464dff0ca00032240
parentf66f2ae4fb1d22f28d8835fa1063ea5342847e3b (diff)
parent8f7c2fb39c8fddafb4197d7998056f47db43b7d6 (diff)
downloadsetuptools-scm-ea08eddf6015ac07a52f531261fad62c82da4125.tar.gz
Merge pull request #433 from pypa/drop-samefile
Drop samefile and use a conditional dependency for old pythons
-rw-r--r--.github/workflows/python-tests.yml16
-rw-r--r--MANIFEST.in1
-rw-r--r--pyproject.toml2
-rw-r--r--setup.cfg81
-rw-r--r--setup.py79
-rw-r--r--src/setuptools_scm/git.py5
-rw-r--r--src/setuptools_scm/win_py31_compat.py214
7 files changed, 91 insertions, 307 deletions
diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml
index b34d0a6..9b41ff2 100644
--- a/.github/workflows/python-tests.yml
+++ b/.github/workflows/python-tests.yml
@@ -26,6 +26,7 @@ jobs:
with:
python-version: ${{ matrix.python_version }}
architecture: x64
+ - run: pip install -U setuptools
- run: pip install -e .[toml] pytest
- run: pytest
@@ -45,7 +46,8 @@ jobs:
architecture: x64
# self install testing needs some clarity
# so its being executed without any other tools running
- - run: pip install -U setuptools
+ - run: pip install -U setuptools jaraco.windows
+ - run: python setup.py egg_info
- run: python setup.py sdist
- run: easy_install dist/*
- run: python testing/check_self_install.py
@@ -68,10 +70,10 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
- pip install --upgrade wheel setuptools
+ pip install --upgrade wheel setuptools jaraco.windows
+ - run: python setup.py egg_info
- name: Build package
- run: |
- python setup.py bdist_egg
+ run: python setup.py bdist_egg
- uses: actions/upload-artifact@v2
with:
name: dist
@@ -90,10 +92,10 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
- pip install --upgrade wheel setuptools
+ pip install --upgrade wheel setuptools jaraco.windows
+ - run: python setup.py egg_info
- name: Build package
- run: |
- python setup.py bdist_wheel sdist
+ run: python setup.py bdist_wheel sdist
- uses: actions/upload-artifact@v2
with:
name: dist
diff --git a/MANIFEST.in b/MANIFEST.in
index 5770343..4bbd88d 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,5 +1,4 @@
exclude *.nix
-exclude appveyor.yml
exclude .travis.yaml
exclude .pre-commit-config.yaml
include *.py
diff --git a/pyproject.toml b/pyproject.toml
index f90d4d1..0a33ae6 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,3 +1,3 @@
[build-system]
-requires = ["setuptools>=34.4", "wheel"]
+requires = ["setuptools>=34.4", "wheel", "jaraco.windows; python_version < '3'"]
build-backend = "setuptools.build_meta"
diff --git a/setup.cfg b/setup.cfg
index 224b998..32f8cff 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,9 +1,80 @@
-[bdist_wheel]
-universal=1
-
[metadata]
# ensure that the LICENSE file is included in the built wheels
license_file = LICENSE
+license = MIT
+name = setuptools_scm
+url = https://github.com/pypa/setuptools_scm/
+author = Ronny Pfannschmidt
+author_email = opensource@ronnypfannschmidt.de
+description = the blessed package to manage your versions by scm tags
+long_description= file:README.rst
+
+
+classifiers=
+ Development Status :: 5 - Production/Stable
+ Intended Audience :: Developers
+ License :: OSI Approved :: MIT License
+ Programming Language :: Python
+ Programming Language :: Python :: 3
+ Programming Language :: Python :: 3.5
+ Programming Language :: Python :: 3.6
+ Programming Language :: Python :: 3.7
+ Programming Language :: Python :: 3.8
+ Topic :: Software Development :: Libraries
+ Topic :: Software Development :: Version Control
+ Topic :: System :: Software Distribution
+ Topic :: Utilities
+
+
+[options]
+zip_safe = true
+python_requires= >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*
+install_requires=
+ setuptools
+ jaraco.windows; python_version=="2.7"
+packages=find:
+package_dir=
+ =src
+
+[options.packages.find]
+where=src
+
+[options.extras_require]
+toml = toml
+
+
+[options.entry_points]
+
+distutils.setup_keywords =
+ use_scm_version = setuptools_scm.integration:version_keyword
+
+setuptools.file_finders =
+ setuptools_scm = setuptools_scm.integration:find_files
+
+setuptools.finalize_distribution_options=
+ setuptools_scm = setuptools_scm.integration:infer_version
+
+setuptools_scm.parse_scm =
+ .hg = setuptools_scm.hg:parse
+ .git = setuptools_scm.git:parse
+
+setuptools_scm.parse_scm_fallback =
+ .hg_archival.txt = setuptools_scm.hg:parse_archival
+ PKG-INFO = setuptools_scm.hacks:parse_pkginfo
+ pip-egg-info = setuptools_scm.hacks:parse_pip_egg_info
+ setup.py = setuptools_scm.hacks:fallback_version
+
+setuptools_scm.files_command =
+ .hg = setuptools_scm.file_finder_hg:hg_find_files
+ .git = setuptools_scm.file_finder_git:git_find_files
+
+setuptools_scm.version_scheme =
+ guess-next-dev = setuptools_scm.version:guess_next_dev_version
+ post-release = setuptools_scm.version:postrelease_version
+ python-simplified-semver = setuptools_scm.version:simplified_semver_version
-[devpi:upload]
-formats=sdist,bdist_wheel
+setuptools_scm.local_scheme =
+ node-and-date = setuptools_scm.version:get_local_node_and_date
+ node-and-timestamp = setuptools_scm.version:get_local_node_and_timestamp
+ dirty-tag = setuptools_scm.version:get_local_dirty_tag
+ no-local-version = setuptools_scm.version:get_no_local_node
diff --git a/setup.py b/setup.py
index 6e72f74..0b3e0c7 100644
--- a/setup.py
+++ b/setup.py
@@ -24,6 +24,9 @@ def scm_config():
sys.path.insert(0, src)
pkg_resources.working_set.add_entry(src)
+ # FIXME: remove debug
+ print(src)
+ print(pkg_resources.working_set)
from setuptools_scm.hacks import parse_pkginfo
from setuptools_scm.git import parse as parse_git
from setuptools_scm.version import guess_next_dev_version, get_local_node_and_date
@@ -46,79 +49,5 @@ def scm_config():
return dict(version=get_version(root=here, parse=parse, **config))
-with open("README.rst") as fp:
- long_description = fp.read()
-
-
-arguments = dict(
- name="setuptools_scm",
- url="https://github.com/pypa/setuptools_scm/",
- zip_safe=True,
- author="Ronny Pfannschmidt",
- author_email="opensource@ronnypfannschmidt.de",
- description=("the blessed package to manage your versions by scm tags"),
- long_description=long_description,
- license="MIT",
- packages=["setuptools_scm"],
- package_dir={"": "src"},
- entry_points="""
- [distutils.setup_keywords]
- use_scm_version = setuptools_scm.integration:version_keyword
-
- [setuptools.file_finders]
- setuptools_scm = setuptools_scm.integration:find_files
-
- [setuptools.finalize_distribution_options]
- setuptools_scm = setuptools_scm.integration:infer_version
-
- [setuptools_scm.parse_scm]
- .hg = setuptools_scm.hg:parse
- .git = setuptools_scm.git:parse
-
- [setuptools_scm.parse_scm_fallback]
- .hg_archival.txt = setuptools_scm.hg:parse_archival
- PKG-INFO = setuptools_scm.hacks:parse_pkginfo
- pip-egg-info = setuptools_scm.hacks:parse_pip_egg_info
- setup.py = setuptools_scm.hacks:fallback_version
-
- [setuptools_scm.files_command]
- .hg = setuptools_scm.file_finder_hg:hg_find_files
- .git = setuptools_scm.file_finder_git:git_find_files
-
- [setuptools_scm.version_scheme]
- guess-next-dev = setuptools_scm.version:guess_next_dev_version
- post-release = setuptools_scm.version:postrelease_version
- python-simplified-semver = setuptools_scm.version:simplified_semver_version
- release-branch-semver = setuptools_scm.version:release_branch_semver
-
- [setuptools_scm.local_scheme]
- node-and-date = setuptools_scm.version:get_local_node_and_date
- node-and-timestamp = \
- setuptools_scm.version:get_local_node_and_timestamp
- dirty-tag = setuptools_scm.version:get_local_dirty_tag
- no-local-version = setuptools_scm.version:get_no_local_node
- """,
- classifiers=[
- "Development Status :: 4 - Beta",
- "Intended Audience :: Developers",
- "License :: OSI Approved :: MIT License",
- "Programming Language :: Python",
- "Programming Language :: Python :: 2",
- "Programming Language :: Python :: 3",
- "Programming Language :: Python :: 2.7",
- "Programming Language :: Python :: 3.4",
- "Programming Language :: Python :: 3.5",
- "Programming Language :: Python :: 3.6",
- "Programming Language :: Python :: 3.7",
- "Topic :: Software Development :: Libraries",
- "Topic :: Software Development :: Version Control",
- "Topic :: System :: Software Distribution",
- "Topic :: Utilities",
- ],
- python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*",
- extras_require=dict(toml=["toml", "setuptools>=42"]),
-)
-
if __name__ == "__main__":
- arguments.update(scm_config())
- setuptools.setup(**arguments)
+ setuptools.setup(**scm_config())
diff --git a/src/setuptools_scm/git.py b/src/setuptools_scm/git.py
index 76be436..b717584 100644
--- a/src/setuptools_scm/git.py
+++ b/src/setuptools_scm/git.py
@@ -6,10 +6,7 @@ from os.path import isfile, join
import warnings
-try:
- from os.path import samefile
-except ImportError:
- from .win_py31_compat import samefile
+from os.path import samefile
DEFAULT_DESCRIBE = "git describe --dirty --tags --long --match *[0-9]*"
diff --git a/src/setuptools_scm/win_py31_compat.py b/src/setuptools_scm/win_py31_compat.py
deleted file mode 100644
index 82a11eb..0000000
--- a/src/setuptools_scm/win_py31_compat.py
+++ /dev/null
@@ -1,214 +0,0 @@
-"""
-Backport of os.path.samefile for Python prior to 3.2
-on Windows from jaraco.windows 3.8.
-
-DON'T EDIT THIS FILE!
-
-Instead, file tickets and PR's with `jaraco.windows
-<https://github.com/jaraco/jaraco.windows>`_ and request
-a port to setuptools_scm.
-"""
-
-import os
-import nt
-import posixpath
-import ctypes.wintypes
-import sys
-import __builtin__ as builtins
-
-
-##
-# From jaraco.windows.error
-
-def format_system_message(errno):
- """
- Call FormatMessage with a system error number to retrieve
- the descriptive error message.
- """
- # first some flags used by FormatMessageW
- ALLOCATE_BUFFER = 0x100
- FROM_SYSTEM = 0x1000
-
- # Let FormatMessageW allocate the buffer (we'll free it below)
- # Also, let it know we want a system error message.
- flags = ALLOCATE_BUFFER | FROM_SYSTEM
- source = None
- message_id = errno
- language_id = 0
- result_buffer = ctypes.wintypes.LPWSTR()
- buffer_size = 0
- arguments = None
- bytes = ctypes.windll.kernel32.FormatMessageW(
- flags,
- source,
- message_id,
- language_id,
- ctypes.byref(result_buffer),
- buffer_size,
- arguments,
- )
- # note the following will cause an infinite loop if GetLastError
- # repeatedly returns an error that cannot be formatted, although
- # this should not happen.
- handle_nonzero_success(bytes)
- message = result_buffer.value
- ctypes.windll.kernel32.LocalFree(result_buffer)
- return message
-
-
-class WindowsError(builtins.WindowsError):
- """
- More info about errors at
- http://msdn.microsoft.com/en-us/library/ms681381(VS.85).aspx
- """
-
- def __init__(self, value=None):
- if value is None:
- value = ctypes.windll.kernel32.GetLastError()
- strerror = format_system_message(value)
- if sys.version_info > (3, 3):
- args = 0, strerror, None, value
- else:
- args = value, strerror
- super(WindowsError, self).__init__(*args)
-
- @property
- def message(self):
- return self.strerror
-
- @property
- def code(self):
- return self.winerror
-
- def __str__(self):
- return self.message
-
- def __repr__(self):
- return '{self.__class__.__name__}({self.winerror})'.format(**vars())
-
-
-def handle_nonzero_success(result):
- if result == 0:
- raise WindowsError()
-
-
-##
-# From jaraco.windows.api.filesystem
-
-FILE_FLAG_OPEN_REPARSE_POINT = 0x00200000
-FILE_FLAG_BACKUP_SEMANTICS = 0x2000000
-OPEN_EXISTING = 3
-FILE_ATTRIBUTE_NORMAL = 0x80
-FILE_READ_ATTRIBUTES = 0x80
-INVALID_HANDLE_VALUE = ctypes.wintypes.HANDLE(-1).value
-
-
-class BY_HANDLE_FILE_INFORMATION(ctypes.Structure):
- _fields_ = [
- ('file_attributes', ctypes.wintypes.DWORD),
- ('creation_time', ctypes.wintypes.FILETIME),
- ('last_access_time', ctypes.wintypes.FILETIME),
- ('last_write_time', ctypes.wintypes.FILETIME),
- ('volume_serial_number', ctypes.wintypes.DWORD),
- ('file_size_high', ctypes.wintypes.DWORD),
- ('file_size_low', ctypes.wintypes.DWORD),
- ('number_of_links', ctypes.wintypes.DWORD),
- ('file_index_high', ctypes.wintypes.DWORD),
- ('file_index_low', ctypes.wintypes.DWORD),
- ]
-
- @property
- def file_size(self):
- return (self.file_size_high << 32) + self.file_size_low
-
- @property
- def file_index(self):
- return (self.file_index_high << 32) + self.file_index_low
-
-
-class SECURITY_ATTRIBUTES(ctypes.Structure):
- _fields_ = (
- ('length', ctypes.wintypes.DWORD),
- ('p_security_descriptor', ctypes.wintypes.LPVOID),
- ('inherit_handle', ctypes.wintypes.BOOLEAN),
- )
-
-
-LPSECURITY_ATTRIBUTES = ctypes.POINTER(SECURITY_ATTRIBUTES)
-
-
-CreateFile = ctypes.windll.kernel32.CreateFileW
-CreateFile.argtypes = (
- ctypes.wintypes.LPWSTR,
- ctypes.wintypes.DWORD,
- ctypes.wintypes.DWORD,
- LPSECURITY_ATTRIBUTES,
- ctypes.wintypes.DWORD,
- ctypes.wintypes.DWORD,
- ctypes.wintypes.HANDLE,
-)
-CreateFile.restype = ctypes.wintypes.HANDLE
-
-GetFileInformationByHandle = ctypes.windll.kernel32.GetFileInformationByHandle
-GetFileInformationByHandle.restype = ctypes.wintypes.BOOL
-GetFileInformationByHandle.argtypes = (
- ctypes.wintypes.HANDLE,
- ctypes.POINTER(BY_HANDLE_FILE_INFORMATION),
-)
-
-
-##
-# From jaraco.windows.filesystem
-
-def compat_stat(path):
- """
- Generate stat as found on Python 3.2 and later.
- """
- stat = os.stat(path)
- info = get_file_info(path)
- # rewrite st_ino, st_dev, and st_nlink based on file info
- return nt.stat_result(
- (stat.st_mode,) +
- (info.file_index, info.volume_serial_number, info.number_of_links) +
- stat[4:]
- )
-
-
-def samefile(f1, f2):
- """
- Backport of samefile from Python 3.2 with support for Windows.
- """
- return posixpath.samestat(compat_stat(f1), compat_stat(f2))
-
-
-def get_file_info(path):
- # open the file the same way CPython does in posixmodule.c
- desired_access = FILE_READ_ATTRIBUTES
- share_mode = 0
- security_attributes = None
- creation_disposition = OPEN_EXISTING
- flags_and_attributes = (
- FILE_ATTRIBUTE_NORMAL |
- FILE_FLAG_BACKUP_SEMANTICS |
- FILE_FLAG_OPEN_REPARSE_POINT
- )
- template_file = None
-
- handle = CreateFile(
- path,
- desired_access,
- share_mode,
- security_attributes,
- creation_disposition,
- flags_and_attributes,
- template_file,
- )
-
- if handle == INVALID_HANDLE_VALUE:
- raise WindowsError()
-
- info = BY_HANDLE_FILE_INFORMATION()
- res = GetFileInformationByHandle(handle, info)
- handle_nonzero_success(res)
-
- return info