Permalink
Browse files

update setup.py to enforce the writing of version.txt

  • Loading branch information...
sdpython committed Apr 20, 2015
1 parent c195795 commit d757a51d2b92fb11646275063e93dc55a16fb325
Showing with 35 additions and 27 deletions.
  1. +35 −27 setup.py
View
@@ -42,6 +42,40 @@
from distutils.core import setup
from setuptools import find_packages
def import_pyquickhelper():
try:
import pyquickhelper
except ImportError:
sys.path.append(
os.path.normpath(
os.path.abspath(
os.path.join(
"..",
"pyquickhelper",
"src"))))
try:
import pyquickhelper
except ImportError as e:
raise ImportError(
"module pyquickhelper is needed to build the documentation ({0})".format(
sys.executable)) from e
return pyquickhelper
def write_version():
pyquickhelper = import_pyquickhelper()
from pyquickhelper.loghelper.pyrepo_helper import SourceRepository
src = SourceRepository(commandline=True)
fold = os.path.abspath(os.path.dirname(__file__))
version = src.version(fold)
if version is not None:
with open(os.path.join(fold, "version.txt"), "w") as f:
f.write(str(version) + "\n")
if not os.path.exists("version.txt"):
write_version()
if os.path.exists("version.txt"):
with open("version.txt", "r") as f:
lines = f.readlines()
@@ -107,25 +141,6 @@
long_description = ""
def import_pyquickhelper():
try:
import pyquickhelper
except ImportError:
sys.path.append(
os.path.normpath(
os.path.abspath(
os.path.join(
"..",
"pyquickhelper",
"src"))))
try:
import pyquickhelper
except ImportError as e:
raise ImportError(
"module pyquickhelper is needed to build the documentation ({0})".format(
sys.executable)) from e
return pyquickhelper
if "--verbose" in sys.argv:
print("---------------------------------")
print("package_dir =", package_dir)
@@ -149,14 +164,7 @@ def import_pyquickhelper():
print("number of impacted files", len(rem))
elif "write_version" in sys.argv:
pyquickhelper = import_pyquickhelper()
from pyquickhelper.loghelper.pyrepo_helper import SourceRepository
src = SourceRepository(commandline=True)
fold = os.path.abspath(os.path.dirname(__file__))
version = src.version(fold)
if version is not None:
with open(os.path.join(fold, "version.txt"), "w") as f:
f.write(str(version) + "\n")
write_version()
elif "clean_pyd" in sys.argv:
pyquickhelper = import_pyquickhelper()

0 comments on commit d757a51

Please sign in to comment.