首页 > 解决方案 > pip 从远程 github repo 安装 tar.gz 文件

问题描述

我为工作编写了一个 python 包,最初发布到 PYPI。一切都很完美,我可以 pip install 并使用我写的所有模块。一切都好。几分钟后,我意识到包中可能包含敏感信息,所以未发布它,愚蠢的我/新开发者愚蠢。

然后我决定最简单的方法是获取tar.gz文件——dist运行时在文件夹中生成python3 setup.py sdist bdist_wheel——并将其添加到我公司的私人 github 存储库中。

我添加了文件,提交,然后尝试了以下命令:

pip install git+ssh://git@github.com/company_github/my_repo.git@commithash

并得到以下错误信息:

 ERROR: Command errored out with exit status 1:
     command: /Users/me/opt/anaconda3/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/78/bn32jmyx0350cdp7cc_3t2ym0000gn/T/pip-req-build-qqbm6_ox/setup.py'"'"'; __file__='"'"'/private/var/folders/78/bn32jmyx0350cdp7cc_3t2ym0000gn/T/pip-req-build-qqbm6_ox/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/78/bn32jmyx0350cdp7cc_3t2ym0000gn/T/pip-req-build-qqbm6_ox/pip-egg-info
         cwd: /private/var/folders/78/bn32jmyx0350cdp7cc_3t2ym0000gn/T/pip-req-build-qqbm6_ox/
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/Users/me/opt/anaconda3/lib/python3.7/tokenize.py", line 447, in open
        buffer = _builtin_open(filename, 'rb')
    FileNotFoundError: [Errno 2] No such file or directory: '/private/var/folders/78/bn32jmyx0350cdp7cc_3t2ym0000gn/T/pip-req-build-qqbm6_ox/setup.py'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

我到底做错了什么?我是否需要将我的文件添加setup.py到包含我的文件的同一文件夹tar.gz中?或者我需要对需求文件做些什么->在安装所有依赖项之前无法安装?

可以pip install直接下载tarball吗?我也试了一下,

pip install https://github.com/company_github/my_repo/my_package.tar.gz  

但是有一个ERROR: HTTP error 404说法是找不到文件。

非常感谢任何帮助或指导!

编辑:

这是文件结构:

    .
    ├── CF_dev_emr_cluster.yaml
    ├── DeepAR\ Model\ Input\ Check\ (json).ipynb
    ├── __init__.py
    ├── anomaly
    │   ├── MAD.py
    │   └── __init__.py
    ├── batch_transform
    │   ├── batch_transform.py
    │   ├── generic_batch_transform.py
    │   ├── get_time_series_as_rows.py
    │   └── post_batch_transform.py
    ├── dev_env
    │   ├── CF_dev_emr_cluster_m5d.yaml
    │   ├── CF_dev_emr_cluster_r5d.yaml
    │   └── new_cluster_v2.sh
    ├── digital_logging.py
    ├── hive_table_checker
    │   ├── __init__.py
    │   └── hive_table_checker.py
    ├── metadata_io
    │   ├── README.md
    │   ├── __init__.py
    │   ├── manage_metadata.py
    │   ├── model_record_example.py
    │   └── tests
    │       ├── __init__.py
    │       └── test_manage_metadata.py
    ├── parquet_converter
    │   ├── CF_parquet_emr_cluster_m5d.yaml
    │   ├── DAGs
    │   │   ├── monthly_parquet_convert_v1.5.py
    │   │   ├── monthly_parquet_convert_v1.6.py
    │   │   └── utils
    │   │       └── check_partitions.py
    │   ├── __init__.py
    │   ├── dist_parquet_converter.sh
    │   ├── dist_parquet_copy.sh
    │   ├── dist_spark_parquet_converter.sh
    │   ├── parquet_config.json
    │   ├── parquet_converter.py
    │   ├── parquet_emr_connection_update.sh
    │   ├── parquet_final_copy.sh
    │   ├── parquet_start_stack.sh
    │   ├── patef_schema.json
    │   ├── ptef_schema.json
    │   └── readme.md
    ├── pyspark_visualizer
    │   └── visualizer.py
    ├── readme.md
    ├── setup.py
    ├── testfile.txt
    └── tests
        ├── __init__.py
        ├── airflow_testing
        │   ├── __init__.py
        │   └── dag_test
        │       ├── __init__\ 3.py
        │       ├── __init__.py
        │       ├── test_dag_pytest\ 2.py
        │       └── test_dag_pytest.py
        ├── config.py
        └── test_airflow_dags.py

    13 directories, 49 files

标签: gitgithubpippackagesetup.py

解决方案


推荐阅读