python-packaging | Tutorial on how to structure Python packages | Build Tool library

 by   storborg Python Version: Current License: No License

kandi X-RAY | python-packaging Summary

kandi X-RAY | python-packaging Summary

python-packaging is a Python library typically used in Utilities, Build Tool applications. python-packaging has no bugs, it has no vulnerabilities and it has high support. However python-packaging build file is not available. You can download it from GitHub.

Tutorial on how to structure Python packages
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              python-packaging has a highly active ecosystem.
              It has 414 star(s) with 130 fork(s). There are 17 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 18 open issues and 6 have been closed. On average issues are closed in 0 days. There are 19 open pull requests and 0 closed requests.
              OutlinedDot
              It has a negative sentiment in the developer community.
              The latest version of python-packaging is current.

            kandi-Quality Quality

              python-packaging has 0 bugs and 3 code smells.

            kandi-Security Security

              python-packaging has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              python-packaging code analysis shows 0 unresolved vulnerabilities.
              There are 1 security hotspots that need review.

            kandi-License License

              python-packaging does not have a standard license declared.
              Check the repository for any license declaration and review the terms closely.
              OutlinedDot
              Without a license, all rights are reserved, and you cannot use the library in your applications.

            kandi-Reuse Reuse

              python-packaging releases are not available. You will need to build from source code and install.
              python-packaging has no build file. You will be need to create the build yourself to build the component from source.
              python-packaging saves you 30 person hours of effort in developing the same functionality from scratch.
              It has 82 lines of code, 5 functions and 7 files.
              It has low code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed python-packaging and discovered the below as its top functions. This is intended to give you an instant insight into python-packaging implemented functionality, and help decide if they suit your requirements.
            • Return joke .
            • Return the README . rst file .
            • Runs the main function
            Get all kandi verified functions for this library.

            python-packaging Key Features

            No Key Features are available at this moment for python-packaging.

            python-packaging Examples and Code Snippets

            No Code Snippets are available at this moment for python-packaging.

            Community Discussions

            QUESTION

            Python Packaging: user specified file path
            Asked 2021-Jun-02 at 09:19

            I am writing a python package which is dependent on a number of large data files. These files are not included with the package. Instead, users are required to have these files on disk already (with an arbitrary path). What is the best way to make my package aware of the location of these files?

            I have been reading about setup.py and setup.cfg but I am still not sure how to to this. It seems to me that a user-editable option in setup.cfg would be a good way to go but I don't know if it is, if it can be done at all, or how I would do it if so...

            I did see this almost identical question, Python Packaging: Ask user for variable values when (pip) installing, which focuses on user input during pip (which is discouraged in the comments). If that actually would be a good solution, I'm interested in how to do that too.

            In my private development of the package, I have used module constants, as in

            ...

            ANSWER

            Answered 2021-Jun-01 at 18:19

            This sounds like runtime configuration. It's none of the business of setup.py, which is concerned with installing your package.

            For app configuration, it would be common to specify this resource location by command-line argument, environment variable, or configuration file. You will usually want to either hard-code some sensible default path in case the user does not specify any configuration, or raise an exception in case of resources not existing / not found.

            Example for environment var:

            Source https://stackoverflow.com/questions/67794055

            QUESTION

            Python package hierarchy
            Asked 2021-May-26 at 13:52

            I have developed a Python package. My structure is the following :

            ...

            ANSWER

            Answered 2021-May-26 at 13:52

            User configuration should usually be kept in the os-specific locations for application configs. The usual way to handle it as a package author is to

            • write a default config file and put it into the package, e.g. at src/my_package/default.ini - this is better than writing the config as code, as your main.py probably does, because you can re-use your parsing step, can copy the default config to get a valid user config, and just have to maintain a single file type
            • copy the default config into a user-specific directory, use appdirs to find out which one is correct on each os
              • you can either ask your users if it's ok to create a new config at e.g. /home/user/.configs/my_app and do it after confirmation, or just do it and tell them where to find it in case they want to customize something
            • on application start, parse the default config first, then parse the user config and overwrite differing settings
            • if you also allow configuration via environment variables, those will be parsed afterwards and should overwrite both default- and user-config

            Just to have a starting point, my config-parsing usually looks somewhat like this:

            config.py, somewhere in your package

            Source https://stackoverflow.com/questions/67699500

            QUESTION

            Install dependencies automatically upon serverless deploy
            Asked 2021-Mar-09 at 13:46

            I'm using Serverless v2.23.0 to deploy a bunch of endpoints to AWS Lambda functions. The Lambda functions run python 3.8. I want to automatically install a dependency upon deploy to AWS Lambda.

            For example, I want the package pycurl installed automatically. I am following the tutorial at https://www.serverless.com/blog/serverless-python-packaging

            I added a requirements.txt file which just has the line:

            ...

            ANSWER

            Answered 2021-Mar-09 at 13:46

            The libcurl-devel & openssl-devel packages are missing, use one of the lambci/lambda Docker images to build and make sure all the dependencies are installed.

            Change your serverless.yml to:

            Source https://stackoverflow.com/questions/66521824

            QUESTION

            How to create a Relocatable Conda Environment? Is it doable?
            Asked 2020-May-07 at 16:02

            I would like to make a relocatable environment. So I need to use relative paths in the package installations. For this I just create a Conda Environment like this:

            ...

            ANSWER

            Answered 2018-Nov-29 at 18:08

            I think that relocatable environments depend on the installed packages. They should be implemented with relative paths and avoiding hardcoded paths. All the paths that are used in the source code of the package should be inside the own package. So if you install well done package you won´t have any problem to relocate the environment in other folder or computer.

            As you will need to add all the folders inside the package you will need to modify the arguments of the setup. Add these two parameters in order to add folders to the final package. If you don´t do this the folders won´t copied to the site-packages folder within the environment (the final destination when you install the package with pip):

            Source https://stackoverflow.com/questions/51714605

            QUESTION

            how to add csv files where installing packages with pip install in python?
            Asked 2020-May-05 at 16:51

            I spent significant time, finding solution to this one problem :

            My setup.py is as follow :

            ...

            ANSWER

            Answered 2020-May-05 at 16:51

            As the links above do not mentionned, we need to this extra line in setup.py :

            Source https://stackoverflow.com/questions/61588179

            QUESTION

            simplest way to make a python module usable as a cli-tool
            Asked 2020-Apr-12 at 13:54

            I'd like to make a cli tool and found this as a reference: https://python-packaging.readthedocs.io/en/latest/command-line-scripts.html

            So I created a directory with the following structure

            ...

            ANSWER

            Answered 2020-Apr-12 at 09:45

            The guide you are following is 5 years old and a little vague. You could setup your cli-tool like so:

            Source https://stackoverflow.com/questions/61168583

            QUESTION

            Where is python supposed to install scripts for module
            Asked 2020-Apr-04 at 19:34

            I'm trying to build a python module, and install a script as part of the installation of the package. i.e. I have a script foo, and after the user installs the package, they should be able to run foo on the command line.

            In the docs, it says:

            When we install the package, setuptools will copy the script to our PATH and make it available for general use.

            Source

            Is it possible to find which folder the setup is supposed to install the script?

            I have a setup.py that looks like this:

            ...

            ANSWER

            Answered 2020-Apr-04 at 18:50

            Python's doc also says:

            The Distutils install command is designed to make installing module distributions to an alternate location simple and painless. The basic idea is that you supply a base directory for the installation, and the install command picks a set of directories (called an installation scheme) under this base directory in which to install files. The details differ across platforms, so read whichever of the following sections applies to you.

            Note that the various alternate installation schemes are mutually exclusive: you can pass --user, or --home, or --prefix and --exec-prefix, or --install-base and --install-platbase, but you can’t mix from these groups.

            See it here

            Source https://stackoverflow.com/questions/61033001

            QUESTION

            AWS: Unable to import module 'handler': No module named 'numpy'
            Asked 2020-Apr-01 at 17:49

            AWS Newbie here

            I have to host my python scripts via gitlab CI as a lambda and trigger it by cloudwatch on AWS.

            I am following the following tutorials:

            1. https://docs.gitlab.com/ee/user/project/clusters/serverless/aws.html
            2. https://serverless.com/blog/serverless-python-packaging/

            From the first tutorial, I am taking just the .gitlab-ci.yml file and adding it to the tutorial shown in the second tutorial (but instead of python 3.6, I am choosing 3.7 as the runtime)

            I have the following serverless.yml file

            ...

            ANSWER

            Answered 2020-Mar-27 at 12:43

            It seems like you missed step about adding serverless-python-requirements plugin to serverless.yml.

            Try adding it as mentioned blog:

            Source https://stackoverflow.com/questions/60885819

            QUESTION

            Deploying a microservice with Tensorflow at AWS Lambda
            Asked 2020-Jan-15 at 15:26

            I have been stuck here for too long. I am trying to deploy a microservice that uses tensorflow. There is a single file by the name of handler.py which has the simple code below:

            ...

            ANSWER

            Answered 2018-May-25 at 09:49

            As you've mentioned from the error you received it looks like your zipped package is too large. You received that other error because you have a module requirement in your script to use tensorflow.

            Keep in mind the AWS Lambda Limits has a 50MB deployment package size limit. The Tensorflow package by itself is close to 50MB, so adding the Numpy package will take it well over the limit.

            Have a look at this blog which does some investigation into the package limit sizing in AWS Lambda

            https://hackernoon.com/exploring-the-aws-lambda-deployment-limits-9a8384b0bec3

            Source https://stackoverflow.com/questions/50523674

            QUESTION

            Python packaging: different methods to specify external requirements - differences, advantages, and recommendations
            Asked 2019-Dec-29 at 17:22

            I am packaging a python project and look for the "right" way to specify dpendencies on external files. I am aware of multiple ways to specify dpendencies, but I would like to know how these ways work practically, how they differ, and at which specific time points they are taking effect, respectively.

            Known ways to specify dependencies (see here)

            1. We could specify the dependency in the install_requires argument of setuptools.setup
            2. We could use requirements.txt
            3. We could use setup.cfg

            My main questions

            1. What are advantages and disadvantages of the different methods?
            2. When and in which order are the information in the respective files read? Would e.g. pip first execute setup.py and then check the requirements.txt afterwards?
            3. What happens if I specify a requirement only in one of the ways given above? What happens, if I speciefy different requirements with different ways?

            Motivating example

            I need to create a package that uses cython and numpy. As can be seen e.g. here, cython (and similarly numpy, must be imported before setuptools.setup is called. Hence, setup.py would raise an ImportError if the library is not available. How would I make the requirement visible anyway so that the necessary packages are installed before setup.py is called? Should I move the compilation to a different file that is then called from setup.py? How would I do that?

            ...

            ANSWER

            Answered 2019-Dec-29 at 17:22

            These are many broad questions. It is difficult to give an exhaustive answer and to keep opinions aside...

            When it comes strictly to packaging Python projects, I believe pip's "requirements" files are not commonly useful nor used (there are counter examples of course, but I would argue that they are not a good idea for packaging in general). But in some other use cases, I believe they are very helpful.

            If setuptools is used for packaging (there are perfectly valid alternatives), then install_requires is the way to go to declare the direct dependencies of the project. Unless there is no other way around, then I would recommend placing the whole setuptools configuration (this includes install_requires) in the setup.cfg file instead of as arguments to setuptools.setup(). The result would be exactly the same in both cases but (as it is now commonly accepted) for configuration, a static declarative file is a much more natural fit than executable code. As for the order of precedence, I believe a setuptools.setup() argument would override the same configuration item read from setup.cfg.

            Would e.g. pip first execute setup.py and then check the requirements.txt afterwards?

            These are two different things. The requirements file is more or less a list of projects that one wants to install. Each of these projects might be packaged (setuptools or other) and distributed (source or pre-built wheel) in different ways, some will require the execution of a setup.py some won't. But again, when packaging (and distributing) a project there is usually no need to bother with a requirements file (never when the project is a library, and not at first when the project is an application, see Donald Stufft's article "setup.py vs requirements.txt").

            I would rather not go into details regarding the question about the combination of Cython and setuptools. It would be a good additional question. These two links might help get you started though:

            Source https://stackoverflow.com/questions/59515656

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install python-packaging

            You can download it from GitHub.
            You can use python-packaging like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/storborg/python-packaging.git

          • CLI

            gh repo clone storborg/python-packaging

          • sshUrl

            git@github.com:storborg/python-packaging.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link