Skip to content
This repository has been archived by the owner on Jul 22, 2023. It is now read-only.

Commit

Permalink
migration to 2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
sdpython committed Apr 17, 2015
1 parent cb5ad04 commit ac714de
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -235,3 +235,4 @@ _doc/sphinxdoc/source/blog/rss.xml
_doc/sphinxdoc/source/phdoc_templates/*.html _doc/sphinxdoc/source/phdoc_templates/*.html
_doc/sphinxdoc/source/blog/feed-icon*.png _doc/sphinxdoc/source/blog/feed-icon*.png
_doc/notebooks/.ipynb_checkpoints/* _doc/notebooks/.ipynb_checkpoints/*
dist_module27/*
7 changes: 5 additions & 2 deletions _unittests/ut_example/test_example.py
Expand Up @@ -14,7 +14,6 @@


try: try:
import src import src
import pyquickhelper
except ImportError: except ImportError:
path = os.path.normpath( path = os.path.normpath(
os.path.abspath( os.path.abspath(
Expand All @@ -24,6 +23,11 @@
".."))) "..")))
if path not in sys.path: if path not in sys.path:
sys.path.append(path) sys.path.append(path)
import src

try:
import pyquickhelper
except ImportError:
path = os.path.normpath( path = os.path.normpath(
os.path.abspath( os.path.abspath(
os.path.join( os.path.join(
Expand All @@ -35,7 +39,6 @@
"src"))) "src")))
if path not in sys.path: if path not in sys.path:
sys.path.append(path) sys.path.append(path)
import src
import pyquickhelper import pyquickhelper




Expand Down
48 changes: 48 additions & 0 deletions build_setup_help_on_windows_27.bat
@@ -0,0 +1,48 @@
echo off
IF EXIST dist del /Q dist\*.*

set PYTHONPATH=

if "%1"=="" goto default_value:
set pythonexe27="%1"
goto py34:

:default_value:
set pythonexe27=c:\Anaconda2\python

:py34:
if "%2"=="" goto default_value34:
set pythonexe34="%2"
goto utpy34:

:default_value34:
set pythonexe34=c:\Python34_x64\python


:utpy34:
%pythonexe34% setup.py copy27
if %errorlevel% neq 0 exit /b %errorlevel%
cd dist_module27\_unittests

for /d %%d in (ut_*) do %pythonexe27%\..\Scripts\nosetests.exe -w %%d

if %errorlevel% neq 0 exit /b %errorlevel%
echo #######################################################
cd ..

rem we add the script with publish the module for python 2.7
echo %pythonexe27% setup.py bdist_wheel upload > publish_on_pipy27.bat

:setup27_x64_msi_wheel:
%pythonexe27% setup.py bdist_wheel
if %errorlevel% neq 0 exit /b %errorlevel%
echo #######################################################
cd ..
if not exist dist: mkdir dist
copy dist_module27\dist\*.whl dist

rem
rem autopep8
rem coverage
rem flake8
rem wheel
41 changes: 32 additions & 9 deletions setup.py
Expand Up @@ -91,9 +91,9 @@


if os.path.exists(readme): if os.path.exists(readme):
try: try:
with open(readme, "r", encoding='utf-8') as f: with open(readme, "r", encoding='utf-8-sig') as f:
long_description = f.read() long_description = f.read()
long_description = long_description.replace("\ufeff", "") long_description = long_description
except: except:
try: try:
with open(readme, "r") as f: with open(readme, "r") as f:
Expand All @@ -116,13 +116,24 @@ def import_pyquickhelper():
try: try:
import pyquickhelper import pyquickhelper
except ImportError: except ImportError:
sys.path.append( if sys.version_info[0] == 2:
os.path.normpath( sys.path.append(
os.path.abspath( os.path.normpath(
os.path.join( os.path.abspath(
"..", os.path.join(
"pyquickhelper", "..",
"src")))) "..",
"pyquickhelper",
"dist_module27",
"src"))))
else:
sys.path.append(
os.path.normpath(
os.path.abspath(
os.path.join(
"..",
"pyquickhelper",
"src"))))
try: try:
import pyquickhelper import pyquickhelper
except ImportError as e: except ImportError as e:
Expand Down Expand Up @@ -191,6 +202,18 @@ def import_pyquickhelper():
pyquickhelper = import_pyquickhelper() pyquickhelper = import_pyquickhelper()
pyquickhelper.main_wrapper_tests(run_unit, add_coverage=True) pyquickhelper.main_wrapper_tests(run_unit, add_coverage=True)


elif "copy27" in sys.argv:

if sys.version_info[0] < 3:
raise Exception("Python needs to be Python3")

pyquickhelper = import_pyquickhelper()
root = os.path.abspath(os.path.dirname(__file__))
root = os.path.normpath(root)
dest = os.path.join(root, "dist_module27")
pyquickhelper.py3to2_convert_tree(root, dest, unittest_modules=["pyquickhelper"],
pattern_copy=".*[.]((ico)|(dll)|(rst)|(ipynb)|(png)|(txt)|(zip)|(gz)|(tohelp))$")

else: else:


setup( setup(
Expand Down

0 comments on commit ac714de

Please sign in to comment.