Skip to content

Instantly share code, notes, and snippets.

@dev-sareno
Last active April 8, 2021 02:05
Show Gist options
  • Save dev-sareno/3c8ade249079a5a0b2bbb21940fa7dd1 to your computer and use it in GitHub Desktop.
Save dev-sareno/3c8ade249079a5a0b2bbb21940fa7dd1 to your computer and use it in GitHub Desktop.
Python Cheat Sheet

setup.py

package_data

package_data copy the files into Python site-packages level directory.

data_files

data_files copy the files into System-wide level directory.

install_requires

install_requires install the library dependencies.

Example

import setuptools

setuptools.setup(
    name="mylib",
    version="1.0.0",
    author="dev-sareno",
    author_email="dev.sareno@gmail.com",
    description="My Sample Library",
    packages=setuptools.find_packages(),
    classifiers=[
        "Programming Language :: Python :: 3",
        "License :: AlgoDX License",
        "Operating System :: OS Independent",
    ],
    python_requires='>=3.8',
    package_data={
        'mylib': [
            'assets/*.*',
            'assets/subdir/*.*'
        ]
    },
    install_requires=[
          'numpy==1.19.5',
          'tensorflow==2.4.1',
          'shap==0.39.0'
      ]
)

PIP

Install dependency with external registry

Parameter --extra-index-url

pip install --extra-index https://mypythonregistry.com/simple

Install dependency with custom index

Parameter --index-url

pip install --index-url https://mypythonregistry.com/simple
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment