forked from pyscaffold/pyscaffold
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove dependency on PyScaffold during builds
As discussed in pyscaffold#256, after pytest-runner was deprecated and removed, the only strong reason for having PyScaffold required during builds is to use setuptools_scm. Docs can easily be generated via Makefile (already created by default) or tox/nox (the new tox template already contains a task for the docs). A way of removing this dependency is by injecting setuptools_scm directly on the `setup.py` template. In the future something similar can be done for `pyproject.toml` (when it is generated by default). This change is an attempt of doing that. As a direct consequence, we also remove PyScaffold as a build-time dependency of itself, which makes things easier.
- Loading branch information
1 parent
5f8eff6
commit 6a3d435
Showing
28 changed files
with
70 additions
and
3,764 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
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,62 +1,16 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Setup file for PyScaffold. | ||
Important note: Since PyScaffold is self-using and depends on | ||
setuptools-scm, it is important to run: | ||
`python setup.py egg_info --egg-base .` | ||
after a fresh checkout. This will generate some critically needed data. | ||
""" | ||
import inspect | ||
import os | ||
"""Setup file for PyScaffold.""" | ||
import sys | ||
|
||
from pkg_resources import VersionConflict, require | ||
from setuptools import setup | ||
|
||
__location__ = os.path.join( | ||
os.getcwd(), os.path.dirname(inspect.getfile(inspect.currentframe())) | ||
) | ||
|
||
|
||
def bootstrap_cfg(): | ||
"""Allow PyScaffold to be used to package itself. | ||
Usually, running ``python setup.py egg_info --egg-base .`` first is a good | ||
idea. | ||
""" | ||
src_dir = os.path.join(__location__, "src") | ||
egg_info_dir = os.path.join(__location__, "PyScaffold.egg-info") | ||
has_entrypoints = os.path.isdir(egg_info_dir) | ||
import pkg_resources | ||
|
||
sys.path.insert(0, src_dir) | ||
pkg_resources.working_set.add_entry(src_dir) | ||
from pyscaffold.contrib.setuptools_scm import get_version | ||
from pyscaffold.contrib.setuptools_scm.git import parse as parse_git | ||
from pyscaffold.contrib.setuptools_scm.hacks import parse_pkginfo | ||
from pyscaffold.integration import local_version2str, version2str | ||
from pyscaffold.utils import check_setuptools_version | ||
|
||
check_setuptools_version() | ||
|
||
def parse(root): | ||
try: | ||
return parse_pkginfo(root) | ||
except IOError: | ||
return parse_git(root) | ||
|
||
config = dict(version_scheme=version2str, local_scheme=local_version2str,) | ||
|
||
if has_entrypoints: | ||
return dict(use_pyscaffold=True) | ||
else: | ||
return dict(version=get_version(root=__location__, parse=parse, **config)) | ||
|
||
|
||
def setup_package(): | ||
"""Call setuptools-provided `setup` using PyScaffold to bootstrap itself""" | ||
setup(**bootstrap_cfg()) | ||
try: | ||
require("setuptools>=38.3") | ||
except VersionConflict: | ||
print("Error: version of setuptools is too old (<38.3)!") | ||
sys.exit(1) | ||
|
||
|
||
if __name__ == "__main__": | ||
setup_package() | ||
setup(use_scm_version={"version_scheme": "post-release"}) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.