Skip to content

dexteroux/CryptHdl

Repository files navigation

pyskel_bc

A skeleton of a Python package with CLI and test suite included. Taken from pyskel and modified slightly for quickstarting British Columbia python packages as per BC's guide.

Customization quick start

To use pyskel_bc as the start of a new project, do the following, preferably in a virtual environment.

  1. Clone the repo:

    git clone https://github.com/smnorris/pyskel_bc myproject
    cd myproject
    
  2. Replace all occurrences of 'pyskel_bc' with the name of your own project. (Note: the commands below require bash, find, and sed and are yet tested only on OS X.)

    if [ -d pyskel_bc ]; then find . -not -path './.git*' -type f -exec sed -i '' -e 's/pyskel_bc/myproject/g' {} + ; fi
    mv pyskel_bc myproject
    
  3. Install in locally editable (-e) mode and run the tests:

    pip install -e .[test]
    py.test
    
  4. Give the command line program a try:

    myproject --help
    myproject 4
    
  5. Test with tox if you are supporting multiple versions of Python:

    tox
    

To help prevent uncustomized forks of pyskel_bc from being uploaded to PyPI, the setup's upload command is configured to dry run. Make sure to remove this configuration from setup.cfg when you customize pyskel_bc.

A post on the Mapbox blog has more information about this project.

Usage on BC GTS Windows

  1. Open a windows command prompt and ensure that ArcGIS Python and scripts are inlcuded in the PATH. If a 64bit ArcGIS Python is available, use it:

    set PATH="E:\sw_nt\Python27\ArcGISx6410.3";"E:\sw_nt\Python27\ArcGISx6410.3\Scripts";%PATH%
    
  2. Ensure pip is available, install if it is not (to your workspace, not the system Python).

  3. Create and enable a virtualenv for testing/development so we don't have to worry about conflicting with system installed python packages:

    pip install --user virtualenv   # (if necessary)  
    mkdir myproject_env
    virtualenv myproject_env
    myproject_env\Scripts\activate
    
  4. If ArcGIS/arcpy is required by the module, ensure we can reach the arcpy module from the virtualenv (based on this USGS guide) by creating a file Lib\site-packages\ArcGIS.pth within the virtual environment folder. Include these lines (or similar, check for required 32 bit paths by starting ArcMap and typing import sys; print sys.path into the python window):

    # ArcGIS.pth
    # Path to ArcGIS arcpy modules
    # Place in folder ...\<path to your virtual environment>\lib\site-packages\
            
    E:\\sw_nt\\Python27\\ArcGISx6410.3
    E:\\sw_nt\\Python27\\ArcGISx6410.3\\Lib
    E:\\sw_nt\\Python27\\ArcGISx6410.3\\DLLs
    E:\\sw_nt\\Python27\\ArcGISx6410.3\\Lib\\lib-tk
    E:\\sw_nt\\Python27\\ArcGISx6410.3\\lib\\site-packages
    E:\\sw_nt\\Python27\\ArcGISx6410.3\\lib\\site-packages\\win32
    E:\\sw_nt\\Python27\\ArcGISx6410.3\\lib\\site-packages\\win32\\lib
    E:\\sw_nt\\Python27\\ArcGISx6410.3\\lib\\site-packages\\Pythonwin
    E:\\sw_nt\\ArcGIS\\Desktop10.3\\bin64
    E:\\sw_nt\\ArcGIS\\Desktop10.3\\ArcPy
    E:\\sw_nt\\ArcGIS\\Desktop10.3\\ArcToolBox\\Scripts
    
    
  5. Clone the repository using your tool of choice:

    git clone https://github.com/smnorris/pyskel_bc.git
    
  6. Replace all occurrences of 'pyskel_bc' with the name of your own project using your tool of choice. See quick start above for a bash command.

  7. Back at the windows command prompt, within the virtual environment:

    cd myproject
    pip install -e .[test]
    
  8. Give the command line program a try:

    myproject --help
    myproject 4
    
  9. If required, activate the virtualenv within an ArcGIS session by issuing this command from the ArcGIS python window (as per this question on StackOverflow):

    execfile(r'<path_to_env>\Scripts\activate_this.py', {'__file__': r'<path_to_env>\Scripts\activate_this.py'})
    import myproject
    

See also

Here are a few other tools for initializing Python projects:

  • Paste Script's paster create
  • cookiecutter-pypackage is a Cookiecutter template for a Python package. Cookiecutter supports many languages, includes Travis configuration and much more.

License

Copyright 2018 Province of British Columbia

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at 

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

Cryptographic Implementations in Myhdl

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published