Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 133 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

{{ cookiecutter.project_slug }}-env/

docs/build/
20 changes: 10 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@
skeleton-python-binary
===============================

.. image:: https://img.shields.io/github/v/tag/pole-surfaces-planetaires/skeleton-python-binary
.. image:: https://img.shields.io/github/v/release/pole-surfaces-planetaires/skeleton-python-binary?include_prereleases
.. image:: https://img.shields.io/github/v/tag/pdssp/skeleton-python-binary
.. image:: https://img.shields.io/github/v/release/pdssp/skeleton-python-binary?include_prereleases

.. image:: https://img.shields.io/github/downloads/pole-surfaces-planetaires/skeleton-python-binary/total
.. image:: https://img.shields.io/github/issues-raw/pole-surfaces-planetaires/skeleton-python-binary
.. image:: https://img.shields.io/github/issues-pr-raw/pole-surfaces-planetaires/skeleton-python-binary
.. image:: https://img.shields.io/github/downloads/pdssp/skeleton-python-binary/total
.. image:: https://img.shields.io/github/issues-raw/pdssp/skeleton-python-binary
.. image:: https://img.shields.io/github/issues-pr-raw/pdssp/skeleton-python-binary
.. image:: https://img.shields.io/badge/Maintained%3F-yes-green.svg
:target: https://github.com/pole-surfaces-planetaires/skeleton-python-binary/graphs/commit-activity
.. image:: https://img.shields.io/github/license/pole-surfaces-planetaires/skeleton-python-binary
.. image:: https://img.shields.io/github/forks/pole-surfaces-planetaires/skeleton-python-binary?style=social
:target: https://github.com/pdssp/skeleton-python-binary/graphs/commit-activity
.. image:: https://img.shields.io/github/license/pdssp/skeleton-python-binary
.. image:: https://img.shields.io/github/forks/pdssp/skeleton-python-binary?style=social


Create a functional skeleton of a python package

✨ Demo preview
---------------

.. image:: https://raw.githubusercontent.com/pole-surfaces-planetaires/skeleton-python-binary/main/.github/images/demo.gif
.. image:: https://raw.githubusercontent.com/pdssp/skeleton-python-binary/main/.github/images/demo.gif

Usage
-----
Expand All @@ -35,7 +35,7 @@ To create a skeleton of a python project:

pip install cookiecutter

cookiecutter https://github.com/pole-surfaces-planetaires/skeleton-python-binary
cookiecutter https://github.com/pdssp/skeleton-python-binary



Expand Down
40 changes: 22 additions & 18 deletions cookiecutter.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
{
"full_name": "Jean-Christophe Malapert",
"institute": "CNES",
"email": "[email protected]",
"full_name": "John Doo",
"institute": "My institute",
"email": "[email protected]",
"github_username": "",
"project_name": "My Great Project",
"project_slug": "{{ cookiecutter.project_name.lower().replace(' ', '_').replace('-', '_') }}",
"project_class_lib": "{{ cookiecutter.project_slug.title().replace('_', '') + 'Lib' }}",
"project_short_description": "My Great Project description.",
"project_url": "https://github.com/pdssp/{{ cookiecutter.project_slug }}",
"project_web_site":"{{ cookiecutter.project_url.replace('github.com', 'pdssp.github.io') }}",
"project_description": "My Great Project description.",
"docker_image_name": "{{ cookiecutter.project_slug + '_image' }}",
"year": "{% now 'utc', '%Y' %}",
"month": "{% now 'utc', '%B' %}",
"_extensions": [
"jinja2_time.TimeExtension"
],
"consortium_name": [
"Pôle Surfaces Planétaires"
"PDSSP (Pôle de Données et Services Surfaces Planétaires)"
],
"pypi_username": "{{ cookiecutter.github_username }}",
"version": "0.0.1",
"use_pytest": "n",
"use_pypi_deployment_with_travis": "y",
"add_pyup_badge": "n",
"create_author_file": "y",
"open_source_license": [
"GNU General Public License v3",
"GNU Lesser General Public License v3",
"GNU Affero General Public License v3"
]
}
"Apache V2.0",
"MIT",
"GNU Lesser General Public License v3"
],
"python_version": [
"3.12",
"3.11"
],
"pypi_username": "{{ cookiecutter.github_username }}",
"add_pyup_badge": "n",
"use_pypi_deployment_with_travis": "y",
"use_pyenv":false
}

54 changes: 54 additions & 0 deletions hooks/pre_gen_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import platform
import sys
import os

def is_compatible_with_plateform(minimal_python_version_wanted):
major_version_wanted, minor_version_wanted = minimal_python_version_wanted.split(".")
python_version = platform.python_version_tuple()
major_version, minor_version, _ = python_version
return major_version_wanted == major_version and int(minor_version_wanted) <= int(minor_version)

def is_compatible_with_gitlab_docker(minimal_python_version_wanted):
major_version_wanted, minor_version_wanted = minimal_python_version_wanted.split(".")
python_version = "3.13."
major_version, minor_version, _ = python_version.split(".")
return major_version_wanted == major_version and int(minor_version_wanted) <= int(minor_version)

def is_pyenv_installed():
path_directories = os.environ.get('PATH', '').split(os.pathsep)

# Look at the install directory of pyenv in PATH
for directory in path_directories:
if 'pyenv' in directory:
return True

return False

def is_pyenv_selected(pyenv):
return pyenv.lower() in ("yes", "true", "t", "1")


minimal_python_version_wanted = "{{ cookiecutter.python_version }}"
pyenv_wanted = "{{ cookiecutter.use_pyenv }}"


if is_compatible_with_plateform(minimal_python_version_wanted) and is_compatible_with_gitlab_docker(minimal_python_version_wanted):
if is_pyenv_selected(pyenv_wanted):
if is_pyenv_installed():
sys.exit(0)
else:
print ("Please set use_pyenv=False or install it")
sys.exit(1)
else:
sys.exit(0)
elif is_pyenv_selected(pyenv_wanted):
if is_pyenv_installed():
sys.exit(0)
else:
print ("Please install pyenv")
sys.exit(1)
else:
print("Please set use_pyenv=True with this python version")
sys.exit(1)


Loading