Skip to content
Permalink
Browse files

fixing issues with the documentation, less indirection, working with …

…submodules importing another one
  • Loading branch information...
sdpython committed Jun 18, 2013
1 parent 2871d27 commit 1865837c55f976b7239c049c1efdcad7ca626e8f
@@ -113,9 +113,30 @@ On Windows, the file ``build_setup_help_on_windows.bat`` does everything for you
Source
------

Folders
+++++++

The following folders contain:

* ``_doc``: Sphinx documentation.
* ``_unittests``: unit tests, you can run them by running the function :func:`check <__init__.check>` (as root on linux)
* ``src``: the sources

Adding a new module or subpackage
+++++++++++++++++++++++++++++++++

Any new module or subpackage should be added in ``src/project_name``. Every subfolder should
contain a file ``__init__.py``. If the new file needs an existing submodule, you need
to add something like the following::

import os,sys

try :
import project_name.subproject
except ImportError as e :
path = os.path.normpath( os.path.abspath( os.path.join( os.path.split(__file__)[0], "..", "..") ))
if path not in sys.path : sys.path.append(path)
import project_name.subproject
from project_name.subproject.myexample import myclass

@@ -14,7 +14,7 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath(os.path.join(os.path.split(__file__)[0])))
sys.path.insert(0, os.path.abspath(os.path.join(os.path.split(__file__)[0], project_var_name, project_var_name)))
sys.path.insert(0, os.path.abspath(os.path.join(os.path.split(__file__)[0], project_var_name)))

# -- General configuration -----------------------------------------------------

@@ -87,9 +87,6 @@
# This can be handy if you document a project that consists of a single package.
# Works only for the HTML builder currently. Default is [].
modindex_common_prefix = [
project_var_name + ".src.",
project_var_name + "._unittests.",
project_var_name + "." + project_var_name + ".",
project_var_name + ".",
]

@@ -22,17 +22,17 @@ Installation
* Windows installation:
* run the setup ``project_name*.win32.exe``
* Windows installation with source:
* download the file ``pyhome*.tar.gz`` and unzip it
* download the file ``project_name*.tar.gz`` and unzip it
* type the following commands::
set PATH=%PATH%;c:\Python33
python.exe setup.py install
* Linux installation:
* download the file ``pyhome*.tar.gz``
* download the file ``project_name*.tar.gz``
* type the following commands::
tar xf porject_name-py3.3.tar.gz
tar xf project_name-py3.3.tar.gz
sudo su
python3.3 setup.py install

@@ -59,7 +59,7 @@ About this documentation

generatedoc
glossary
confr_pyhome
confr_pyp


Changes
@@ -19,6 +19,7 @@

from pyhome3 import fLOG
from src.project_name.subproject.myexample import myclass
from src.project_name.subproject2.myexample2 import myclass2



@@ -30,6 +31,7 @@ def test_split_cmp_command(self) :
r = my.get_value(5)
ex = 20
if r != ex : raise Exception("we expect %f, not %f" % (ex, r))
my2 = myclass2(5)

if __name__ == "__main__" :
unittest.main ()
@@ -3,6 +3,7 @@ IF EXIST c:\python33vir\virt2\Scripts (
) ELSE (
set pythonexe="c:\python33\python"
)
copy README.rst README.txt
%pythonexe% setup.py sdist --formats=gztar,zip
%pythonexe% setup.py bdist_wininst
%pythonexe% make_help.py
@@ -65,7 +65,7 @@ def generate_help_sphinx () :
"""
"""
sys.path.append (os.path.join("_doc", "sphinxdoc","source"))
sys.path.append (os.path.abspath(os.path.join("_doc", "sphinxdoc","source")))
import conf

# modifies the version number in conf.py
@@ -83,11 +83,10 @@ def generate_help_sphinx () :
".",
"_doc/sphinxdoc/source/",
subfolders = [
("src/__init__.py", project_var_name + "/__init__.py"),
("src", project_var_name),
("src/" + project_var_name, project_var_name),
],
silent = True,
rootrep = ("_doc.sphinxdoc.source.%s.%s." % (project_var_name,project_var_name), ""),
rootrep = ("_doc.sphinxdoc.source.%s." % (project_var_name,), ""),
optional_dirs = optional_dirs )

fLOG("end of prepare_file_for_sphinx_help_generation")
@@ -47,6 +47,7 @@
import sys,os, re, zipfile

project_var_name = "project_name"
sversion = "0.5"

def get_svn_version (path = ".") :
try :
@@ -146,14 +147,14 @@ def get_folder_files (folder, excludePyFile = False, svn = False, recursive = Fa
# dirname is not used by sdist.py
path = "Lib/site-packages/" + project_var_name
data_files = [
#(os.path.join(path, project_var_name, "subproject"),
#(os.path.join(path, "subproject"),
# get_folder_files("src/" + project_var_name + "/subproject", svn = True, recursive = False) ),
]

if "bdist_wininst" in sys.argv :
# for the windows setup, we add the compiled files
data_files += [
#(os.path.join(path, project_var_name + "/subproject"),
#(os.path.join(path, "subproject"),
# ["src/" + project_var_name + "/subproject/file.pyd",
# ] ),
]
@@ -235,7 +236,7 @@ def find_packages () :

CLASSIFIERS = \
[
'Development Status :: 0.5 - Alpha',
'Development Status :: ' + sversion + ' - Alpha',
'Operating System :: any',
'Programming Language :: Python and C++',
'License :: GNU 2.0',
@@ -270,25 +271,15 @@ def find_packages () :
project_var_name + ', first name, last name'


packages = find_packages ()
package_dir = { k : k.replace(".","/") for k in packages }

if os.path.exists ("src") :
os.chdir ("src")
back = True

packages = [ _.replace ("src.","") for _ in packages ]
package_dir = { k : k.replace(".","/") for k in packages }
readme = '../README.rst'
else :
back = False
readme = 'README.rst'
packages = find_packages ()
package_dir = { k : k.replace(".","/") for k in packages }
readme = 'README.rst'



setup(
name = project_var_name + '-py' + versionPython,
version = 'v0.5.%d' % get_svn_version (),
version = 'v%s.%d' % (sversion, get_svn_version ()),
author = 'author',
author_email = 'author AT something.any',
url = "http://...",
@@ -307,14 +298,6 @@ def find_packages () :
include_package_data = True
)

if back :
os.chdir("..")
if not os.path.exists ("dist") :
os.mkdir ("dist")
os.system("copy /Y src\\dist\\*.* dist")
os.system("rmdir /S /Q src\\dist")
os.system("rmdir /S /Q src\\build")

if "install" in sys.argv :
# we check the data was installed
import shutil

0 comments on commit 1865837

Please sign in to comment.
You can’t perform that action at this time.