Setup.py resources




















As a data scientist I often make packages that aren't meant to be used by other python code but are meant to do something, for example to train a model. As such, I often have a python script that I want to execute from the command line. Do not forget to re-install - otherwise the command will not be registered. Whenever you write any code, I strongly encourage you to also write tests for this code.

For testing with python I suggest you use pytest. In order to have it installed automatically when you run tests you can add the following to your setup. Additionally you will have to create a file named setup. Now you can simply run python setup. Have a look here if you want to provide arguments or set configuration options for pytest. If you have any additional requirements for testing e. Personally I think it is a good idea to run Flake8 to check the formatting of your code.

If you want to change some of the configuration parameters of Flake8 you can add a [flake8] section to your setup. For example:. Sometimes you may want to include some non-python files in your package. These may for example be schema files or a small lookup table. Be aware that such files will be packaged together with your code, so it is in general a bad idea to include any large files. Suppose we have a schema. This will make sure the file is included in the package.

We can also choose to include all files based on a pattern, for example:. If you are going to publish your package, then you probably want to give your potential users some more information about your package, including a description, the name of the author or maintainer, and the url to the package's home page.

Active Oldest Votes. Improve this answer. Community Bot 1 1 1 silver badge. Mark Gemmill Mark Gemmill 5, 2 2 gold badges 25 25 silver badges 22 22 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook.

Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Making Agile work for data science. Stack Gives Back They may contain glob patterns as well. The path names may contain directory portions; any necessary directories will be created in the installation. For example, if a package should contain a subdirectory with several data files, the files can be arranged like this in the source tree:.

The corresponding call to setup might be:. Each directory , files pair in the sequence specifies the installation directory and the files to install there. Each file name in files is interpreted relative to the setup. Note that you can specify the directory where the data files will be installed, but you cannot rename the data files themselves.

The directory should be a relative path. Distutils allows directory to be an absolute installation path, but this is discouraged since it is incompatible with the wheel packaging format. No directory information from files is used to determine the final location of the installed file; only the name of the file is used. To install data files directly in the target directory, an empty string should be given as the directory.

The setup script may include additional meta-data beyond the name and version. This information includes:. Either the author or the maintainer must be identified.

See the Classifier field. The valid classifiers are listed on PyPI. To preserve backward compatibility, this field also accepts a string. If you pass a comma-separated string 'foo, bar' , it will be converted to ['foo', 'bar'] , Otherwise, it will be converted to a list of one string. Encoding the version information is an art in itself. Python packages generally adhere to the version format major. The major number is 0 for initial, experimental releases of software.

It is incremented for releases that represent major milestones in a package. The minor number is incremented when important new features are added to the package.

The patch number increments when bug-fix releases are made. Additional trailing version information is sometimes used to indicate sub-releases. Some examples:. Distutils catches any exceptions when running the setup script, and print a simple error message before the script is terminated. Navigation index modules next previous Python ».

Extension 'pkg. This warning notwithstanding, options to SWIG can be currently passed like this: setup Extension 'foo' , [ 'foo. For example, if you need to link against libraries known to be in the standard library search path on target systems Extension It can provide packages or modules. It can obsolete packages or modules. From the PyXML setup script: setup For example, if a package should contain a subdirectory with several data files, the files can be arranged like this in the source tree: setup.

It is recommended that versions take the form major. This field must be a list. Some examples: 0. Table of Contents 2. Writing the Setup Script 2. Listing whole packages 2. Listing individual modules 2. Describing extension modules 2. Extension names and packages 2. Extension source files 2. Preprocessor options 2. Library options 2.



0コメント

  • 1000 / 1000