sample-proj-lib


Namesample-proj-lib JSON
Version 0.1.3 PyPI version JSON
download
home_pagehttps://github.com/psilons/pypigeonhole-proj-tmplt.git
SummaryPython build sample project for libs
upload_time2020-10-18 06:34:20
maintainer
docs_urlNone
authorpsilons
requires_python>=3.6
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            This is a sample for pypigeonhole-build to build a reusable lib.

## Python Environment Setup

Install miniconda, if needed, from https://docs.conda.io/en/latest/miniconda.html

We need to install this package in order to use its scripts.

```conda install -c psilons pypigeonhole-build```

Use IntelliJ or other IDEs to create a project in the folder sample-proj-lib
Under there, create the following:

- src folder: for python code
- create top package under src, it should be the project folder name 
  with _ instead of - . In this case, it's sample_proj_lib.
- test folder: for python test code
- create top package under test, it should be ```test_<top package in src>```.
  In this case, it's test_sample_proj_lib
- a blank README.md file that we could fill in later.
- setup.py: copy from pypigeonhole-build\src\pypigeonhole_build\dep_setup.py 
  to the top package in src, we will modify it later.
- app_setup.py: copy from pypigeonhole-build\src\pypigeonhole_build\app_setup.py 
  to the top package in src, we will modify it later.
- ```__init__.py```: copy from pypigeonhole-build\test\pypigeonhole_build\.
  Notice that there is some hook code in this file for unit testing. No need
  to change it.

Now follow these steps:
- change __app_version to 0.1.0 in app_setup.py
- add 2 dependencies to dependent_libs in dep_setup.py:  
    ```Dependency(name='psutil', scope=INSTALL),```     
    ```Dependency(name='pypigeonhole-build', installer=CONDA),```
- add psilons to the channels in dep_setup.py 
- setup.py: modify the import statement to point to sample_proj_lib.

Now let's open a command window, and go to the project folder. Run 

```pph_dev_env_setup 2>&1 | tee a.log```

to create the conda environment with the name ```py390_sample_proj_lib``` 
specified in the dep_setup.py.

This step also creates requirements.txt and environment.yml. After it's down,
run ```conda info --envs``` to check the new environment is in the right path.
Run ```conda activate py390_sample_proj_lib```

If needed, run ```conda clean -a``` to clear conda cache (from time to time).

## Coding and Testing
Back to IDE and change the setting to use this new environment.

Let's create some sample code, create sample_feature.py under the top package 
and fill in some python logic. 

In the test folder, write some test case. Make sure it works in the IDE, and
it gets proper test coverage. 
Run ```pph_unittest```, this generates .coverage and a badge coverage.svg.

In the project folder, ```pip install -e .``` creates a soft link in the
python environment, if needed during cross development.


## Package

If all goes well, it's time to package our code and ship it out. Run 

```pph_package_pip.bat 2>&1 | tee b.log``` 

this generates a few things:
- sample_proj_lib.egg-info under src, this is package info.
- build folder under project, this is intermediate staging folder.
- dist folder under project, there are 2 artifacts in this folder.

In order to build conda package, we need to follow conda-build convention.
Let's create a bbin (build bin) folder under project, then a pkg_conda_cfg
folder under bbin. This path is hard-coded in the following script. There
are 3 files here, meta.yaml, bld.bat, and build.sh. conda-build calls these
files. Please read conda-build docs for more details.

Now let's get out of the conda environment and run 
```pph_package_conda 2>&1 | tee c.log```, 
it generates output in dist_conda folder under project. We care the file 
dist_conda\noarch\sample-proj-lib-0.0.1-pyt_0.tar.bz2

Make sure conda is clean after build. conda-build corrupts conda environments,
and so run it outside.

```conda info --envs```

## Local Testing

To test pip package:
- pip uninstall sample-proj-lib -y  
- pip install dist\sample-proj-lib-0.1.0.tar.gz  
- python -c "import sample_proj_lib.dep_setup as ds; print(ds.app_version)"
- check ```<env>\Lib\site-packages\sample_proj_lib``` for files
- pip uninstall sample-proj-lib -y
- pip install dist\sample_proj_lib-0.1.0-py3-none-any.whl
- python -c "import sample_proj_lib.dep_setup as ds; print(ds.app_version)"
- check ```<env>\Lib\site-packages\sample_proj_lib``` for files
- pip uninstall sample-proj-lib -y

