tencent cloud

Feedback

PyPI Repository

Last updated: 2024-01-02 17:58:50
    This document describes how to store PyPI artifacts in CODING-AR for centralized artifact management and version control. The following sections introduce how to create an artifact, configure authentication, and pull and push artifacts.

    Open CODING-AR

    1. Log in to the CODING Console and click Use Now to go to CODING page.
    2. Click
    
    in the upper-right corner to open the project list page and click a project icon to open the project.
    3. In the menu on the left, click Artifact Management.

    Preparations

    Note:
    Before you begin:
    Install Python3.
    Create an artifact repository (see Basic Operations).
    Select PyPI as the repository type.

    Initialize a Local PyPI Project

    1. Create a demo directory for the PyPI project. Run the following command in the terminal to create a demo project folder.
    mkdir -p demo/example_pkg/__init__.py
    
    2. Go to the demo directory and create a setup.py file.
    cd demo && touch setup.py
    
    3. Paste the configuration to setup.py.
    import setuptools
    
    setuptools.setup(
    name="example-pkg-YOUR-USERNAME-HERE", # Replace with your own username
    version="0.0.1",
    author="Example Author",
    author_email="author@example.com",
    description="A small example package",
    url="https://github.com/pypa/sampleproject",
    packages=setuptools.find_packages(),
    classifiers=[
    "Programming Language :: Python :: 3",
    "License :: OSI Approved :: MIT License",
    "Operating System :: OS Independent",
    ],
    python_requires='>=3.6',
    )
    
    4. Install setuptools and wheel.
    python3 -m pip install --user --upgrade setuptools wheel
    
    5. Package the project.
    python3 setup.py sdist bdist_wheel
    
    After the project is packaged, the following files will be generated in /dist for pushing:
    └─npm
    ├─example_pkg_YOUR_USERNAME_HERE-0.0.1-py3-none-any.whl
    ├─example_pkg_YOUR_USERNAME_HERE-0.0.1.tar.gz
    

    Configure Authentication Information

    Authentication information must be configured before you can pull artifacts from or push artifacts to CODING-AR. You can select automatic configuration or manual configuration. Before configuration, run cd / to go to the root directory, and then run ls -a to check whether .pypirc and pip.conf files exist.
    If such files are not found, run the following command to create these files.
    touch .pypirc && touch pip.conf
    

    Automatic configuration

    1. Click Generate configuration from access token. An access credential will be generated for you. To view your personal token, go to Personal Account Settings > Access Token.
    
    2. Enter your login password to obtain the configuration.
    
    Copy the configuration to the .pypirc and pip.conf files in the root directory.

    Manual configuration

    Copy the code in the guide to the specific files.
    

    Push an Artifact

    Go to the project directory and copy and run the command in the terminal. For example, go to the Demo directory created above and run the command to push all artifacts in Demo/dist to CODING-AR.
    twine upload -r coding-pypi dist/*
    
    
    After the artifact is pushed successfully, refresh the page to view the latest artifacts. </dx-codeblock>
    

    Pull an Artifact

    Run the pip install command in the PyPI repository guide to pull an artifact.
    pip install <Artifact Name>
    

    Configure a Proxy

    If you try to pull an artifact that does not exist in the CODING private repository, the system will try to pull from the configured proxy. You can add a third-party artifact source to obtain artifacts from the specific repository. Without the need for configuration, CODING will retrieve artifacts in sequence from top to bottom.
    
    Replace <package> with the package name and run the command generated on the page to pull the package.
    
    The artifact and its dependencies will be pulled to the local machine and synchronized to CODING-AR. The package source will be shown on the details page.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support