Giter VIP home page Giter VIP logo

self-contained-runnable-python-package-template's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

self-contained-runnable-python-package-template's Issues

python -m packagename.tests does not run

I'm not familiar with unittest, so I apologize in advance if I used it wrongly.

After downloading the repo and running:

python -m packagename.tests

I get:


Warning: No suitable VIRTUAL_ENV environmental variable detected.

In order to ensure consistency / reproducibility between runs, you might want to
consider always running this package from within a suitable python virtual
environment, containing the python package versions specified in the package's
requirements.txt file.

Press ENTER if you'd like to continue regardless (or Ctrl-C to abort)



__init__: Setting PKGROOT to /home/junior/Documents/Projetos/Python/self-contained-runnable-python-package-template/packagename
__init__: Setting INPUTS_PATH to /home/junior/Documents/Projetos/Python/self-contained-runnable-python-package-template/packagename/inputs
__init__: Setting OUTPUTS_PATH to /home/junior/Documents/Projetos/Python/self-contained-runnable-python-package-template/packagename/outputs
__init__: Setting MCMC_ENGINE to <class 'packagename.config.CONFIG.Stan'>
Traceback (most recent call last):
  File "/usr/lib64/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib64/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/junior/Documents/Projetos/Python/self-contained-runnable-python-package-template/packagename/tests/__main__.py", line 41, in <module>
    if __name__ == '__main__': main()
  File "/home/junior/Documents/Projetos/Python/self-contained-runnable-python-package-template/packagename/tests/__main__.py", line 33, in main
    Tests  = unittest.defaultTestLoader.discover( start_dir = TestDir )
  File "/usr/lib64/python3.10/unittest/loader.py", line 306, in discover
    os.path.dirname((the_module.__file__)))
  File "/usr/lib64/python3.10/posixpath.py", line 152, in dirname
    p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType

System information:

$: python -VV
Python 3.10.2 (main, Jan 17 2022, 00:00:00) [GCC 11.2.1 20211203 (Red Hat 11.2.1-7)]

Add optional lib directory

Either in the template, or simply mentioned as optional.

Python typically does not require 'libraries' bundled with the project, since external dependencies are typically handled at the 'python' / 'pip' level.

However, it is not impossible that an atypical external dependency needs to be accessible from within the project structure. E.g. a stray python module, or libraries from other languages that the main program may need to interface with (possibly even requiring compilation before the package can be run). In such cases, the right place for such code is not the 'src' file, which should only contain 'project-native' code. In which case, it should go into 'lib', which is a standard name for external libraries in packages typical of other languages. (possibly even a 'bin' directory, in case compilation into executables is involved -- though I'd place this inside the 'lib' directory, to avoid any confusion that these may relate to execution of the main package in any way).

Add optional dependencies / requirements to project structure

More generally, this is a straightforward way to declare dependencies for a project, though for simple dependencies this can also be in the docs or README.

However, some projects may need specific versions of packages installed to run properly.
This is e.g. particularly important in terms of reproducibility, such as when packages are intended to represent self-contained 'experiments', etc.

Add assertion ensuring python3 is used

e.g. get this assertion error if you attempt to run using python2:

Error: This package is intended to be run in python3
   (you seem to be running python2)

NOTE: Ironically, for this to work, this whole file needs to use python2 compatible syntax, otherwise the interpreter will exit with a syntax error even before it reaches this assertion. Specifically, this means we cannot use 'f-strings' in this file, so we'll need to rely on the older '.format()' mechanism.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.