To test conda package:
- conda remove sample-proj-lib -y
- conda install dist_conda\noarch\sample-proj-lib-0.1.0-py_0.tar.bz2
- python -c "import sample_proj_lib.dep_setup as ds; print(ds.app_version)"
- check ```<env>\Lib\site-packages\sample_proj_lib``` for files
- conda remove sample-proj-lib -y

## Upload and Testing   

```pph_upload_pip```

```pph_upload_pip_test```

```pph_upload_conda dist_conda\noarch\sample-proj-lib-0.1.0-py_0.tar.bz2```


To test: same process as before, except we install from central server:

```pip install sample-proj-lib``` and ```conda install -c psilons sample-proj-lib```

We may add the channel psilons to the config:

```conda config --add channels psilons```

To check whether it's in the config:

```conda config --get channels```


## Release and Cleanup

Now check all changes, and run

```pph_release```

Finally, we clean up all the generated files.

```pph_cleanup```

Try to commit again, there should be nothing to commit.

```conda deactivate```



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/psilons/pypigeonhole-proj-tmplt.git",
    "name": "sample-proj-lib",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "",
    "author": "psilons",
    "author_email": "psilons.quanta@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/97/ab/530a74e4e36ca5a4310208b2f84f5b9731d6c036abee9664c06ecb684216/sample-proj-lib-0.1.3.tar.gz",
    "platform": "",
    "description": "This is a sample for pypigeonhole-build to build a reusable lib.\n\n## Python Environment Setup\n\nInstall miniconda, if needed, from https://docs.conda.io/en/latest/miniconda.html\n\nWe need to install this package in order to use its scripts.\n\n```conda install -c psilons pypigeonhole-build```\n\nUse IntelliJ or other IDEs to create a project in the folder sample-proj-lib\nUnder there, create the following:\n\n- src folder: for python code\n- create top package under src, it should be the project folder name \n  with _ instead of - . In this case, it's sample_proj_lib.\n- test folder: for python test code\n- create top package under test, it should be ```test_<top package in src>```.\n  In this case, it's test_sample_proj_lib\n- a blank README.md file that we could fill in later.\n- setup.py: copy from pypigeonhole-build\\src\\pypigeonhole_build\\dep_setup.py \n  to the top package in src, we will modify it later.\n- app_setup.py: copy from pypigeonhole-build\\src\\pypigeonhole_build\\app_setup.py \n  to the top package in src, we will modify it later.\n- ```__init__.py```: copy from pypigeonhole-build\\test\\pypigeonhole_build\\.\n  Notice that there is some hook code in this file for unit testing. No need\n  to change it.\n\nNow follow these steps:\n- change __app_version to 0.1.0 in app_setup.py\n- add 2 dependencies to dependent_libs in dep_setup.py:  \n    ```Dependency(name='psutil', scope=INSTALL),```     \n    ```Dependency(name='pypigeonhole-build', installer=CONDA),```\n- add psilons to the channels in dep_setup.py \n- setup.py: modify the import statement to point to sample_proj_lib.\n\nNow let's open a command window, and go to the project folder. Run \n\n```pph_dev_env_setup 2>&1 | tee a.log```\n\nto create the conda environment with the name ```py390_sample_proj_lib``` \nspecified in the dep_setup.py.\n\nThis step also creates requirements.txt and environment.yml. After it's down,\nrun ```conda info --envs``` to check the new environment is in the right path.\nRun ```conda activate py390_sample_proj_lib```\n\nIf needed, run ```conda clean -a``` to clear conda cache (from time to time).\n\n## Coding and Testing\nBack to IDE and change the setting to use this new environment.\n\nLet's create some sample code, create sample_feature.py under the top package \nand fill in some python logic. \n\nIn the test folder, write some test case. Make sure it works in the IDE, and\nit gets proper test coverage. \nRun ```pph_unittest```, this generates .coverage and a badge coverage.svg.\n\nIn the project folder, ```pip install -e .``` creates a soft link in the\npython environment, if needed during cross development.\n\n\n## Package\n\nIf all goes well, it's time to package our code and ship it out. Run \n\n```pph_package_pip.bat 2>&1 | tee b.log``` \n\nthis generates a few things:\n- sample_proj_lib.egg-info under src, this is package info.\n- build folder under project, this is intermediate staging folder.\n- dist folder under project, there are 2 artifacts in this folder.\n\nIn order to build conda package, we need to follow conda-build convention.\nLet's create a bbin (build bin) folder under project, then a pkg_conda_cfg\nfolder under bbin. This path is hard-coded in the following script. There\nare 3 files here, meta.yaml, bld.bat, and build.sh. conda-build calls these\nfiles. Please read conda-build docs for more details.\n\nNow let's get out of the conda environment and run \n```pph_package_conda 2>&1 | tee c.log```, \nit generates output in dist_conda folder under project. We care the file \ndist_conda\\noarch\\sample-proj-lib-0.0.1-pyt_0.tar.bz2\n\nMake sure conda is clean after build. conda-build corrupts conda environments,\nand so run it outside.\n\n```conda info --envs```\n\n## Local Testing\n\nTo test pip package:\n- pip uninstall sample-proj-lib -y  \n- pip install dist\\sample-proj-lib-0.1.0.tar.gz  \n- python -c \"import sample_proj_lib.dep_setup as ds; print(ds.app_version)\"\n- check ```<env>\\Lib\\site-packages\\sample_proj_lib``` for files\n- pip uninstall sample-proj-lib -y\n- pip install dist\\sample_proj_lib-0.1.0-py3-none-any.whl\n- python -c \"import sample_proj_lib.dep_setup as ds; print(ds.app_version)\"\n- check ```<env>\\Lib\\site-packages\\sample_proj_lib``` for files\n- pip uninstall sample-proj-lib -y\n\nTo test conda package:\n- conda remove sample-proj-lib -y\n- conda install dist_conda\\noarch\\sample-proj-lib-0.1.0-py_0.tar.bz2\n- python -c \"import sample_proj_lib.dep_setup as ds; print(ds.app_version)\"\n- check ```<env>\\Lib\\site-packages\\sample_proj_lib``` for files\n- conda remove sample-proj-lib -y\n\n## Upload and Testing   \n\n```pph_upload_pip```\n\n```pph_upload_pip_test```\n\n```pph_upload_conda dist_conda\\noarch\\sample-proj-lib-0.1.0-py_0.tar.bz2```\n\n\nTo test: same process as before, except we install from central server:\n\n```pip install sample-proj-lib``` and ```conda install -c psilons sample-proj-lib```\n\nWe may add the channel psilons to the config:\n\n```conda config --add channels psilons```\n\nTo check whether it's in the config:\n\n```conda config --get channels```\n\n\n## Release and Cleanup\n\nNow check all changes, and run\n\n```pph_release```\n\nFinally, we clean up all the generated files.\n\n```pph_cleanup```\n\nTry to commit again, there should be nothing to commit.\n\n```conda deactivate```\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python build sample project for libs",
    "version": "0.1.3",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "9a3220f497bfe90ab368c96dc9a308b9",
                "sha256": "bceebc497219dc00961830b5f9de2b8882c3896efcaa70d00e9bb712a4b876ac"
            },
            "downloads": -1,
            "filename": "sample_proj_lib-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9a3220f497bfe90ab368c96dc9a308b9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 5500,
            "upload_time": "2020-10-18T06:34:19",
            "upload_time_iso_8601": "2020-10-18T06:34:19.519163Z",
            "url": "https://files.pythonhosted.org/packages/63/f1/dd1c0bb2778c6a535a88c2aa486ebf2c0636a6013ea7df8162af14d6507c/sample_proj_lib-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "9d6452c863c00e4c114d385497c1bc0d",
                "sha256": "5ef7111914487cf79a49b2d203f7e8aa9ddc2014d03fb6ff8cd9bfb6c9c35ef0"
            },
            "downloads": -1,
            "filename": "sample-proj-lib-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "9d6452c863c00e4c114d385497c1bc0d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 5967,
            "upload_time": "2020-10-18T06:34:20",
            "upload_time_iso_8601": "2020-10-18T06:34:20.497873Z",
            "url": "https://files.pythonhosted.org/packages/97/ab/530a74e4e36ca5a4310208b2f84f5b9731d6c036abee9664c06ecb684216/sample-proj-lib-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-10-18 06:34:20",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": null,
    "github_project": "psilons",
    "error": "Could not fetch GitHub repository",
    "lcname": "sample-proj-lib"
}
        
Elapsed time: 0.18010s